VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Indicators and signals

20 week moving average strategy: 100 days, 3 rules and how to test them

A 20-week moving average covers about 100 trading days. It is a usable trend filter only when the rule is written exactly, tested with costs on futures bars, judged against buy and hold on drawdown rather than net result, and shown to behave the same at nearby lengths.

By · Published · updated · Editorial policy

Contents
  1. Is a 20 week moving average strategy a useful trading rule?
  2. How many days is a 20-week moving average?
  3. Which simple rules can you test: close above, close below, or a crossover?
  4. Should you sell when price breaks below the 20-week average?
  5. How does the rule compare with buy and hold, and what does drawdown show?
  6. Why can one length mislead you, and which nearby values should you check?
  7. How do you backtest a 20-week moving average on index futures?
  8. Frequently asked questions
  9. References

Is a 20 week moving average strategy a useful trading rule?

A 20 week moving average strategy is a usable trend filter only when you write the rule exactly, test it with commission and slippage on futures bars, compare it with buy and hold on drawdown rather than net result, and show that lengths near 20 weeks behave the same. Without those four checks it is a line on a chart, not a rule.

A moving average is the average close of the last N bars, recomputed on every new bar so the line moves with price. The 20-week version (20週均線 in Chinese-language charting) is one of the slowest averages traders follow on index charts. Its job is not to find entries; it is to tell you whether you are in a long rise or a long fall. That is the claim this article tests: the value of a slow average, if it has any, shows up in drawdown, not in return.

The four checks above are the same ones that apply to any line from the technical analysis indicators you can actually test. A moving average has one advantage: the rule is short, so there is little room to hide a vague definition.

How many days is a 20-week moving average?

A 20-week average covers about 100 trading days, so a 100-day simple moving average on daily bars draws almost the same line, while a 20-day average is a different and much faster rule. A trading week has five sessions, and 20 weeks times 5 days is 100 days. Exchange holidays remove a few days from any 20-week stretch, so on daily bars the match is close rather than exact.

The two lines are not identical even over the same 100 days. A 20-week average on weekly bars uses only the Friday closes; a 100-day average on daily bars uses every close. The daily version is smoother and updates every session, which also means it can signal mid-week instead of waiting for Friday. For backtesting on futures, daily bars are the practical choice: they give more signal bars and let you fill on the next session's open.

The 20-day average (20日均線) covers about one month. Because it is five times shorter, price crosses it far more often, and a rule built on it trades roughly five times as often as the same rule on the 20-week line. More trades mean more commission and slippage, so the two lengths are not two settings of one strategy; they are two strategies with different cost profiles.

Lookback20-day average20-week average
Bars covered20 daily bars, about one month20 weekly bars or about 100 daily bars, about five months
Signal frequencyFrequent crossesFew crosses, often months apart
Cost sensitivityHigh: many round trips per yearLow: few round trips per year
Typical useSwing entries and exitsLong-term trend filter
A 20-week average uses 20 weekly bars and a 100-day average uses about 100 daily bars over the same five months, while a 20-day average covers only about one month of that span 20 weeks ≈ 100 trading days Same five months, two bar sizes 20-week 100-day 20-day ≈ 1 month 20-day is a different, faster rule. So: test it as its own strategy.
Twenty weekly bars and about 100 daily bars cover the same calendar stretch. A 20-day average covers only one month of it and signals far more often.

Which simple rules can you test: close above, close below, or a crossover?

Three rules cover most uses of a slow average, and each one must say which bar triggers the signal and which bar fills the order. A rule that only says "buy above the average" cannot be tested, because the backtest does not know whether to act on a touch, a close, or a close that is confirmed by the next bar.

  1. Close above/below rule. Long while yesterday's close is above the average; flat (or short) while it is below. Signal on the close of the bar; fill on the open of the next bar. This is the complete trend filter.
  2. Break-below exit only. Enter long by some other rule, or hold from the start, and exit when a bar closes below the average. Re-entry happens by the original entry rule, not by a cross back above. This is the version most discretionary traders mean when they ask whether to sell on a break.
  3. Fast-average crossover. A crossover is the moment one average moves from below another to above it. Here a faster average, such as a 20-day line, crosses the 20-week line. The crossover trades later than rule 1 because two smoothed lines must cross, but it skips many single-bar dips below the slow line.

For the crossover, the choice of fast average changes lag. A double exponential moving average cuts EMA lag and crosses earlier than a simple average of the same length, which trades the fewer late signals for more early ones. Test that trade-off; do not assume less lag is better.

All three moving-average rules, close above, break below and crossover, read the signal on a bar's close and fill on the next bar, so no rule uses a price it could not have traded Signal bar, then fill bar The same timing in all three rules Average Signal Fill 1 Close above 2 Break below 3 Crossover No rule trades a price it never saw. So: name both bars in every rule.
Three testable rules. The signal bar is where the condition is read; the fill bar is the next one, so no rule uses a price it could not have traded.

Should you sell when price breaks below the 20-week average?

A break below the 20-week average is a slow exit that often fires after a large part of a fall has already happened and reverses quickly in a sideways market, so before you adopt it as a sell rule, count how many past breaks were whipsaws and how many were real trend changes. A whipsaw is a signal that reverses soon after it fires, so you exit, price turns back up, and you re-enter higher than you left.

The slow length is the cause of both effects. A 100-day average sits well below price in a long rise, so by the time a close drops under it, the index has usually given back months of gains. In a flat market the same line runs through the middle of price, and closes cross it every few weeks. Brock, Lakonishok and LeBaron (1992) found that moving-average rules on a long Dow Jones history produced returns different from random on both sides of the line; Park and Irwin (2007), reviewing later studies, report that the results weaken once costs and the number of rules tried are accounted for. The exit's value therefore depends on your market and your costs, which is why it has to be counted rather than assumed.

  1. List every bar where the close moved from above to below the average.
  2. For each, record the result of staying out until the re-entry signal, compared with holding through.
  3. Mark a break as a whipsaw when staying out cost money, and as a real trend change when it saved money.
  4. Sum the two groups. The rule is worth keeping only if the money saved on real breaks exceeds the money lost on whipsaws, after the costs of every exit and re-entry.

Hypothetical example

Suppose a ten-year test of a 100-day break-below exit on an index future produces 20 breaks. Fifteen are whipsaws, each costing about 2 percent of the index value in missed recovery plus two round trips of costs; five are real trend changes, each avoiding about 12 percent of further fall. The whipsaws cost roughly 30 percent in total; the real breaks save roughly 60 percent. The rule is kept, but on a count of 5 against 15, so the test also records that three signals out of four were wrong.

Illustration of a price line and a slow average: four short dips below the average in a sideways stretch are whipsaws, and one later break below it starts a long fall, the real trend change Most breaks are whipsaws Illustration, not real data 4 whipsaws 1 real break Average One real break pays for the whipsaws. So: count both before you trust it.
Most breaks below a slow average are short crosses in a sideways market. The rule pays for them with the one break that precedes a long fall.

If the whipsaw count is high, a second condition before selling is a fair thing to test, as long as it is written as a rule. Positioning data is one candidate: the Commitment of Traders report tested as a rule shows how to turn a weekly release into a testable filter, and the COT positioning rule on gold futures works through one market in detail.

How does the rule compare with buy and hold, and what does drawdown show?

Judge the rule against a buy-and-hold line on the same futures data by maximum drawdown and time in market, not by net result alone, because a trend filter usually earns less than holding through a long rise and its only defence is a smaller drawdown. Buy and hold is the comparison strategy that enters at the first bar and never exits. Maximum drawdown is the largest fall from an equity peak to the next low, measured before a new peak is made. You can read it from any equity series with the free drawdown calculator.

On futures, buy and hold means holding one contract and rolling it every quarter, so build the comparison on the same continuous, back-adjusted series the rule uses. Then set the two equity curves side by side and read four numbers:

MeasureWhy it mattersWhat a useful filter shows
Net resultTotal gain over the periodOften lower than buy and hold in a long rise
Maximum drawdownThe worst fall you would have sat throughClearly smaller than buy and hold
Time in marketShare of bars with a positionLower; the filter is flat in falls
Result per unit of time in marketGain earned while exposedHigher than buy and hold if the flat periods were the bad ones

Hypothetical example

Over a ten-year test, buy and hold on an index future gains $100,000 with a maximum drawdown of $40,000 and is in the market 100 percent of the time. The 100-day close-above rule gains $70,000 with a maximum drawdown of $18,000 and is in the market 60 percent of the time. It earned less in total, but it earned more per unit of exposure and its worst fall was less than half as deep. Whether that trade is worth making is a decision about how much drawdown your account and your nerves can hold, which is the real question a trend filter answers.

Illustration comparing buy and hold, set to 100 percent, with a moving-average rule: the rule is somewhat lower on net result, much lower on maximum drawdown and about half on time in market Smaller gain, smaller fall Illustration: buy and hold = 100% Buy & hold Rule Net result Max drawdown Time in market The filter's case is the drawdown. So: judge it on drawdown, not net.
A trend filter gives up part of the rise and in return cuts the deepest fall. The bars below the curves make the trade visible.

Why can one length mislead you, and which nearby values should you check?

A result that is good at 100 days but poor at 90 and 110 is a lucky spike, so run the rule across a band of lengths around 20 weeks and keep it only when neighbouring settings behave alike. Nothing about the market knows that 20 weeks is special. If the edge is real, a 95-day or 105-day average should catch most of the same trends and most of the same whipsaws, and the results should sit on a plateau. A plateau is a range of settings whose results are similar; a spike is one setting that stands far above its neighbours.

The spike is what selection does to you. When you try many lengths and report the best one, part of that best result is noise that happened to fit this history. Bailey, Borwein, López de Prado and Zhu (2014) show that the expected out-of-sample result of the best candidate falls as the number of candidates tried rises. The practical reading is simple: a wide plateau means the rule, not the number, is doing the work. The full method for reading a parameter surface is in parameter stability: plateau or lucky spike.

  1. Run the exact rule at 80, 90, 100, 110 and 120 days, with the same costs and fill rule.
  2. Compare net result, maximum drawdown and trade count across the five runs, not net result alone.
  3. Keep the rule if the five results are of similar sign and size. Reject it if one length stands alone.
  4. Trade the centre of the plateau, not its best point.
Illustration of results at five moving-average lengths from 80 to 120 days: on the left five bars of similar height form a plateau, on the right one tall bar at 100 days stands above four low bars as a lucky spike Plateau or lucky spike? Result at 80 to 120 days, illustration Plateau Lucky spike Neighbours alike: the rule works. So: trade the centre of the plateau.
Five nearby lengths of similar height mean the rule works; one tall bar means the number was lucky on this history.

How do you backtest a 20-week moving average on index futures?

Set the bar size, session, contract point value, commission, slippage and next-bar execution first, then run the exact rule over the full history and read trades, drawdown and the out-of-sample stretch. For a Nasdaq-100 test, that means NQ daily bars, the full trading session so the close is the exchange settlement-time close, and a point value of $20 per index point, which the CME contract specification sets. Exchanges change contract values from time to time; the exchange's contract page is the place to confirm them.

  1. Choose the market and bar size: NQ daily bars, built on a continuous back-adjusted series.
  2. Set the session and point value: full session, $20 per point.
  3. Set commission and slippage per trade, and apply them to every entry and exit.
  4. Write the exact rule: the condition read on the close, the fill on the next open, and the re-entry condition.
  5. Run over the full history, with the last stretch held out as out-of-sample.
  6. Read the trade count, the maximum drawdown and how the out-of-sample stretch compares with the rest.

Step 3 is the one a moving-average test most often skips, because a slow rule trades rarely and the costs look small. They are small per year, but they decide the whipsaw count in the break-below test above, so they belong in every run from the start. AlphaPrime (Valynox) charges fees and slippage inside each evaluation and fills on the next bar, so the backtesting of a slow average and a fast one are already on the same cost basis when you compare them.

Six backtest steps on NQ daily bars: market, session, costs, exact rule, full run, read the results; a weak result loops back to step 4 to change the rule, never the data Settings first, rule second Six steps on NQ daily bars 1 Market 2 Session 3 Costs 4 Rule 5 Run 6 Read Weak result? Go back to step 4. So: change the rule, not the data.
Settings first, rule second, run third. When the result disappoints, the loop goes back to the rule, never to the data or the dates.

The run below shows what the output of those six steps looks like on NQ daily bars. It did not test a 20-week moving average. It tested a stand-in rule, a Mean-Reversion Half-Life rule built from standard indicators, as the only entry and exit, long and short, with no stop, target or filter. The candidate shown is the one the search kept out of 1,024 it tried, chosen for its return against its drawdown; picking the kept one after the fact flatters it, so read the table as an example of a report, not as what the rule or any moving average earned and not as what a reader can expect.

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

NumberResult
Net profit (closed trades)$208,535
Max drawdown$73,565
Trades252
Win rate56.35%
Profit factor1.407
Average trade$827.52
Time in market50.5%

Three lines in that table are the ones to read for any rule, including a 20-week average. Trades (252 over about six and a half years) tells you whether the sample is large enough to judge. Max drawdown ($73,565) against net profit ($208,535) is the return-against-drawdown comparison from the buy-and-hold section. Time in market (50.5%) shows how much of the period the rule was exposed, which is the number a trend filter is supposed to lower.

Look at the slope before and after the out-of-sample mark, and at the depth of the shaded drawdown relative to the climb. A 20-week moving average test should be read from the same three places.
Look at the slope before and after the out-of-sample mark, and at the depth of the shaded drawdown relative to the climb. A 20-week moving average test should be read from the same three places. NQ · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

The next step is to run the close-above rule at 100 days on your own index futures data with the costs you actually pay, then rerun it at 80, 90, 110 and 120 days and put the five maximum drawdowns next to the buy-and-hold drawdown of the same series. If the five sit together and all are clearly smaller than buy and hold, the rule has passed the two tests that matter most. If they do not, you have learned that in one afternoon instead of one bear market.

Frequently asked questions

How many trading days is a 20-week moving average?

About 100 trading days, because a trading week has five sessions and 20 times 5 is 100. Exchange holidays remove a few days from any real 20-week stretch, so a 100-day average on daily bars is a close match rather than an exact one. On weekly bars the average uses only 20 Friday closes, so it is a little rougher than the daily version.

Should I sell when price breaks below the 20-week moving average?

Only if a test on your market shows that the falls the exit avoided outweighed the whipsaws it caused, after costs. The break fires late in a long fall and reverses often in a sideways market. Count both groups over the full history before adopting it, and consider a second rule-based condition if the whipsaw count is high.

Is the 20-week moving average the same as the 100-day moving average?

They cover the same stretch of time and draw nearly the same line, but they are not identical. The 20-week version updates once a week from Friday closes; the 100-day version updates every session from every close. For backtesting on futures the daily version is more practical because it gives a signal bar and a next-bar fill every session.

How do I backtest a 20-week moving average on futures?

Set the bar size, session, point value, commission, slippage and next-bar fill before writing the rule. Write the rule down to the bar: which close is read and which open fills. Run it over the full history with a held-out out-of-sample stretch, compare its drawdown and time in market with buy and hold on the same data, and repeat at 80 to 120 days to confirm the result is a plateau and not a single lucky length.

References

  • Brock, W., Lakonishok, J., & LeBaron, B. (1992). Simple Technical Trading Rules and the Stochastic Properties of Stock Returns. The Journal of Finance, 47(5), 1731–1764.
  • Park, C.-H., & Irwin, S. H. (2007). What Do We Know About the Profitability of Technical Analysis? Journal of Economic Surveys, 21(4), 786–826.
  • 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.
  • CME Group. E-mini Nasdaq-100 Futures Contract Specs. https://www.cmegroup.com/markets/equities/nasdaq/e-mini-nasdaq-100.contractSpecs.html