Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarUpdate() get called before IsFirstTickOfBar is true for last closed bar

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

    OnBarUpdate() get called before IsFirstTickOfBar is true for last closed bar

    Hi folks,

    It seems to me that OnBarUpdate() get called before IsFirstTickOfBar condition is true for last closed bar in loading history data for an indicator. My program looks like the following

    protected override void OnBarUpdate()
    {
    //Do some calculation on latest bar
    //Do some thing A;

    if(IsFirstTickOfBar)
    {

    //Do some calculation for the last closed bar
    //Do some thing B;

    }
    }

    It seems everything fine with the indicator if I replay the data, either in normal speed or in fast mode. However, if seems there are cases where The "A" part of a new bar is called before the "B" part of the last closed bar is executed. I got to know this before I found there are some slightly difference in the chart of indicator after I remove and re-add the indicator into the chart.

    When I develop the indicator, I presume the bar closed event happens before new tick data in. But it seems it didn't apply to load history data. How I can fix this?

    Thank you very much!


    Best Regards
    David

    #2
    Hi David, thanks for writing in.

    If you are not using Tick Replay the FirstTickOfBar will not become true until the first real time tick. You would need to enable tick replay to detect the first tick of each historical bar. See here for more documentation:

    https://ninjatrader.com/support/help...ick_replay.htm

    Please let me know if this does not resolve your inquiry.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    68 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    151 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X