Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need to sync when using data series and multi-time frames

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

    Need to sync when using data series and multi-time frames

    I was intrigued by the need to perform this 'sync' when using multi-time frame building your indicators after I run into some problems (my indicator would perform wrong calculations).
    Although this has solved the problem, I'm still not clear why this is necessary.

    Can someone give me some more detailed explanation why you need the 'sync' when dealing with data series and multi-time frame? Also, what is the best way to do this sync without adding a useless calculation (in this case an SMA not very 'heavy' but still I hate to waste CPU cycles...).

    Thanks,
    Dori



    Code:
    [FONT=Courier New][SIZE=3][FONT=Courier New][SIZE=3][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][COLOR=#008000][FONT=Courier New][COLOR=#008000][FONT=Courier New][COLOR=#008000][SIZE=1]/* Only need to sync DataSeries objects once. We couldn't do this sync in the Initialize() method because we[/SIZE]
    [SIZE=1]cannot access the BarsArray property there. */[/SIZE]
    [/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][FONT=Courier New][/FONT][/FONT][SIZE=1][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][FONT=Courier New] (secondarySeries == [/FONT][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]null[/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][/SIZE][FONT=Courier New][FONT=Courier New][SIZE=1])[/SIZE]
    [SIZE=1]{[/SIZE]
    [/FONT][/FONT][FONT=Courier New][COLOR=#008000][FONT=Courier New][COLOR=#008000][FONT=Courier New][COLOR=#008000][SIZE=1]/* Syncs another DataSeries object to the secondary bar object.[/SIZE]
    [SIZE=1]We use an arbitrary indicator overloaded with an IDataSeries input to achieve the sync.[/SIZE]
    [SIZE=1]The indicator can be any indicator. The DataSeries will be synced to whatever the[/SIZE]
    [SIZE=1]BarsArray[] is provided.*/[/SIZE]
    [/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][FONT=Courier New][SIZE=1]secondarySeries = [/SIZE][/FONT][/FONT][SIZE=1][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]new[/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][FONT=Courier New] DataSeries(SMA(BarsArray[[/FONT][/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][FONT=Courier New]], [/FONT][/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]50[/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=3][FONT=Courier New][SIZE=3][SIZE=1]));[/SIZE]
    [SIZE=1]}[/SIZE]
    
    [/SIZE][/FONT][/SIZE][/FONT]

    #2
    ds1111,

    Multi-timeframe indicators call their OnBarUpdate() whenever a data series is updated. With multiple data series you will have them updating at different times, calling OnBarUpdate() at different times, and as such sometimes you may want to sync something to one appropriately.
    Adam P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    569 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    548 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X