Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DataSeries Objects With Different Bars Objects

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

    DataSeries Objects With Different Bars Objects

    If I create a DataSeries object myDataSeries and I am processing bars with two different periods (or tick counts), do I need one DataSeries object for each period or will NT correctly account for BarsInProgress?

    For example, can I do the following

    private DataSeries myDataSeries;
    .
    .
    .

    if (BarsInProgress == 0)

    myDataSeries.Set(Indicator());
    .
    .
    .

    if(BarsInProgress == 1)

    myDataSeries.Set(Indicator(BarsArray[1]);


    or do I need two separate DataSeries?

    private DataSeries myDataSeries0;
    private DataSeries myDataSeries1;

    Thanks for reading

    #2
    Hello x703jko,

    Thank you for writing in. How you go about this would depend more specifically on what you are trying to do.

    In the example you provided, it would be possible for whichever data series called OnBarUpdate last on a given bar to set your custom DataSeries value for that bar.

    Please keep in mind that OnBarUpdate is not going to be called in order by the data series. Here is an example to help illustrate of the sequence that OnBarUpdate might be called in:

    Data Series 1 calls OBU for bar 1
    Data Series 2 calls OBU for bar 1
    Data Series 2 calls OBU for bar 2
    Data Series 1 calls OBU for bar 2
    Data Series 2 calls OBU for bar 3
    Data Series 1 calls OBU for bar 3
    Data Series 1 calls OBU for bar 4
    Data Series 2 calls OBU for bar 4

    To handle this the easiest way possible, I would recommend using two data series so that you do not have values getting overwritten randomly.

    A useful method when using custom DataSeries is the ContainsValue method:
    Code:
    DataSeries.ContainsValue(int barsAgo)
    More information on this can be found in our help guide under "Checking for Valid Values" here: http://ninjatrader.com/support/helpG...sub=dataseries

    You can use the ContainsValue method to determine if your DataSeries has already been set to a value on a given bar because it will still return a placeholder value otherwise.

    Please let me know if I may be of further assistance.
    Michael M.NinjaTrader Quality Assurance

    Comment

    Latest Posts

    Collapse

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