Skip to content
Algo Trade Analytics Docs

strategy.risk.max_drawdown() - Pine Script Function

The purpose of this rule is to determine maximum drawdown. The rule affects the whole strategy. Once the maximum drawdown value is reached, all pending orders are cancelled, all open positions are closed and no new orders can be placed.

strategy.risk.max_drawdown(value, type, alert_message) → void
NameTypeDescription
valuesimple int/floatA required parameter. The maximum drawdown value. It is specified either in money (base currency)
orin percentage of maximum equity. For % of equity the range of allowed values is from 0 to 100.
//@version=6
strategy("risk.max_drawdown Demo 2", currency = "EUR")
strategy.risk.max_drawdown(2000, strategy.cash) // set maximum drawdown to 2000 EUR from maximum equity
plot(strategy.position_size)