strategy.risk.max_intraday_loss() - Pine Script Function
strategy.risk.max_intraday_loss()
Section titled “strategy.risk.max_intraday_loss()”Overview
Section titled “Overview”The maximum loss value allowed during a day. It is specified either in money (base currency), or in percentage of maximum intraday equity (0 -100).
Syntax
Section titled “Syntax”strategy.risk.max_intraday_loss(value, type, alert_message) → voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| value | simple int/float | A required parameter. The maximum loss value. It is specified either in money (base currency) |
| or | — | in percentage of maximum intraday equity. For % of equity the range of allowed values is from 0 to 100. |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”// Sets the maximum intraday loss using the strategy's cash value.//@version=6strategy("strategy.risk.max_intraday_loss Example 2", overlay = false)// Inputfor maximum intraday loss in absolute cash value of the symbol.absCashLoss =input.float(5)// Set maximum intraday loss to `absCashLoss` in account currency.strategy.risk.max_intraday_loss(absCashLoss, strategy.cash)// Enter Short at bar_index zero.if bar_index == 0strategy.entry("Short", strategy.short)// Store the open price value from the beginning of the day.beginPrice = ta.valuewhen(ta.change(dayofweek) > 0, open, 0)// Calculate the absolute price changefor the current period.priceChg = (close - beginPrice)hline(absCashLoss)plot(priceChg)