Reputation: 17
I found this code for ema. It doesn't work in v5 anymore. I know that ema is in the pinescript library. It is only an example for calculating over an interval.
I tried this code:
*calcEma(oVector, period) =>
var float volatility = 0.0
var float sum = 0.0
for i = 0 to period - 1
sum += oVector[i] / period
sum
*
I expecting the ema, but only get an constant value.
Must I write out the outer loop. If yes, how must I code it?
Upvotes: 0
Views: 89
Reputation: 17
The var keyword must be deleted in the definition of sum. It also must be tied to float. Variant definition also doesn't work.
Upvotes: 0