Reputation: 3
//@version=2
study(title="Volume Based Buy and Sell Momentum by 2tm", shorttitle="VBSM")
EMA_Len = input(25, title="Lenth", minval=1) xROC = roc(close, 1)
nRes1 = iff(volume < volume[1], nz(nRes1[1], 0) + xROC, nz(nRes1[1], 0))
nRes2 = iff(volume > volume[1], nz(nRes2[1], 0) + xROC, nz(nRes2[1], 0)) nRes3 = nRes1 + nRes2
nResEMA3 = sma(nRes1, EMA_Len) + sma(nRes2, EMA_Len)
PNVI = plot(nRes3, color=blue, title="PVI + NVI") PEMA = plot(nResEMA3, color=red, title="EMA")
pCol = nRes3 > nResEMA3 ? blue : red
fill (PNVI, PEMA, pCol)
Upvotes: 0
Views: 588
Reputation: 31
First you convert from //@version=2 to //@version=3
Then from //@version=3 to //@version=5 will be done automatically
Upvotes: 0
Reputation: 1368
You will have to use prefix ta before time series related functions like roc and sma. You will have to use suffix like int after input. You have to use prefix like color before colors like red and blue.
//@version=5
indicator(title="Volume Based Buy and Sell Momentum by 2tm", shorttitle="VBSM")
EMA_Len = input.int(25, title="Lenth", minval=1)
xROC = ta.roc(close, 1)
var nRes1=0.0
nRes1 := volume < volume[1]? nz(nRes1[1], 0) + xROC: nz(nRes1[1], 0)
var nRes2=0.0
nRes2 := volume > volume[1]? nz(nRes2[1], 0) + xROC: nz(nRes2[1], 0)
nRes3 = nRes1 + nRes2
nResEMA3 = ta.sma(nRes1, EMA_Len) + ta.sma(nRes2, EMA_Len)
PNVI = plot(nRes3, color=color.blue, title="PVI + NVI")
PEMA = plot(nResEMA3, color=color.red, title="EMA")
pCol = nRes3 > nResEMA3 ? color.blue : color.red
fill (PNVI, PEMA, pCol)
Upvotes: 1