Limits how many orders may fill in one trading day, then stops trading until the next day.
strategy.risk.max_intraday_filled_orders(count) counts orders that fill during the day, entries and exits alike. When the count is reached, the emulator cancels pending orders, closes open positions and places no new orders until the next trading day.
It guards against a script that flips in and out many times in choppy conditions, and against runaway order loops.
Syntax
strategy.risk.max_intraday_filled_orders(count: simple int, alert_message: simple string (optional)) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| count | simple int | required | The most orders allowed to fill in one trading day. |
| alert_message | simple string | na | Text sent with the alert when the rule stops the strategy. With na, the alert carries the default message. |
Returns
Nothing. The rule stays in force for the whole run.
Remarks
- Both sides of a round trip count, so a limit of 10 allows five complete trades.
- Call it once, at the top level of the script. It needs an intraday chart.
Example
//@version=6
strategy("Fill cap", overlay = true)
strategy.risk.max_intraday_filled_orders(10)
fast = ta.sma(close, 10)
slow = ta.sma(close, 30)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
strategy.close("Long")
plot(ta.sma(close, 30), "SMA 30", color.orange)See also
Runs on Sidechair