Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Does anyone have an example of a QlikView expressio to calculate an "x" period exponential moving average (EMA)? I know how to do a simple (rolling) average using RangeAvg() and Above(), but an EMA is more complex, because it uses the prior record's EMA.
"x" can be any number you'd like (e.g. 50, 200, etc.)
Thanks.
EMA is a recursive calculation. That can't be done in an expression afaik since an expression can't reference itself. You can calculate it in the script using the peek function. But that's not very dynamic since you can't vary x. Maybe you can use R.
edit: fixed some typos, i.e can to can't
You're saying that it "can" reference itself? Do you have an example of this?
I know this thread is a bit old but for the sake of posterity I'd thought I'd point out that a chart expression CAN reference itself. For example, I've had a quick go at doing an exponential moving average with a period of 9 and a weighting of 0.2 where the expression has the Label "EMA9":
if(RowNo() = 1, Data, (Data - Above(EMA9)) * .2 + Above(EMA9))
Technically I guess I shouldn't be starting the EMA from row 1 the way I have, but I hope it gives you the idea.
Cheers,
Rod
Rod, That turns out to be exactly what I did. I simply named the column and then referred to the column by name in the row above. I just never got to post the result.