Need help in converting script

#1
I did not found Relative Volatility Index(RVI) indicator in Amibroker. So I decided to covert the same from tradingview pinescript to afl.
After conversion RVI graph is not generating properly. I am new in AFL, can someone please tell me where did I went wrong?

Tradingview RVI code (pinescript) -
Code:
study(title="Relative Volatility Index", shorttitle="RVI")
length = input(10, minval=1), src = close
len = 14
stddev = stdev(src, length)
upper = ema(change(src) <= 0 ? 0 : stddev, len)
lower = ema(change(src) > 0 ? 0 : stddev, len)
rvi = upper / (upper + lower) * 100
h0 = hline(80)
h1 = hline(20)
fill(h0, h1, color=olive)
plot(rvi, title="RVI")
converted RVI code (afl) -
Code:
P = ParamField("Price",3);
N  = Param("Period",10,1,100,1);
STD = StDev(P, N);
u = IIf(P <= Ref(P, -1), 0, STD);
d = IIf(P > Ref(P, -1), 0, STD);
Usum = EMA(u, N);
Dsum = EMA(d, N);
RVI = Usum / (Usum + Dsum) * 100;
Plot( RVI, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
 
#2
Moderator, please close this thread.

I did some troubleshooting and it seems code is proper. It is not giving proper output because of insufficient historical data.

Sorry for the trouble.
 

Similar threads