Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"High[-1] >= High[0]"... does this work in Ninjascript?

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

    "High[-1] >= High[0]"... does this work in Ninjascript?

    I'm trying to port some code from Thinkscript to Ninjascript and have a question about this line of code:

    High[-1] >= High[0]

    Can I use High[-1], Low[-1], etc in Ninjascript? I have a NT strategy that compiles OK with that, I'm just not sure it's going to handle things like Thinkscript does.

    #2
    Try High[1]. Unlike eSignal or TOS, NinjaScript doesn't need the negative sign.

    Dan
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment


      #3
      In TOS High[-1] looks at the next bar. High[1] in TOS gives me the previous bar high just like Ninja. Below is a snippet from the Thinkscript user manual:



      Editing Stategies - Referencing Historical Bars

      In the example above you see a construct that looks like this:

      price[length]

      Given our default values for price and length, this would actually resolve to 'close[12]'. What you see here is a reference to a bar other than current bar using [offset] syntax. In this case, 'close[12]' would give you the close price on the bar 12 bars in the past. It's important to remember that positive values are bars BACK and negative numbers are bars FORWARD:

      def diff = close - close[-1];

      In this example, diff equals the difference in the current and the next value. ]

      Comment


        #4
        Fred, unfortunately you can't reference future values in NinjaScript, as those are simply not available going forward with your script - on the very rightmost bar in realtime there would no value one bar ahead, you might experiment with substituting a regression value for it.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        67 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        36 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        59 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X