Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

multi-timeframes and "new DataSeries(this)"

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

    multi-timeframes and "new DataSeries(this)"

    Hi,

    I'm still pretty green when it comes to programming and C#, and I'm a little unclear with it comes to using the "this" syntax.

    What I'm trying to do is to add a new DataSeries for the Secondary bar object.

    So for example:

    Code:
    protected override void Initialize()
    {
         Add(PeriodType.Day,1);
    
    }
    Now, how do I create a new DataSeries to be used only for secondary Daily bars (i.e. during BarsInProgress == 1)? Would this, under Initialize() be correct:

    Code:
    myDataSeries = new DataSeries(this);
    Thanks.

    -Nick

    #2
    Hello,
    Thank you for writing in.

    'this" refers to the Indicator or strategy that the data series is being created in.
    If you are wanting a secondary data series based off of different values would would need to add a secondarySeries into OnBar Update

    An example of this is
    [CODE]
    protected override void OnBarUpdate()
    if (secondarySeries == null)
    {
    /* Syncs another DataSeries object to the secondary bar object.
    We use an arbitrary indicator overloaded with an IDataSeries input to achieve the sync.
    The indicator can be any indicator. The DataSeries will be synced to whatever the
    BarsArray[] is provided.*/

    secondarySeries = new DataSeries(SMA(BarsArray[1], 50));
    }

    In my example I am getting the data series that is synced to another time frame by using the SMA indicator to get the BarsArray. You can then set the seconDarySeries accorindingly after this in OnBarUpdate.

    For more information on DataSeries Class please see the following link, http://ninjatrader.com/support/helpGuides/nt7/dataseries_class.htm

    I would also recommend to review our reference file on adding a Secondary Data Series http://ninjatrader.com/support/forum/showthread.php?t=3572

    If we can be of any other assistance please let me know.
    Cody B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

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