Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Recognizing instrument when using stop loss on multi strategy script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Recognizing instrument when using stop loss on multi strategy script

    I am working with a multi strategy script. It is easy to recognize trades on exexution method through their names..
    If (execution.Name == "Long AAPL") do this..............

    However when some strategy is stoped .. execution.Name will be "stop loss" :for all.
    So, I ve tried

    if (execution.Name == "Long AAPL" ) && (execution.Instrument == "AAPL) do this,,,,
    but the system is not accepting it..
    Any clue?

    #2
    Hello Dafonseca,

    Thank you for your post.

    The Stop Loss name, is this coming from the SetStopLoss()?

    If so, this name cannot be overridden. You would want to check for the FromEntrySignal and you can place this text in a DrawText() on the chart so that you can see the order being filled clearly.

    Additionally, is the same syntax that you are using in the script? Including the parenthesis?
    Code:
    if (execution.Name == "Long AAPL" ) && (execution.Instrument == "AAPL)
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I ve tried this:

      if (execution.Instrument== "GOOG")

      and a error message is sayimg:

      operatot '--' can not be applied to operands of type NinjaTrader.Cbi.Instrument and string..
      Any clue??

      when i use this:
      (execution.Name == "Stop loss")
      compiler accepts..

      Comment


        #4
        Originally posted by dafonseca View Post
        I've tried this:

        if (execution.Instrument== "GOOG")

        and a error message is saying:

        operator '--' can not be applied to operands of type NinjaTrader.Cbi.Instrument and string.
        Any clue??
        Is this the direct syntax that you have inputted into the editor? The == should work but I wouldn't expect the -- to work.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Sorry. my mistake.
          the message says operator "==" (as I used).

          Comment


            #6
            I ve tested in another strategy (same result) and I ve saved the screen to show you..
            Let me know.
            Attached Files

            Comment


              #7
              dafonseca,

              You are getting the Instrument in this case. You need to add .MasterInstrument.Name at the end of execution.Instrument to get the name property.

              if(execution.Instrument.MasterInstrument.Name == "AAPL")

              http://www.ninjatrader.com/support/h...trument_na.htm

              Let me know if this helps
              Cal H.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by HiddenPhilosopher, 05-22-2020, 01:09 AM
              25 responses
              2,699 views
              0 likes
              Last Post Trader17  
              Started by Misplace, Today, 11:55 AM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by amousaber, Yesterday, 09:30 AM
              1 response
              26 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by PopovDS, Yesterday, 11:17 AM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by Mr Bread, Yesterday, 12:01 PM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X