• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DataSeries that are nested

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

    DataSeries that are nested

    I am a newbie to NinjaScript. In the documentation it is given that

    "Note: By default NinjaTrader limits the number of values stored for DateTimeSeries objects to 256. This drastically improves memory performance by not holding onto old values that are generally not needed."

    Consider a situation where I have say 3000 periods loaded on a chart (e.g. 1-min bars) and I have a code that has 3 DataSeries x1, x2, x3 and does the following:

    protected override void Initialize()
    {
    ....
    x1 = new DataSeries(this);
    x2 = new DataSeries(this);
    x3 = new DataSeries(this);
    ....
    }

    protected override void OnBarUpdate()
    {
    ....
    x1.Set(EMA(Close[0]-High[0], Period1)[0])

    x2.Set(EMA(High[0]-Open[0], Period2)[0])

    x3.Set( EMA( x1[0]*x2[0], Period3)[0])
    ....
    }

    In the code above, when the EMA is calculated for x3, does the EMA use only 256 bars from x1 and x2 to calculate the results for x3?

    #2
    Hello uday12,

    Using EMA(Close[0]-High[0], Period1)[0] is not valid.

    Close[0]-High[0] would be a double.

    The following overloads are possible with EMA:
    EMA(int period)
    EMA(IDataSeries input, int period)

    So you do:
    EMA(Close, Period1)[0]

    Or:
    EMA(Close, Period1)[0] - EMA(High, Period1)[0]

    http://ninjatrader.com/support/helpG...onential_e.htm

    In either case, the number of bars used for the EMA calculation will be the period. Whatever you have Period1 set to.

    If Period1 is set to 5 it will use 5 bars.

    When MaximumBarsLookBack is set to MaximumBarsLookBack.TwoHundredFiftySix, then the maximum size Period1 can be set to is 256. At that point if you supply 300, it will only use 256.
    So its up to 256.

    When MaximumBarsLookBack is Set to MaximumBarsLookBack.Infinite then it will use as many bars as you have specified with Period1.

    http://ninjatrader.com/support/helpG...rslookback.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea, thanks.

      One more question: would this be correct syntax:

      EMA(x1*x2, Period)

      where x1 and x2 are both IDataSeries / DataSeries ?

      Comment


        #4
        Hello uday12,

        No, Dataseries cannot be multiplied together.

        This would be like multiplying an array with an array. These are not numbers they are a collection of values for each bar.

        Below is a link to the help guide on DataSeries.
        http://ninjatrader.com/support/helpG...ries_class.htm
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by tshidsmre, Today, 06:06 AM
        0 responses
        3 views
        0 likes
        Last Post tshidsmre  
        Started by KetoProPlus123, Today, 06:05 AM
        0 responses
        3 views
        0 likes
        Last Post KetoProPlus123  
        Started by vdhsdkhl, Today, 03:00 AM
        0 responses
        5 views
        0 likes
        Last Post vdhsdkhl  
        Started by fluffier, Yesterday, 11:49 PM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by GARZONJ, Yesterday, 09:02 PM
        0 responses
        10 views
        0 likes
        Last Post GARZONJ
        by GARZONJ
         
        Working...
        X