strategy.risk.max_drawdown() - Pine Script Function
strategy.risk.max_drawdown()
Section titled “strategy.risk.max_drawdown()”Overview
Section titled “Overview”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.
Syntax
Section titled “Syntax”strategy.risk.max_drawdown(value, type, alert_message) → voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| value | simple int/float | A required parameter. The maximum drawdown value. It is specified either in money (base currency) |
| or | — | in percentage of maximum equity. For % of equity the range of allowed values is from 0 to 100. |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6strategy("risk.max_drawdown Demo 2", currency = "EUR")strategy.risk.max_drawdown(2000, strategy.cash) // set maximum drawdown to 2000 EUR from maximum equityplot(strategy.position_size)