Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        563 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        329 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
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X