samedi 31 juillet 2021

If is not workin (beginner

I found out a lot, but this one kills my sleep.

I want to plot a sma only when ShowSMA is true. It plots fine but when I add (if ShowSMA) gives me an error. I think I tried all. Now its 3:30 and I have to give up. What's wrong there?

ShowSMA = input(title="Show SMA", type=input.bool, defval=1)

sma = sma(smaSource, smaLength)

// Plot SMA 200 if ShowSMA = 1

if ShowSMA

plot ( sma, color=close[1] > sma and close > sma ? color.green : color.red, linewidth=2 )

Aucun commentaire:

Enregistrer un commentaire