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 Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              558 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              324 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              545 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              547 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X