crossed_sl = false if is_long() and use_sl crossed_sl := close <= sl_price crossed_sl if is_short() and use_sl crossed_sl := close >= sl_price crossed_sl
terminate_operation = window() and has_open_trade() and crossed_sl
if terminate_operation and not(long_signalA or short_signalA) // Do not close position if trend is flipping anyways. entry_price := 0.0 updated_entry_price := entry_price sl_price := 0.0 strategy_close()
start_operation = window() and (long_signalA or short_signalA)
if start_operation entry_price := close updated_entry_price := entry_price sl_price := entry_price + entry_price * sl_pct / 100 if long_signalA strategy_long() if short_signalA strategy_short()
crossed_slB = false if is_long() and use_sl crossed_sl := close <= sl_price crossed_sl if is_short() and use_sl crossed_sl := close >= sl_price crossed_sl
terminate_operationB = window() and has_open_trade() and crossed_sl
if terminate_operation and not(long_signal or short_signal) // Do not close position if trend is flipping anyways. entry_price := 0.0 updated_entry_price := entry_price sl_price := 0.0 strategy_close()
start_operationB = window() and (long_signal or short_signal)
if start_operation entry_price := close updated_entry_price := entry_price sl_price := entry_price + entry_price * sl_pct / 100 if long_signal strategy_long() if short_signal strategy_short()