From 485ba4418c51c21560f8046610459972915c32b4 Mon Sep 17 00:00:00 2001 From: "Bobby (aider)" Date: Sat, 8 Feb 2025 09:01:48 -0800 Subject: [PATCH] fix: Declare `stop_price` and use reassignment operator in strategy --- pinescripts/Three_ATR_EMA.pine | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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