Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Paul H.NinjaTrader Customer Service

    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 bmartz, 03-12-2024, 06:12 AM
      5 responses
      32 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Started by Aviram Y, Today, 05:29 AM
      4 responses
      12 views
      0 likes
      Last Post Aviram Y  
      Started by algospoke, 04-17-2024, 06:40 PM
      3 responses
      28 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by gentlebenthebear, Today, 01:30 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by cls71, Today, 04:45 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X