Count the trades that filled since the futures day's first bar and take a new entry only while the count is under your limit.
The script below does it. TradingView's strategy.risk.max_intraday_filled_orders counts orders and not trades: an entry and its exit are two. Set to 1 it closed all 500 trades of our test on the bar they filled. Set it to twice the trades you want when each trade is one entry and one exit.
On this MNQ breakout more trades a day made more. Over two years it made $1,222 at one trade a day, $5,519.50 at two and $7,723 at three. The 120 second trades made $4,297.50 and the 14 third trades $2,203.50. All three lost money from 24 February 2026. Three a day lost the least: $2,876.
The code in three parts
1. Count what filled
strategy.closedtrades + strategy.opentrades is every trade that filled. A count of orders sent would also count a limit entry that never filled.
2. Start each day at zero
Save that number on the futures day's first bar: the 18:00 New York reopen that session.isfirstbar marks. Today's trades are the number now minus the one you saved.
3. Gate the entries
A new entry only while today's trades are under your limit. Put dayOpen in front of each entry's condition.
The limit on its own · 10 lines
// ── Trades per day ───────────────────────────────────────────────────────────────────────────────
maxDay = input.int(3, "Trades per day", minval=1, group="Trades per day")
// Count the trades that filled, not the orders sent: a limit entry that never fills is not a trade.
// The count starts again on the futures day's first bar, the 18:00 New York reopen
var int dayStartTrades = 0
if session.isfirstbar
dayStartTrades := strategy.closedtrades + strategy.opentrades
tradesToday = strategy.closedtrades + strategy.opentrades - dayStartTrades
dayOpen = tradesToday < maxDay
Paste it under your strategy() line and put dayOpen in front of each entry's condition. The full script below does the same.
What the built-in counts
strategy.risk.max_intraday_filled_orders counts every filled order: each entry and each exit. When the day reaches the number it closes the open trade and takes no new order until the next session. Here it is on the same breakout with no other limit, set the way code that reads it as trades sets it:
| SET TO | WHAT IT DID | TRADES | 2 YEARS |
|---|---|---|---|
| max_intraday_filled_orders(1) | Closed all 500 trades on the bar they filled | 500 | −$2,500 |
| max_intraday_filled_orders(2) | One trade a day: the same trades as the counter at 1 | 500 | +$1,222 |
| max_intraday_filled_orders(3) | Let each day's first trade run and closed 120 second trades on the bar they filled | 620 | +$622 |
Each trade the rule closed on the bar it filled cost $5 of commission in our tester. One MNQ contract on a $50,000 account pays $2.50 a contract each side and a tick of slippage.
1, 2 and 3 trades a day
| TRADES PER DAY | TRADES | WON | 2 YEARS | 4 NOV 2024 → 23 FEB 2026 | 24 FEB 2026 → 22 OCT 2026 | WORST DRAWDOWN |
|---|---|---|---|---|---|---|
| 1 trade a day | 500 | 45.2% | +$1,222 | +$8,850 | −$7,628 | −$10,373.50 |
| 2 trades a day | 620 | 45.5% | +$5,519.50 | +$9,931 | −$4,411.50 | −$9,619 |
| 3 trades a day | 634 | 45.7% | +$7,723 | +$10,599 | −$2,876 | −$7,969 |
One MNQ contract on a $50,000 account pays $2.50 a contract each side and a tick of slippage. The 6 runs were fixed before they ran. The worst drawdown is the deepest fall from a high between 4 November 2024 and 22 October 2026.
A second trade comes only after the first one closed and the price crossed back through the range. It happened on 120 of the 500 days and a third on 14. One trade a day gives the same trades as the breakout of our VWAP filter test with the filter off. Three a day is the no-target run of our daily profit target page on one contract.
The script as it ran
MNQ opening range breakout with three trades a day
A 15-minute opening range from 9:30 New York. A close through it after a close inside it enters from 9:45 to 12:00 when no trade is open. The stop sits at the range's other side and the target at 2R. The day takes up to 3 trades: the script counts the trades that filled since the futures day's first bar. Its input sets the number.
- Trades: 634
- Won: 45.7%
- Profit factor: 1.10
- Net: +15.4%
- Worst drawdown: −12.5%
- Worst trade: −$749
MNQ1! · 5-minute · 4 Nov 2024 → 22 Oct 2026 · $2.50 a contract each side and a tick of slippage · one contract on a $50,000 account
+$10,599 from 4 November 2024 to 23 February 2026, −$2,876 from 24 February 2026 to 22 October 2026.
Pine Script v6 · 60 lines
//@version=6
// Suggested timeframe: 5-minute
strategy("MNQ opening range breakout with a limit on trades per day", overlay=true, initial_capital=50000, default_qty_type=strategy.fixed, default_qty_value=1,
commission_type=strategy.commission.cash_per_contract, commission_value=2.5, slippage=1, margin_long=0, margin_short=0)
// ── Trades per day ───────────────────────────────────────────────────────────────────────────────
maxDay = input.int(3, "Trades per day", minval=1, group="Trades per day")
// Count the trades that filled, not the orders sent: a limit entry that never fills is not a trade.
// The count starts again on the futures day's first bar, the 18:00 New York reopen
var int dayStartTrades = 0
if session.isfirstbar
dayStartTrades := strategy.closedtrades + strategy.opentrades
tradesToday = strategy.closedtrades + strategy.opentrades - dayStartTrades
dayOpen = tradesToday < maxDay
// ── The example strategy: a 15-minute opening range breakout ────────────────────────────────────
// Your own entries go here, behind "dayOpen"
orSess = input.session("0930-0945", "Opening range (New York)", group="Strategy")
tradeSess = input.session("0945-1200", "Entry window (New York)", group="Strategy")
rMult = input.float(2.0, "Target (R)", minval=0.5, step=0.5, group="Strategy")
inOR = not na(time(timeframe.period, orSess, "America/New_York"))
inTrade = not na(time(timeframe.period, tradeSess, "America/New_York"))
var float orHigh = na
var float orLow = na
var float stopLevel = na
var float targetLevel = na
if session.isfirstbar
orHigh := na
orLow := na
if inOR
orHigh := na(orHigh) ? high : math.max(orHigh, high)
orLow := na(orLow) ? low : math.min(orLow, low)
// The setup: a close through the range after a close inside it. The stop sits at the range's
// other side and the target at rMult times the risk. A new trade waits until the last one closed
rangeSet = not inOR and not na(orHigh)
longSetup = rangeSet and close > orHigh and close[1] <= orHigh
shortSetup = rangeSet and close < orLow and close[1] >= orLow
canTrade = inTrade and strategy.position_size == 0 and dayOpen and not session.islastbar
if canTrade and longSetup and orLow < close
stopLevel := orLow
targetLevel := close + (close - orLow) * rMult
strategy.entry("Long", strategy.long)
strategy.exit("Long exit", from_entry="Long", stop=stopLevel, limit=targetLevel)
else if canTrade and shortSetup and orHigh > close
stopLevel := orHigh
targetLevel := close - (orHigh - close) * rMult
strategy.entry("Short", strategy.short)
strategy.exit("Short exit", from_entry="Short", stop=stopLevel, limit=targetLevel)
if session.islastbar
strategy.close_all("Session end", immediately=true)
// The count, in the Data Window
plot(tradesToday, "Trades today", display=display.data_window)
plot(rangeSet ? orHigh : na, "Range high", color=color.new(#16A56A, 0), style=plot.style_linebr)
plot(rangeSet ? orLow : na, "Range low", color=color.new(#E5484D, 0), style=plot.style_linebr)
A daily loss limit that holds is on our daily loss limit page.
Questions
How do I limit trades per day in Pine Script?
Count the trades that filled since the futures day's first bar and take a new entry only while the count is under your limit. strategy.closedtrades plus strategy.opentrades is every trade that filled. Save it on the bar that session.isfirstbar marks: the 18:00 New York reopen on CME futures. Today's trades are the number now minus that. The script on this page does it in a block that goes on top of your own strategy.
Does strategy.risk.max_intraday_filled_orders limit trades?
It limits filled orders. An entry and its exit are two. Set to 2 it allows one trade a day. Set to the number of trades you want it closes the last trade on the bar it fills: in our test it closed all 500 trades at 1 and 120 second trades at 3.
Should I count the orders I send or the trades that filled?
The trades that filled. A limit entry that never fills is not a trade. A count of orders sent would spend the day's limit on it.
When does the count start again?
At the futures day's first bar. CME's futures session opens at 18:00 New York and session.isfirstbar marks it. A count reset by dayofmonth turns at midnight and would put the evening's trades on the day before.
Do more trades a day make more money?
On this breakout they did. Over two years it made $1,222 at one trade a day, $5,519.50 at two and $7,723 at three. From 24 February 2026 all three lost money and three a day lost the least. Test your own strategy before you trade it.
Can I run it myself?
Yes. Run opens the script on MNQ 5-minute bars in the Alpha Charts terminal. On a computer, a free account with no card runs it as published on all two years. Its input sets the trades per day. A changed input or line makes it your own script: a free account then tests the newest 30 days of a chart under an hour. Prop Ready ($39 paid once) opens all two years for 30 days.
Is a backtest a prediction?
No. It is what a strategy's rules would have done on past prices with costs charged. Live fills, news and your own execution differ. Read it as a test of the rules and not as a forecast.
Every number comes from Alpha Charts' tester on MNQ 5-minute bars from 4 November 2024 to 22 October 2026. The runs were made on 27 November 2026. Alpha Charts is software for testing trading scripts and gives no investment advice. A backtest shows what rules would have done on past data. It does not show what they will do. Our methodology is in Data and methodology. Updated 27 November 2026.
Originally published at getalphacharts.com.
Top comments (0)