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 burtoninlondon, Today, 12:38 AM
      0 responses
      5 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      12 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      13 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,982 views
      3 likes
      Last Post jhudas88  
      Working...
      X