fix: Declare stop_price and use reassignment operator in strategy

This commit is contained in:
Bobby (aider) 2025-02-08 09:01:48 -08:00
parent e0ad1ac620
commit 485ba4418c

View File

@ -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