Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Current Bar Number Being Processed

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

    Current Bar Number Being Processed

    when a script is loaded and it works its way through each historical bar 0 to Count
    can I (should I) reference the current bar being processed?

    e.g.

    if (CurrentBarIndex == 42)
    {

    }

    #2
    Hello,

    Thank you for the question.

    I would like to ask, What are you trying to do with the CurrentBar?

    In general you would use CurrentBar rather than CurrentBarIndex, unless CurrentBarIndex is a variable you have defined.

    Here is more information: http://www.ninjatrader.com/support/h...sub=CurrentBar

    Can you please detail more on what you are trying to do and I will provide a more clear answer.

    I look forward to being of further assistance.

    Comment


      #3
      ok thanks again (1st class product + 1st class support ... consistently).

      During historical load I have a method that opens trading on specific bars and another method that compare the current bar to this. I can use Time[0] instead of an index but just wanted to know how NT handles this.

      e.g. if chart has 100 bars (Count=100) and a script is loaded, CurrentBar = 0 if 1st bar is being processed and CurrentBar = 99 if last bar is being processed. Count=100 at any time during load.

      Is that correct?

      Comment


        #4
        Hello,

        Thank you for the clarification.

        e.g. if chart has 100 bars (Count=100) and a script is loaded, CurrentBar = 0 if 1st bar is being processed and CurrentBar = 99 if last bar is being processed. Count=100 at any time during load.
        You are correct, the Count is set before the bars start loading so we know when to stop trying to load data.

        If you load a chart, the Count will start as the amount of bars so lets say 100.

        In OnBarUpdate on CurrentBar == 0, Count is equal to 100.
        on CurrentBar == 50, Count is still equal to 100.
        on CurrentBar == 99, Count is still equal to 100.

        Count will increase though if a new bar is generated, so we have Count == 100, a new bar generates and now Count is 101.

        Here is more information on Count http://www.ninjatrader.com/support/h.../nt7/count.htm

        I would recommend taking a look at the Data section in the NinjaScript manual, this is where the help for Count, CurrentBar, CurrentBars and a lot of the other fundamental items in NinjaScript are located.


        Please let me know if I may be of additional assistance.

        Comment

        Latest Posts

        Collapse

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