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

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 quantismo, 04-17-2024, 05:13 PM
    3 responses
    25 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by ScottWalsh, 04-16-2024, 04:29 PM
    7 responses
    34 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by cls71, Today, 04:45 AM
    0 responses
    5 views
    0 likes
    Last Post cls71
    by cls71
     
    Started by mjairg, 07-20-2023, 11:57 PM
    3 responses
    214 views
    1 like
    Last Post PaulMohn  
    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
    4 responses
    547 views
    0 likes
    Last Post PaulMohn  
    Working...
    X