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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        59 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        143 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        161 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        97 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        276 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X