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 sjsj2732, Yesterday, 04:31 AM
        0 responses
        36 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        287 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        288 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        134 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        95 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X