fix: Declare stop_price and use reassignment operator in strategy
This commit is contained in:
parent
e0ad1ac620
commit
485ba4418c
@ -18,6 +18,7 @@ bullish_entry = (close < ema) and
|
|||||||
(close > close[1])
|
(close > close[1])
|
||||||
|
|
||||||
// Trailing Stop Logic
|
// Trailing Stop Logic
|
||||||
|
var float stop_price = na
|
||||||
var float trail_price = na
|
var float trail_price = na
|
||||||
var bool trail_active = false
|
var bool trail_active = false
|
||||||
|
|
||||||
@ -35,8 +36,8 @@ if strategy.position_size > 0
|
|||||||
if trail_active
|
if trail_active
|
||||||
trail_price := math.max(high, nz(trail_price, high))
|
trail_price := math.max(high, nz(trail_price, high))
|
||||||
|
|
||||||
// Calculate stop price
|
// Calculate stop price (now using declared variable)
|
||||||
stop_price = trail_active ? trail_price * (1 - trail_percent/100) : na
|
stop_price := trail_active ? trail_price * (1 - trail_percent/100) : na
|
||||||
|
|
||||||
// Submit exit order
|
// Submit exit order
|
||||||
if trail_active
|
if trail_active
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user