Loss guards and limits
What stops a strategy, and for how long.
max_daily_loss: at each bar close, the day's closed profit plus open profit is compared with the limit. When it is reached, all trades close and pending orders are cancelled at the next bar's open, and new entries are rejected until the next UTC day.max_drawdownworks the same way against the highest equity reached, and pauses the deployment until you resume it.max_open,max_open_per_side,pyramiding,max_total_riskandmin_distancereject an entry, with a reason, at the moment it would fill.
The rule is E20. You can also write your own guard as an ordinary rule:
when history.today.pnl < -(2% of account.balance) or account.margin_level < 150%: close_all