Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Missing last history bar.

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

    Missing last history bar.

    I am new to NinjaTrader amd working on some testing strategy. Today, I created a custom strategy to print history data of a stock from 2010-01-01 to 2010-10-15. In OnBarUpdate() process, I am using following code to print Currentbar, Date, and Count.
    protected override void OnBarUpdate()
    {
    Print("The CurrentBar is " + CurrentBar.ToString() + ". The date is " + Time[0].Date.ToString() + ". The Count is " + Count.ToString() + ".");
    }

    From the Output window, I saw the last line is as following.
    The CurrentBar is 197. The date is 2010-10-14 12:00:00 AM. The Count is 199.

    Actually, I expexted the last line in Output window should be something like:
    The CurrentBar is 198. The date is 2010-10-15 12:00:00 AM. The Count is 199.

    It looks like the last bar 198 as of 2010-10-15 is missing. Did I do something wrong in code? How can I get the missed last bar?

    By the way, I did set "CalculateOnBarClose = true;" in Initialize() process.

    Thanks.

    #2
    qfweiwei, welcome to our forums and NinjaScript - you would need to work with CalculalteOnBarClose set to false to access the last 'developing' bar on the chart.

    Comment


      #3
      Hi Bertrand,

      Thanks for your kind reply. I set CalculateOnBarClose to be false, and ran again with From date as 2010-01-01 and To date as 2010-10-19. This time, I get the last line of bar 198 as of 2010-10-15 as following.

      The CurrentBar is 198. The date is 2010-10-15 12:00:00 AM. The Count is 199.

      However, I did not see line for today as of 2010-10-18. Furthermore, the Count is still 199 rather than 200. Do I need to do something else? By the way, I am using IB data feed.

      Thanks,
      weiwei

      Comment


        #4
        weiwei, this is expected - the count would always be larger than the CurrentBar - http://www.ninjatrader.com/support/h.../nt7/count.htm

        I'm not sure where and in which timezone you're based, but today would be the 19th - can you please check the current PC clock & data and sync them up if needed?

        For IB data this is the reference to stamp your bars, as they would not provide a native timestamp.

        Thanks

        Comment

        Latest Posts

        Collapse

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