Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X