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 Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,788 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,293 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    13 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    63 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X