fix: Properly declare and initialize trail_price with correct reassignment

This commit is contained in:
Bobby (aider) 2025-02-08 09:37:41 -08:00
parent 9cd98202c7
commit 1fe27d41da

View File

@ -24,6 +24,7 @@ var float entry_price = na
var float target_1 = na
var float target_2 = na
var float trail_stop = na
var float trail_price = na
var bool trail_active = false
if bullish_entry
@ -38,7 +39,9 @@ profit_target_reached = close >= target_2
// Trailing stop logic (activated by upper band touch)
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)
// Exit strategy