diff --git a/pinescripts/Three_ATR_EMA.pine b/pinescripts/Three_ATR_EMA.pine index 46686be..65976cf 100644 --- a/pinescripts/Three_ATR_EMA.pine +++ b/pinescripts/Three_ATR_EMA.pine @@ -18,6 +18,7 @@ bullish_entry = (close < ema) and (close > close[1]) // Trailing Stop Logic +var float stop_price = na var float trail_price = na var bool trail_active = false @@ -35,8 +36,8 @@ if strategy.position_size > 0 if trail_active trail_price := math.max(high, nz(trail_price, high)) - // Calculate stop price - stop_price = trail_active ? trail_price * (1 - trail_percent/100) : na + // Calculate stop price (now using declared variable) + stop_price := trail_active ? trail_price * (1 - trail_percent/100) : na // Submit exit order if trail_active