Skip to content
Algo Trade Analytics Docs

strategy.risk.max_intraday_loss() - Pine Script Function

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).

strategy.risk.max_intraday_loss(value, type, alert_message) → void
NameTypeDescription
valuesimple int/floatA required parameter. The maximum loss value. It is specified either in money (base currency)
orin percentage of maximum intraday equity. For % of equity the range of allowed values is from 0 to 100.
// Sets the maximum intraday loss using the strategy's cash value.//@version=6
strategy("strategy.risk.max_intraday_loss Example 2", overlay = false)// Input
for 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 == 0
strategy.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 change
for the current period.priceChg = (close - beginPrice)
hline(absCashLoss)
plot(priceChg)