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

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 bortz, 11-06-2023, 08:04 AM
    47 responses
    1,611 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    9 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    19 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    6 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    22 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X