Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Data out of sync on multiseries from indexes of different Exchange

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

    Data out of sync on multiseries from indexes of different Exchange

    Objective: calculate ratio of Daily Close between two series: BarsArray[0] and BarsArray[1] of the same date.

    Problem: For US and Canadian indexes, a few of trading dates per year are not the same because of different stock market holidays. This caused the index data to be out of sync.

    1. Retrieving data using Closes[index][barsAgo] – DAILY data are out of sync when a different trading holidays are encountered.

    2. Retrieving data using BarsArray[index].GetClose(bar) – data are also out of sync because the retrieved bar data is mostly incorrect.

    3. The indexes used for testing (load both series on the screen):
    ^SP500 (Kinetick: SPX.XO)
    ^TSX_INDEX (Kinetick: C.TX60.X)

    Note: The Data Box is displaying the correct data for the these two indexes
    Please help to resolve. Test indicator is attached.

    Codes used for testing:

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    if(CurrentBars[0] == BarsArray[0].Count-2 && State == State.Historical)
    {
    ClearOutputWindow();
    TriggerCustomEvent(o =>
    {
    for(int ibarsAgo=0; ibarsAgo<40; ibarsAgo++)
    {
    int ibar= BarsArray[0].Count-2 - ibarsAgo;
    DateTime date_0 = BarsArray[0].GetTime(ibar); // check to see if different from Bars.GetTime(ibar)
    int idx_0= BarsArray[0].GetBar(date_0);
    int idx_1= BarsArray[1].GetBar(date_0);

    // date_0a == date_0
    DateTime date_0a = BarsArray[0].GetTime(idx_0);
    // date_1a != date_0, sometimes it is the same
    DateTime date_1a = BarsArray[1].GetTime(idx_1);

    // dClose_0 == dClose_0a , no problem
    // dClose_1 != dClose_1a, sometimes it is the same
    double dClose_0 = BarsArray[0][ibarsAgo];
    double dClose_1 = BarsArray[1][ibarsAgo];
    double dClose_0a = BarsArray[0].GetClose(idx_0);
    double dClose_1a = BarsArray[1].GetClose(idx_1);

    Print("ibarsAgo = " + ibarsAgo + ", date_0 = " + date_0 + ", date_0a = " + date_0a + ", date_1a = " + date_1a);
    Print("dClose_0 = " + dClose_0 + ", dClose_0a = " + dClose_0a + ", dClose_1 = " + dClose_1 + ", dClose_1a = " + dClose_1a);
    Print(".");
    }
    }, null);
    }
    }

    Results:

    ibarsAgo = 1, date_0 = 2021-02-02 12:00:00 AM, date_0a = 2021-02-02 12:00:00 AM, date_1a = 2021-02-01 12:00:00 AM (date_1a is different)
    dClose_0 = 3826.31, dClose_0a = 3826.31, dClose_1 = 1059.25, dClose_1a = 1044.68
    .


    Attached Files

    #2
    Ninjatrader help desk:
    Please disregard this request. I was able to resolve it by using
    DateTime date_0 = BarsArray[0].GetSessionEndTime(ibar) instead of BarsArray[0].GetTime(ibar).
    Last edited by kkc2015; 02-05-2021, 12:22 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    576 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 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
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X