Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CrossAbove (Current Ask, Open price + Int Variable * TickSize)

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

    CrossAbove (Current Ask, Open price + Int Variable * TickSize)

    Hi having a problem setting a very simple condition

    // Condition set 1
    if (CrossBelow(GetCurrentAsk(), Open - S1 * TickSize, 1)
    && Open[1] < Close[1]
    && Position.Quantity == 0
    && Bracket == false)
    {
    EnterLongStop(Q, Open[0], "TSTZLong");
    }


    Note that S1 is a Private int previously defined.

    I am getting code NT0019.: Operator '-' cannot be applied to operands of type "NinjaTraderSata|DataSeries" and "double".


    I have also tried:
    if (CrossBelow(GetCurrentAsk(), Open (0) - S1 * TickSize, 1)
    and got: CS0103: The name 'Open' does not exist in the current context.

    I'll appreciate any help.

    Thanks Horacio








    #2
    Hello horacioofman,

    Thanks for your first post in the forums!

    The error message is advising that you cannot subtract a double value from a data series. In your code , Open - S1 * TickSize, 1), Open is a data series and S1 is a double type variable. You just need to specify which open value of the Open data series to subtract the S1 value from.

    This code: Open (0) - S1 * TickSize, 1) is producing an error because the use of (0) makes the compiler think Open(0) is a method

    I suspect you want this: Open[0] - S1 * TickSize, 1) In this case the square brackets are telling the compiler which data point in the data series of open to use.

    Comment


      #3
      Thanks Paul. You were right on the use of square parenthsis/brackets, but crossbellow funtion did not take the corrected statement either. I ended up using a >= operator for on currentprice(0):

      if (GetCurrentAsk(0)< (Open[0]-S1 * TickSize ) ........

      I think it is working. Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      128 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      73 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      116 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      109 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      88 views
      0 likes
      Last Post CarlTrading  
      Working...
      X