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

Passing DataSeries as Input to an Indicator

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

    Passing DataSeries as Input to an Indicator

    I have a question regarding the correct implementation of passing internal Series<double> values to an indicator.

    This is what I want to do:

    (a) use a Series<double> to store values calculated in OnBarUpdate()
    (b) apply an indicator - for example the EMA or SMA - to that data series
    (c) pass the result to an IDataSeries object

    Please find attached a simple indicator which seems to work. But is it correctly coded? Would you be so kind and look at lines 52 - 58, where SMA and EMA are applied to the private Series<double> "trueRange", the result then being passed to an ISeries<double>?

    Code:
     trueRange =  new Series<double>(this, period < 125 ? MaximumBarsLookBack.TwoHundredFiftySix : MaximumBarsLookBack.Infinite);
    if(calcMode    == thisATRCalcMode.Arithmetic)
        averageTrueRange = SMA(trueRange, period);
    else if(calcMode == thisATRCalcMode.Exponential)
        averageTrueRange = EMA(trueRange, period);
    else
        averageTrueRange = EMA(trueRange, 2*period - 1);
    Thank you for your help.
    Attached Files

    #2
    Hello Harry,

    The issue comes down to the series not being ready when the indicator is initalized causing an 'A hosted indicator tried to load additional data' error.

    I'm not thinking an ISeries should be used as this is for the system data series vs a custom data series.

    I will do some testing with this and ask some questions and I will let you know what I find.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      I have deleted my last post, because further tests have not shown any problems with the code. I think it is probably working the way it is coded. Please let me know your opinion.
      Last edited by Harry; 01-22-2018, 11:13 AM.

      Comment


        #4
        Hello Harry,

        Thank you for your patience.

        You are using the ISeries in the proper context.

        Please let me know if you have any questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        4 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        20 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Working...
        X