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

check symbol strategy is appied to

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

    check symbol strategy is appied to

    Hi

    I'm developing a strategy I'd like to use on different Forex pairs
    in order to set my stoploss order on a short position I need to know the spread of this pair the strategy is applied to
    (long positions don't have this problem as forex prices are bid driven)

    AtmStrategyChangeStopTarget(0, High[2] + XXX * TickSize, "STOP1", atmStrategyId);

    the XXX in the line above should present the spread of the pair the strtegy is applied to

    example: for eur/usd 3 ticks spread XXX = 3
    gbp/jpy 9 ticks spread XXX = 9
    .....

    Could you please help me with some code on how to check what symbol the strategy is applied to
    so I can define the appropriate stoploss offset

    Thank you very much

    Nico

    #2
    Instrument.FullName

    RayNinjaTrader Customer Service

    Comment


      #3
      Hi,

      I don't seem to get this problem solved,
      In the Initialize part of my code I put :

      if (Instrument != null && Instrument.FullName == "EURUSD")
      {
      int spread = 3;
      }

      Later in the code I'm trying to get this 'spread' variable included in the next line, but I keep getting the error message,
      "The name 'spread' does not exist in the current context

      AtmStrategyChangeStopTarget(0, High[2] + spread * TickSize, "STOP1", atmStrategyIdLong2);


      Any help is much appreciated

      Nico

      Comment


        #4
        This is a C# programming issue. Please consult the relevant Microsoft documents for how to correctly code in C#.

        Hint: You declared a variable "spread" within the scope of your "if" statement. As soon as you leave this scope it no longer will be there. You would need to make it a class variable (see "Variables" region).

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ninza33, Yesterday, 12:31 PM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by patrickmlee007, Today, 09:33 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
        53 responses
        5,306 views
        0 likes
        Last Post BartMan
        by BartMan
         
        Started by Richozzy38, Today, 01:06 PM
        2 responses
        12 views
        0 likes
        Last Post Richozzy38  
        Started by Lele2k24, Today, 01:32 PM
        4 responses
        10 views
        0 likes
        Last Post Lele2k24  
        Working...
        X