Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to know when multi timeframes are all loaded?

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

    How to know when multi timeframes are all loaded?

    I'm adding an extra data serie in the onstatechanched event (State==atatse.Configured or DataLoaded).
    The data series are all for the same instrument, but with different timeframes.
    The main (chart) data serie is M5, and the extra dataserie is D1.
    How can I determine when both data series are completely loaded, so that I can use Closes[1][1] without errors?
    I also need to get the ATR(Inputs[1], 14).Value[1] but get errors about "accessing a barsAgo for a bar that is not loaded yet".

    Please advice.

    #2
    Hello wjadevries, thanks for writing in.

    To check that you have at least 1 bar in both series, you can add this check at the beginning of OnBarUpdate:

    if(CurrentBars[0] < 1 || CurrentBars[1] < 1)
    {
    return;
    }

    //access Closes[1][1] here, CurrentBars Documentation

    The ATR problem could also likely be fixed by adding this CurrentBars check at the top of OnBarUpdate.

    Please let me know if I can assist any further.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    72 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X