Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarUpdate() sometimes not getting called?

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

    OnBarUpdate() sometimes not getting called?

    Hi,

    We are using NT 8.0.20.1 64-bit. Testing on a 1 minute chart bar.

    We have an indicator that receives data from backend. We then use TriggerCustomEvent() to call a method which processes then plots those data. When the data is processed, we use datetime values from _CurrentBar, _CurrentBar - 1, _CurrentBar -2 -- stored in vars Time0, Time1, Time2 -- to determine if we plot on current bar or previous bar. If not on current bar or previous bar, we loop thru Time series to figure out which bar it belongs to.

    So sometimes nothing gets plotted resulting in gaps on data plotted. Based on the logs from the Print() statements added on method called by TriggerCustomEvent(), somehow the OnBarUpdate() doesn't get called resulting in datetime's (using Time.GetValueAt) for CurrentBar, _CurrentBar and Time0, Time1, Time2 to still have an old datetime value, and so these new data aren't in the range of Time0,Time1,Time2 and so we have to go thru Time series, and if not there then it nothing gets plotted for that bar.

    OnBarUpdate() is light. Returns if CurrentBar is < 1, else sets those datetime vars. It has other code that runs when State is Historical.

    Sample logs:
    (data received by indicator are just processed ticks and comes from the same datafeed provider used to display realtime data on NT.)

    Expected:
    time0: 2020/03/16 22:05:00.0000
    time1: 2020/03/16 22:04:00.0000
    time2: 2020/03/16 22:03:00.0000
    time3: 2020/03/16 22:02:00.0000
    TRUE = 2020/03/16 22:04:00.0000<= 2020/03/16 22:04:50.7160 <= 2020/03/16 22:05:00.0000 // match current bar, data.timestamp >= time1 and data.timestamp <= time0
    FALSE = 2020/03/16 22:03:00.0000<= 2020/03/16 22:04:50.7160 <= 2020/03/16 22:04:00.0000 // match previous bar, data.timestamp >= time2 and data.timestamp <= time1
    _CurrentBar Tick Timestamp: 2020/03/16 22:05:00.0000
    CurrentBar Tick Timestamp: 2020/03/16 22:05:00.0000
    Last OnBarUpdate(): 2020/03/16 22:04:52.0330

    Not expected:
    time0: 2020/03/16 22:51:00.0000
    time1: 2020/03/16 22:50:00.0000
    time2: 2020/03/16 22:49:00.0000
    time3: 2020/03/16 22:48:00.0000
    FALSE = 2020/03/16 22:50:00.0000<= 2020/03/16 22:54:01.2320 <= 2020/03/16 22:51:00.0000
    FALSE = 2020/03/16 22:49:00.0000<= 2020/03/16 22:54:01.2320 <= 2020/03/16 22:50:00.0000
    (2020/03/16 22:54:01.2320) does not match with current bar (2020/03/16 22:51:00.0000) nor with previous bar (2020/03/16 22:50:00.0000)
    (2020/03/16 22:54:01.2320) matched with barOpen (2020/03/16 22:55:00.0000)
    Done search attempt for bar where tick timestamp (2020/03/16 22:54:01.2320) belongs to.
    barsAgo: 5786
    barTickTimestamp: 2020/03/16 22:55:00.0000
    _CurrentBar Tick Timestamp: 2020/03/16 22:51:00.0000
    CurrentBar Tick Timestamp: 2020/03/16 22:51:00.0000
    Last OnBarUpdate(): 2020/03/16 22:50:49.1010 <---- last time OnBarUpdate() got called

    Above, it does seem to find the bar when looping thru Time series but I'm still curious as to why OnBarUpdate() sometimes don't get called. Is there a condition that our indicator reaches and that somehow causes OnbarUpate() to not get called?

    Thanks.



    #2
    Hello cmarkb,

    Thanks for your post.

    Is this called from another script, if so does Update() need to be triggered?

    If that does not resolve, please provide a reduced sample test script that demonstrates the issue and the steps to reproduce.

    Comment


      #3
      Hi PaulH,

      Thanks for the reply.

      No, not called from another script. Just this one indicator, added to a minute bar chart.
      No the Update() is not triggered.

      Unfortunately this thing happens irregularly. Sometimes it doesn't happen at all the whole session/day. Sometimes happens once in an afternoon and maybe once or twice in the evening at a certain range of time.

      Comment


        #4
        Hi PaulH,

        Is calling ForceRefresh() the same as calling Update()? We a graphic, a legend panel that can be toggled being displayed. We call ForceRefresh() every 250ms.

        Comment


          #5
          Hello cmarkb,

          Thanks for your replies.

          No, ForceRefresh is not the same as UpDate(), please see: https://ninjatrader.com/support/help...t8/?update.htm

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 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