dimanche 8 novembre 2020

If statement and value of an input variable - Pine Script - Tradingview

I'm having issue with using the value of a variable used as input value, in a if statement Here's a piece of my code :

//@version=3
study(title="v5.0", shorttitle="v5.0", overlay=true)
PP_display = input(1, minval=0, maxval=1)
if (PP_display = 1)
    xHigh  = security(ticker,"D", high[0])
    xLow   = security(ticker,"D", low[0])
    xClose = security(ticker,"D", close[0])
    vPP = (xHigh+xLow+xClose) / 3
    vR1 = vPP+(vPP-xLow)
    vS1 = vPP-(xHigh - vPP)
    vR2 = vPP + (xHigh - xLow)
    vS2 = vPP - (xHigh - xLow)
    vR3 = xHigh + 2 * (vPP - xLow) 
    vS3 = xLow - 2 * (xHigh - vPP)
    plot(vPP, color=change(vPP) ? na : black, title="vPP", style = linebr, linewidth = width, transp=0)
end if

As a result, I'm getting this error : "syntax error at input 'PP_display'".

I can't find why...

Thanks for your help

Aucun commentaire:

Enregistrer un commentaire