The worst unrealised loss a closed trade suffered while it was open, in the account currency.
strategy.closedtrades.max_drawdown(trade_num) is the lowest point the trade's profit reached between entry and exit, measured against the entry price and using each bar's high and low rather than only closes.
It shows how much heat you took on a trade, including trades that finished in profit, and is the figure to check when you size stops.
Syntax
strategy.closedtrades.max_drawdown(trade_num: series int) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| trade_num | series int | required | Zero-based index of the closed trade. 0 is the first trade the strategy closed and strategy.closedtrades - 1 is the most recent. |
Returns
series float: The deepest unrealised loss the trade showed while open, in the account currency. na when the trade does not exist.
Remarks
- Returns na when trade_num is negative, is not below
strategy.closedtrades, or points at a trade that has dropped out of the history (seestrategy.closedtrades.first_index). - Wrap the value in
math.abswhen you compare or add these numbers, so the result does not depend on whether you read the drawdown as a loss amount or a signed value.
Example
//@version=6
strategy("Worst heat", overlay = false)
fast = ta.sma(close, 10)
slow = ta.sma(close, 30)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
strategy.close("Long")
worst = 0.0
for i = strategy.closedtrades.first_index to strategy.closedtrades - 1
worst := math.max(worst, math.abs(strategy.closedtrades.max_drawdown(i)))
plot(worst, "Largest trade drawdown", color.red)See also
strategy.closedtrades.max_drawdown_percentstrategy.closedtrades.max_runupstrategy.closedtrades.profitstrategy.max_drawdown
Runs on Sidechair