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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        630 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        566 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X