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 Rogers101, 05-05-2024, 11:30 AM
              16 responses
              49 views
              0 likes
              Last Post Rogers101  
              Started by ninza33, Today, 12:31 PM
              2 responses
              9 views
              0 likes
              Last Post ninza33
              by ninza33
               
              Started by Bobin, 03-12-2024, 08:51 AM
              15 responses
              481 views
              0 likes
              Last Post fiddich
              by fiddich
               
              Started by Skifree, Today, 11:21 AM
              4 responses
              14 views
              0 likes
              Last Post Skifree
              by Skifree
               
              Started by Bogdan097, Today, 03:25 PM
              0 responses
              7 views
              0 likes
              Last Post Bogdan097  
              Working...
              X