Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Embedding calculated data in indicator

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

    Embedding calculated data in indicator

    Hi guys

    I'm working on an indicator, and I'm having the following problem:

    I've got successful code (using a 'while loop') which compiles OK. I've defined this data by

    Code:
    double x = [I](calculations)[/I] ;
    This is the crunch: I'd like to embed x within an EMA, but

    Code:
    double y =     EMA(x,14)[0];
    doesn't work. Errors show 'overload method match' and converting from 'double' to data series.

    I'd greatly appreciate any guidance as to how to get this work, so I can somehow end up with an EMA of x.

    Many thanks in advance.

    #2
    Hello arbuthnot,

    I believe the issue is that the variable "x" is a double type object. EMA has two different overloads:

    1. EMA(int period)
    2. EMA(IDataSeries input, int period)

    The one you are using is the 2nd one with a Data Series being required to first parameter.

    If you would like to use the 14 period EMA of the data series your indicator is currently set to you may do something like the following:

    Code:
    double y = EMA(14)[0];
    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks very much, JC, for pointing me towards the concept of 'dataseries'. I looked this up in Help and found an indicator which had implemented this function.

      A few minutes later, all was working great and it's now on a chart.

      For those reading this thread with the same problems, this is how I achieved this myself:

      Code:
      Variables
      
      private DataSeries    zseries; // "zseries" is my own name: could be anything.
      ...
      
      protected override void Initialize()
      
          zseries    = new DataSeries(this);
      
      ...
      
      protected override void OnBarUpdate()
      
      [I](my calculations for z)[/I]
      
      zseries.Set(z);
                  
      double zz = EMA(zseries, 14)[0];
                  
      Plot0.Set(zz);
      Now I know about data series, it can help me branch out into new coding directions.

      Much obliged, JC.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      579 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 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
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X