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 Max238, Today, 01:28 AM
      2 responses
      26 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by Shansen, 08-30-2019, 10:18 PM
      25 responses
      949 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by JonesJoker, 04-22-2024, 12:23 PM
      8 responses
      41 views
      0 likes
      Last Post JonesJoker  
      Started by timko, Today, 06:45 AM
      0 responses
      4 views
      0 likes
      Last Post timko
      by timko
       
      Started by Waxavi, 04-19-2024, 02:10 AM
      2 responses
      39 views
      0 likes
      Last Post poeds
      by poeds
       
      Working...
      X