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 drnoggin, Today, 12:19 PM
    0 responses
    2 views
    0 likes
    Last Post drnoggin  
    Started by synthhokie, Today, 12:00 PM
    0 responses
    13 views
    0 likes
    Last Post synthhokie  
    Started by moneyexe, Today, 11:22 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by stevec1824, Today, 11:00 AM
    2 responses
    8 views
    0 likes
    Last Post stevec1824  
    Started by sofortune, Today, 10:05 AM
    2 responses
    14 views
    0 likes
    Last Post sofortune  
    Working...
    X