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

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 pibrew, Today, 06:37 AM
        0 responses
        4 views
        0 likes
        Last Post pibrew
        by pibrew
         
        Started by rbeckmann05, Yesterday, 06:48 PM
        1 response
        14 views
        0 likes
        Last Post bltdavid  
        Started by llanqui, Today, 03:53 AM
        0 responses
        6 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        11 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        16 views
        0 likes
        Last Post AaronKoRn  
        Working...
        X