strategy.risk.max_cons_loss_days() - Pine Script Function
strategy.risk.max_cons_loss_days()
Section titled “strategy.risk.max_cons_loss_days()”Overview
Section titled “Overview”The purpose of this rule is to cancel all pending orders, close all open positions and stop placing orders after a specified number of consecutive days with losses. The rule affects the whole strategy.
Syntax
Section titled “Syntax”strategy.risk.max_cons_loss_days(count, alert_message) → voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| count | simple int | A required parameter. The allowed number of consecutive days with losses. |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6strategy("risk.max_cons_loss_days Demo 1")strategy.risk.max_cons_loss_days(3) // No orders will be placed after 3 days,if each day is with loss.plot(strategy.position_size)