Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 XXtrader, Yesterday, 11:30 PM
    2 responses
    11 views
    0 likes
    Last Post XXtrader  
    Started by Waxavi, Today, 02:10 AM
    0 responses
    6 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Started by TradeForge, Today, 02:09 AM
    0 responses
    11 views
    0 likes
    Last Post TradeForge  
    Started by Waxavi, Today, 02:00 AM
    0 responses
    2 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Started by elirion, Today, 01:36 AM
    0 responses
    7 views
    0 likes
    Last Post elirion
    by elirion
     
    Working...
    X