Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Access historical bars via Low[]

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

    Access historical bars via Low[]

    I have used Metatrader 4 so far and am currently in the process of becoming friends with NinjaTrader.

    I would like to access historical bars using Low[] in an indicator.

    For Low[0] this seems to work. See example 1.

    It doesn't seem to work for Low[10] . See example 2.

    Can someone explain why Low[10] doesn't seem to work?

    Seems like a silly, simple problem, but I just can't figure out the solution....​
    Attached Files

    #2
    Hello Joost,

    You are likely seeing an error here, its best to keep the control center log tab and NinjaScript output window in view while testing scripts. The problem is that you can't use 10 bars ago before processing 10 bars. Your script always starts at bar 0 and works forward, trying to access 10 bars ago on bar 0 doesn't make sense because there are not 10 bars before bar 0.

    To fix this type of problem you can check the CurrentBar. NinjaScript is C# language so you can use features like return to stop code execution past that point based on a condition.

    Code:
    if(CurrentBar < 10) return;
    // do something with Low[10] after this point

    Comment


      #3
      Perfect, thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      627 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      359 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
      562 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      567 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X