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.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by BGWTEX, Today, 07:20 PM
    0 responses
    3 views
    0 likes
    Last Post BGWTEX
    by BGWTEX
     
    Started by hayleeabb, Today, 04:21 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by mg.watts, Today, 03:17 PM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by JTizz, Today, 01:20 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by omermirza, Today, 12:39 PM
    2 responses
    13 views
    0 likes
    Last Post omermirza  
    Working...
    X