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

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 judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    59 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Today, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Started by olisav57, Today, 07:39 PM
    0 responses
    7 views
    0 likes
    Last Post olisav57  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    21 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    10 views
    0 likes
    Last Post cre8able  
    Working...
    X