Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar index

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

    Bar index

    Hello

    I'm in the process of porting a technical study from WealthLab 3.0 to Ninjatrader. This study will often reference a previous bar's index. Bar indexing in WL starts from 0 for the earliest bar in the bar array. As a new bar is formed, an incremented index is assigned to this bar. Within this scheme, bars that meet certain conditions can be 'landmrked' by their index which will not change.

    In Ninjatrader, a bar's index does not remain constant. This obviously makes the port of the above study difficult. The most obvious solution would be to perform the entire analysis each time a new bar arrives. Unfortunately this is far from being efficient.

    So the question is, is there a way around this? Is there a way to keep track of a bar's unique index that is constant?

    Along the same lines, the function DrawLine uses 'x bars ago from the current bar' as the input for the x axis coordinate. Do the coordinates of the line change as new bars arrive?

    Thanks in advance.

    #2
    NinjaTrader bar indexing is reverse. 0 refers to latest bar. 1 refers to previous bar. etc. To keep track of a bar number in the left to right fashion you can use CurrentBar.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks, Josh.

      Comment


        #4
        We have "CurrentBar" which is a pointer that increments from left to right on a chart. Close[int barAgo] is a reference to how many bars ago you wish to access a value for.
        RayNinjaTrader Customer Service

        Comment


          #5
          Thanks, Ray. I appreciate the prompt reply from you and Josh. I'm all clear now.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          561 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          325 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X