Announcement

Collapse
No announcement yet.

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 charlesugo_1, 05-26-2026, 05:03 PM
              0 responses
              52 views
              0 likes
              Last Post charlesugo_1  
              Started by DannyP96, 05-18-2026, 02:38 PM
              1 response
              142 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 05-11-2026, 05:56 AM
              0 responses
              160 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 05-10-2026, 08:12 PM
              0 responses
              96 views
              0 likes
              Last Post CarlTrading  
              Started by Hwop38, 05-04-2026, 07:02 PM
              0 responses
              276 views
              0 likes
              Last Post Hwop38
              by Hwop38
               
              Working...
              X