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 DannyP96, 05-18-2026, 02:38 PM
        1 response
        27 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        117 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        69 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        226 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        415 views
        0 likes
        Last Post CaptainJack  
        Working...
        X