How to compute Moving Average on another indicator

Joined
Oct 15, 2020
Posts
10
Likes
2
I'd like to compute an ema on atr.

I see from looking at other studies that atr values are gotten like this:
Code:
    DataSeries series=ctx.getDataSeries();
    double atr=series.atr(index, atrPeriod);
In LBRPaintBar.java I see an MA computed like this:
Code:
    series.setDouble(index, Values.ATR, atr);
    ...
    double aatr=factor * series.ma(method, index, atrPeriod, Values.ATR);
So, if I'm understanding this correctly, it's 1st necessary to create a new dataseries dataset by inserting ATR values into dataseries (here using key Values.ATR), and then apply the ema to that dataset, by referencing the same key?

Or, is there an easier way to accomplish it
 

Spin

Well-known member
Joined
May 22, 2019
Posts
138
Likes
18
I would do it as you suggest above:

calculate ATR
Put ATR inside a Value
calculate MA using the Value
 
Joined
Oct 15, 2020
Posts
10
Likes
2
I would do it as you suggest above:

calculate ATR
Put ATR inside a Value
calculate MA using the Value
Thanks, got it working.

Coming from Ninjascript where it's all done in one step at study configuration, like so:

C#:
EMA emaOnATR = EMA(30, ATR(14));
 
Top