Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Syntax Problems

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

    Syntax Problems

    In the following condition:

    // Condition set 2
    if (Position.MarketPosition == MarketPosition.Flat
    && CrossBelow(LinReg(Close,
    15), (LinReg(Close, 2) - bBuff), 1))
    {
    EnterShort(n,
    "SS.LRx");
    }

    I get an error message ojectiong to the - operand in (-bBuff).

    How can I apply a buffer, such as an addition or subtraction of value, from one of the elements of a crossover strategy?

    #2
    You need to be subtracting that buffer from the actual value of the LinReg and not the DataSeries.

    LinReg(Close, 2)[0] - bBuff
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Syntax errors continued

      Originally posted by NinjaTrader_Josh View Post
      You need to be subtracting that buffer from the actual value of the LinReg and not the DataSeries.

      LinReg(Close, 2)[0] - bBuff

      Is this the way it should read? (I have add the [0] to both legs of the condition?

      // Condition set 2
      if
      (Position.MarketPosition == MarketPosition.Flat
      && CrossBelow(LinReg(Close,
      15)[0], (LinReg(Close, 2)[0] - bBuff), 1
      ))
      {
      EnterShort(n,
      "SS.LRx"
      );
      }

      Comment


        #4
        Skat100,

        No, you need the first one as a DataSeries.

        You want a DataSeries to cross a specific double value.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        72 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        39 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        63 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        63 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X