Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using a DataSeries within another DataSeries

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

    Using a DataSeries within another DataSeries

    I'm porting code over from Wealthlab and ran into a syntax issue. I want to use one data series within another data series as per this Wealthlab statement.

    DataSeries linregLL = LinearReg.Series( High + Low - (Low + (High-Low)/2), 9);

    How is this done with using Ninja 8? I having problems declaring this correctly.

    #2
    Hello Boreland, and thank you for your question.

    In NinjaTrader 7, DataSeries objects were useful for storing various types of values. In NinjaTrader 8, Series<T> objects are useful for the same purpose.

    When we search through the NinjaTrader 7 help guide, we notice the closest built in indicator to LinearReg is called LinReg. This is the one I will be using here. We find its help guide page here,



    The built-in LinReg indicator does not take two doubles as an argument, so I will need to ignore this code, unless you could explain its function,

    High + Low - (Low + (High-Low)/2)

    When we try to compile code in NinjaTrader 7, we also find that Indicators, including LinReg, do not have a Series member. Instead, when we look at the Help Guide pages for Indicators, we find this section on the supported Values array,

    Originally posted by http://ninjatrader.com/support/helpGuides/nt7/values.htm
    Values is a collection holding DataSeries objects that hold the indicator's underlying calculated values. DataSeries objects held by this collection are added by calling the Add() method.
    In addition, we find in the documentation for Value, that it stores the primary Indicator's Value series, and is equivalent to Values[0].

    Thus, our NinjaTrader 7 code now looks like

    protected override void Initialize()
    {
    Add(LinReg(9));
    }

    protected override void OnBarUpdate()
    {
    DataSeries linregLL = Values[1];
    }

    In NinjaTrader 8, that becomes

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    // ...
    }
    else if (State == State.Configure)
    {
    AddChartIndicator(LinReg(9));
    }
    }

    protected override void OnBarUpdate()
    {
    Series<double> linregLL = LinReg(9);
    }

    Please let us know if there is any other way we can help.
    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by traderqz, Yesterday, 09:06 AM
    4 responses
    24 views
    0 likes
    Last Post traderqz  
    Started by traderqz, Today, 12:06 AM
    4 responses
    7 views
    0 likes
    Last Post traderqz  
    Started by Mongo, Today, 11:05 AM
    0 responses
    3 views
    0 likes
    Last Post Mongo
    by Mongo
     
    Started by Tim-c, Today, 10:58 AM
    0 responses
    2 views
    0 likes
    Last Post Tim-c
    by Tim-c
     
    Started by f.saeidi, Today, 10:19 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X