fix: Properly declare and initialize trail_price with correct reassignment
This commit is contained in:
parent
9cd98202c7
commit
1fe27d41da
@ -24,6 +24,7 @@ var float entry_price = na
|
|||||||
var float target_1 = na
|
var float target_1 = na
|
||||||
var float target_2 = na
|
var float target_2 = na
|
||||||
var float trail_stop = na
|
var float trail_stop = na
|
||||||
|
var float trail_price = na
|
||||||
var bool trail_active = false
|
var bool trail_active = false
|
||||||
|
|
||||||
if bullish_entry
|
if bullish_entry
|
||||||
@ -38,7 +39,9 @@ profit_target_reached = close >= target_2
|
|||||||
|
|
||||||
// Trailing stop logic (activated by upper band touch)
|
// Trailing stop logic (activated by upper band touch)
|
||||||
trail_active := trail_active or trail_activation
|
trail_active := trail_active or trail_activation
|
||||||
trail_price = math.max(high, nz(trail_price[1], high))
|
if trail_active and na(trail_price)
|
||||||
|
trail_price := high
|
||||||
|
trail_price := math.max(high, nz(trail_price[1], high))
|
||||||
trail_stop := trail_price * (1 - trail_percent/100)
|
trail_stop := trail_price * (1 - trail_percent/100)
|
||||||
|
|
||||||
// Exit strategy
|
// Exit strategy
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user