The largest peak-to-trough fall in equity so far, in the account currency.
strategy.max_drawdown is a series float: the biggest drop from an equity high to the following low since the first bar, in money. It only grows. A strategy that has never fallen below a previous equity high reads 0.
Type
series float
Remarks
- The drawdown is measured on equity, so open losses count before the trade closes.
- The sign is positive for a drop; compare absolute values when you test thresholds.
Example
//@version=6
strategy("Drawdown halt", overlay = true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
halted = strategy.max_drawdown > strategy.initial_capital * 0.2
if ta.crossover(ta.sma(close, 10), ta.sma(close, 30)) and not halted
strategy.entry("Long", strategy.long)
if ta.crossunder(ta.sma(close, 10), ta.sma(close, 30)) or halted
strategy.close_all()
plot(strategy.max_drawdown, "Max drawdown", color.red)See also
strategy.max_drawdown_percentstrategy.max_runupstrategy.equitystrategy.risk.max_drawdownstrategy.netprofit
Runs on Sidechair