I struggle to code an if statement in Pine. The idea is that the stop-loss is tightened when a waring signal is triggered. This tighter stop should replace the regular stop-loss and trailing-stop. I hoped is was a simple syntax error, but I can't seem to fix it by editing indents and spaces. Is there something more fundamental I'm overlooking?
Thanks for taking the time to read this!
longLossPerc = input(title="Long Stop Loss (%)", minval=0.0, step=0.1, defval=3.4) * 0.01
longTrailPerc = input(title="Long Trail Loss (%)", minval=0.0, step=0.1, defval=2.5) * 0.01
longTightStopPerc = input(title="Long K Loss (%)", minval=0.0, step=0.1, defval=0.6) * 0.01
longStopPrice = strategy.position_avg_price * (1 - longLossPerc)
longTrailPrice = strategy.position_avg_price * (1 - longTrailPerc)
longTightStop = high * (1 - longTightStopPerc)
stopValueLong = 0.0
if (Signal)
stopValueLong = longTightStop
else
stopValueLong = max(longStopPrice, longTailPrice)
else
0
Aucun commentaire:
Enregistrer un commentaire