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 argusthome, 03-08-2026, 10:06 AM
        0 responses
        109 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        59 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        37 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        40 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        77 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X