VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Markets and trading sessions

Day trading vs swing trading backtest: what changes and why

A day version and a swing version of the same rule are two strategies. They need different session settings, gap handling, margin assumptions and produce very different trade counts, so test each on its own and compare them per trade after costs against a rule written before the test.

By · Published · updated · Editorial policy

Contents
  1. What changes in a backtest when a strategy closes every day instead of holding overnight?
  2. How do you model the session-end exit in a day trading backtest?
  3. Do swing backtests need to account for overnight gaps and the night session?
  4. How do margin and holding costs differ between the two versions?
  5. Why does a day trading strategy produce more trades, and does that make the result more reliable?
  6. Day version or swing version of one breakout rule: which should you keep?
  7. Frequently asked questions
  8. References

What changes in a backtest when a strategy closes every day instead of holding overnight?

A day trading vs swing trading backtest differs in five settings: the exit rule, the bars you load, how stops fill across gaps, the margin behind each contract, and the number of trades. Treat the two as separate strategies, test each with its own settings, and compare them per trade after costs.

Day trading (當沖 in Chinese) is a style where every position is closed before the session ends, so no contract is held through the overnight break. Swing trading is a style where a position stays open for days or weeks and is closed by the rule itself, not by the clock. The same entry signal can feed both styles, but the moment you decide whether the trade may live past the close, almost everything downstream in the backtest changes. A trader who flips a "close at end of day" switch and calls the result "the swing version" has tested one strategy and misread it as another.

Setup choiceDay versionSwing version
Exit ruleForced exit before the session close, plus the strategy's own exitsRule-based exit only, which may come days later
Data loadedDay-session intraday barsFull-session intraday bars or daily bars
Gap handlingNo gaps inside a session; a stop fills near its levelA stop can fill far past its level at the next open
Margin assumedBroker intraday marginExchange initial margin for every night held
Trades per yearHundredsTens
Day version versus swing version of one rule across five settings: the exit comes before the close or by the rule, the data is day-session bars or full-session or daily bars, gaps are none or fill at the open, margin is intraday or initial, and trades per year are hundreds or tens Day vs swing: five changes Same entry, two strategies Day Swing Exit Before close By the rule Data Day session Full or daily Gaps None Fill at open Margin Intraday Initial Trades/yr Hundreds Tens
The two versions differ in five setup choices, not just in the exit time. Each row is a separate decision in the backtest settings.

Most of the five types of futures algo trading strategies can be built either way, and a trend-following rule in particular behaves very differently once it is cut off at the close every day. If you are still choosing your first rule, the 30-day route to a first algo trading strategy suggests picking one holding style and keeping it fixed for the whole first project, because changing it halfway restarts the research.

How do you model the session-end exit in a day trading backtest?

A day trading strategy backtest needs an explicit exit placed on the last bar the strategy can trade, filled on the bar after it, a few minutes before the session close you will actually use live. The session matters as much as the exit. A US index futures contract such as ES trades almost around the clock on weekdays with a short daily break, but many day traders only keep the cash-equity hours, 8:30 a.m. to 3:00 p.m. Central Time. If the backtest uses one session and the trader keeps another, the forced exit lands at a different price and the whole trade list changes. Exchanges can change session times, so check the exchange's contract page or the futures market hours tool, which shows each session in your own time zone.

Next-bar execution is the practice of placing an order on the bar where the signal appears and filling it at the open of the following bar, because the close of the signal bar is only known once that bar has ended. For a session-end exit this detail is easy to get wrong:

  1. Pick the exit time first. Write it as a clock time inside the session, for example 10 minutes before the close, not "the last bar".
  2. Find the last bar that opens before that time. With 5-minute bars and a 3:00 p.m. close, an exit at 2:50 p.m. means the order is placed on the bar that closes at 2:50 and fills on the bar that opens at 2:50.
  3. Confirm the fill bar is still inside the session. If the order is placed on the final bar of the day, the "next bar" is tomorrow's open, and the position was held overnight without you noticing.
  4. Charge the exit like any other trade. A market order at the end of the day pays slippage; one tick per side is a reasonable starting assumption for liquid contracts.
  5. Check that no entry fires after the exit bar. A rule that re-enters at 2:55 p.m. and exits at 3:00 is a different strategy again.
Timeline of one trading day with 5-minute bars: the forced-exit order is placed on the bar that closes at 2:50, the fill comes on the next bar before the session close, and a fill at the order bar's own close is marked as a price that was not tradable Exit on a bar you can trade Example: 5-minute bars, exit at 2:50 Order Fill Not tradable Open 2:50 Close A same-bar close is not a real fill. So: fill on the next bar, in session.
The forced exit must sit on a bar the strategy can trade, with the fill on the bar after it. A same-bar close exit uses a price the trader could not have had.

When the session, the exit time and the fill bar are fixed, the rest of the intraday work follows the steps in how to build and test a day trading algorithm. Because the forced exit sits inside the trading session you define, AlphaPrime (Valynox) backtesting charges commission and slippage on that exit and fills it on the next bar, the same as every other order in the candidate.

Do swing backtests need to account for overnight gaps and the night session?

Yes: a swing trading futures backtest must decide whether night-session bars are part of the data, and it must let a stop fill at the first available price after a gap, not at the stop level. An overnight gap is the difference between one session's last price and the next session's first price, created while the market was closed or thinly traded. A stop order placed below yesterday's close offers no protection against an open that lands below it; the fill is the open, and the extra loss belongs in the backtest.

The night-session decision comes first, because it changes what "overnight" means. TAIEX futures, for example, trade a day session from 8:45 a.m. to 1:45 p.m. and a night session from 3:00 p.m. to 5:00 a.m. the next morning, Taiwan time, according to the TAIFEX contract page (and the exchange can change these hours). A swing strategy that holds through the night faces one of two worlds:

  • Night bars included. A stop can trigger during the night at a price close to its level, but night liquidity is thinner, so slippage should be set higher than in the day session. The gap is then the one between the night close and the day open, which is usually smaller.
  • Night bars excluded, or daily bars only. The backtest sees one gap per day, from close to open, and every stop inside that gap fills at the open. This is the simpler model and the harsher one, and it is the right one if the trader does not watch or trade the night session.
Two daily bars of a long position with a stop between them: the first bar closes above the stop, the next opens below it, so the real fill is the open, not the stop price a naive backtest assumes, and the gap between them is an extra loss Gaps skip your stop Long position, illustration Extra loss Stop Assumed fill Real fill A jumped stop fills at the open. So: model gap fills in swing tests.
When the market opens beyond the stop, the realistic fill is the opening price. The shaded gap between the two arrows is a loss the naive backtest never records.

Whichever world you choose, the live account must live in the same one. A backtest on day-only bars that holds overnight, traded live with night-session stops, will show a different drawdown than the trader experiences. The trade-offs between day-only and full-session bars in futures backtests cover the data side in detail. On the rule side, make sure the backtest engine fills gap-through stops at the open; if it fills them at the stop price, the swing version's drawdown is understated, and the day version, which never faces that gap, looks worse by comparison than it should.

How do margin and holding costs differ between the two versions?

Overnight positions need the exchange's full initial margin per contract and carry gap risk through every night, while intraday positions run on the lower intraday margin a broker allows, so the account size that survives the backtest drawdown is different for each version. Initial margin is the deposit the exchange requires per contract for a position held past the session close. Intraday margin is a smaller deposit a broker may allow for positions that are flat before the close; it is the broker's choice and can be withdrawn on short notice.

ItemDay versionSwing version
Margin per contractBroker intraday margin, lowerExchange initial margin, higher, re-checked each night
Who sets itBrokerExchange, with broker add-ons
Exposure per tradeMinutes to hours, inside one sessionDays, including every night and weekend in between
Worst single lossBounded by intraday range and slippageCan exceed the stop by the size of a gap
Account size to size the backtestIntraday margin plus the day version's drawdownInitial margin plus the swing version's drawdown plus gap allowance
For one contract, relative sizes only: the day version uses lower intraday margin set by the broker and is exposed only within one session, while the swing version uses higher initial margin set by the exchange and is exposed for far more hours, including nights Overnight costs more One contract, relative sizes only Margin Hours held Broker Exchange In session Nights too Day Swing Day Swing Overnight costs margin and hours. So: size swing on initial margin.
Overnight holding needs more margin per contract and spends far more hours exposed, including the hours when gaps form. The day version never sees that second row.

The practical consequence is in position sizing. The same equity curve read against a small intraday margin suggests many contracts; read against initial margin plus a gap allowance it suggests far fewer. A swing backtest sized on intraday margin is a plan that breaks the first night it is held. How margin turns a backtest drawdown into a required account size is worked through in futures leverage and how margin changes backtest drawdown. Margin requirements are set by the exchange and the broker and change with volatility, so take the current figure from the exchange's contract page before sizing either version.

Holding costs are the second difference. A swing position in a futures contract pays no financing in the way a stock position on margin does, but it does face contract rollover: a trade held across the roll must exit the old contract and enter the new one, which is two extra executions with commission and slippage. A day version never rolls a position. Put the roll into the swing backtest as a cost, or the swing version gets a small advantage it would not have live.

Why does a day trading strategy produce more trades, and does that make the result more reliable?

A rule that must be flat by the close can only hold for hours, so it completes many more trades from the same history than a swing version that holds for days, and the larger trade count makes the average trade and the drawdown figures less uncertain. Reliability here means something narrow: how much the average trade would move if a handful of trades were different. It does not mean the strategy is better. A day version with a tiny edge per trade can be measured precisely and still lose to costs.

The swing side of this is easy to see in a real report. The run below is from AlphaPrime's engine on ES daily bars from 2019-01-02 to 2025-06-30, long and short, one contract, with commission and slippage charged on every trade. It tests a stand-in rule, built from a standard deviation condition that serves as the only entry and exit with no stop, target or filter, not the breakout rule discussed in the rest of this article. It is also the one candidate the search kept out of the 1,024 it tried, chosen for its return against its drawdown. Picking the kept one after the fact flatters it: the figures show what that single candidate did on that history, not what the rule earns or what a reader should expect.

Source: AlphaPrime product engine (CPU), run 2026-10-31. ES daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $25 slippage per trade.

NumberResult
Net profit (closed trades)$51,142.5
Max drawdown$15,520
Trades151
Win rate59.6%
Profit factor1.436
Average trade$338.69
Time in market14.83%
Look at the trade count against the length of the period. A daily-bar rule that holds overnight completes few trades in several years, so every other figure in the summary rests on a small sample.
Look at the trade count against the length of the period. A daily-bar rule that holds overnight completes few trades in several years, so every other figure in the summary rests on a small sample. ES · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

151 trades across six and a half years is a few trades a month. An intraday version of a similar idea on 5-minute bars, forced flat each day, would typically complete several trades a week on the same history. The reason the count matters is how an average behaves. The one formula worth knowing is:

uncertainty in the average trade = spread of single trades ÷ √N

Here the spread of single trades is how far individual trade results usually sit from the average (the standard deviation), N is the number of completed trades, and √N is its square root. The square root grows slowly, so four times as many trades are needed to halve the uncertainty.

Hypothetical example

Suppose single trade results typically sit $600 from the average and the average trade after costs is $90. With 150 trades the uncertainty is about $600 ÷ 12.2 ≈ $49, so the true average could plausibly be near $40 or near $140. With 600 trades it is about $600 ÷ 24.5 ≈ $24. With 2,400 trades it is about $600 ÷ 49 ≈ $12. Each fourfold step in trades halves the band around the same $90.

Hypothetical example with a 90 dollar average trade: the uncertainty band is about plus or minus 49 dollars at 150 trades, 24 dollars at four times as many trades and 12 dollars at sixteen times as many trades, because the band equals the spread of single trades divided by the square root of the trade count 4× trades, half the band Hypothetical: same $90 average trade 150 trades ±$49 4× as many ±$24 16× as many ±$12 Average $90 Band = spread ÷ √N So: 4× the trades to halve it.
The uncertainty of the average trade shrinks with the square root of the trade count: four times the trades, half the band.

Two cautions follow. First, the day version's many trades carry a cost per trade that is a much larger share of a much smaller gross move, so its precision is often precision about a number near zero. Second, the swing version's small sample is made worse when it is the best of many candidates: Bailey, Borwein, López de Prado and Zhu (2014) show that the more variants are tried, the longer the history needed before the best one can be told from luck. A swing version therefore needs either a longer history, a walk-forward design that yields more out-of-sample trades, or a stricter rule for accepting it.

Day version or swing version of one breakout rule: which should you keep?

Run the breakout rule twice, once as a day version with a session-end exit and once as a swing version that holds, then keep the version that passes a rule you wrote before the test, not the one with the larger net profit. A breakout rule is a rule that enters when price moves above the highest high (or below the lowest low) of the last N bars, on the idea that a new extreme starts a move. Both versions use the same entry; the day version adds the forced exit and the swing version adds a rule-based exit such as a close back inside the channel.

The pre-written rule should name the figures and the thresholds. A workable set for comparing the two versions:

  1. Gross average trade at least three times the round-trip cost. This protects the result against a slippage estimate that turns out optimistic.
  2. Maximum drawdown that the intended account can carry with the margin that version actually needs, intraday for the day version, initial plus gap allowance for the swing version.
  3. Enough completed trades that the uncertainty band from the previous section does not reach zero.
  4. Overnight exposure the trader is willing to hold. A trader who cannot watch the night session should treat every overnight position as a cost of sleep, not just a number.

Hypothetical example

FigureDay versionSwing version
Trades per year48040
Gross average trade$80$365
Round-trip cost$45$45
Average trade after costs$35$320
Cost as share of gross average trade56%12%
Maximum drawdown$6,000$14,000
Net profit over five years$84,000$64,000
Overnight exposureNoneEvery trade
Passes the pre-written rule?No: gross trade is under three times costYes, if the account carries $14,000 plus initial margin

The day version has the larger net profit and the smoother curve, yet it fails the first test: its gross edge of $80 is less than two times the $45 round-trip cost, so a modest increase in slippage removes most of it. The swing version passes on costs and must then be judged on whether the trader can hold 40 overnight positions a year and carry the larger drawdown.

Hypothetical breakout rule tested two ways: the day version makes 480 trades a year, 35 dollars per trade after costs, costs take 56 percent, a smaller drawdown, no overnight exposure, and fails the pre-written rule; the swing version makes 40 trades, 320 dollars per trade, costs take 12 percent, a drawdown about 2.3 times larger, every trade held overnight, and passes Compare per trade Hypothetical breakout rule, both ways Day Swing Trades/yr 480 40 After costs $35 $320 Cost share 56% 12% Max drawdown Smaller 2.3× larger Overnight None Every trade Passes rule? No Yes
The same breakout rule, tested both ways, gives two reports that must be compared per trade after costs. Net profit alone would have picked the version that fails.

Note that the two versions are not rivals that cancel each other. A trader with the account size and the tolerance for gaps may run the swing version; a trader who wants to be flat every night may keep searching for a day rule whose gross edge clears the cost test. What neither trader should do is pick by net profit and then adjust the pass rule to fit the winner.

Your next step: take one breakout rule you already have, write the four thresholds above on paper, then run the day version on day-session bars with a forced exit ten minutes before the close and the swing version on full-session or daily bars with gap-through stops filling at the open. Put both results into the table and see which one passes the rule you wrote before you looked.

Frequently asked questions

What is the difference between a day trading backtest and a swing trading backtest?

A day trading backtest forces every position flat before the session close, uses day-session bars, never faces an overnight gap and can be sized on broker intraday margin. A swing trading backtest lets the rule close the trade days later, must choose whether night bars are in the data, must fill gap-through stops at the next open, and is sized on exchange initial margin. The same entry signal produces a different trade list, drawdown and cost profile in each.

Does a swing strategy backtest need to account for overnight gaps?

Yes. When the market opens beyond a stop level, the realistic fill is the opening price, and the difference between the stop and the open is a real loss. A backtest that fills such stops at the stop price understates the swing version's drawdown. Decide whether night-session bars are in the data as well, because that changes where the gap sits and how large it tends to be.

Why does a day trading strategy produce more trades?

Because it must be flat by the close, each trade can last only part of one session, so the same history holds many more completed trades than a rule that holds for days. The larger count makes the average trade and drawdown figures less uncertain, since the uncertainty shrinks with the square root of the trade count. It does not make the edge larger; the day version's gross move per trade is smaller, so costs take a bigger share of it.

Which is better, the day version or the swing version of the same strategy?

Neither wins across the board. Compare them with a rule written before the test: gross average trade against round-trip cost, maximum drawdown against the account size each version needs, enough trades to trust the average, and whether the trader will hold positions overnight. Keep the version that passes that rule, and do not choose by net profit and then adjust the rule.

References

  • Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.
  • Taiwan Futures Exchange. Mini-TAIEX Futures. https://www.taifex.com.tw/enl/eng2/mTX