Moving-average systems
Build and test a crossover rule · 8 min
- Close
- 10-day average
- 40-day average
Every crossing of the two lines would be a trade for a crossover rule.
A rule is long when the 10-day average is above the 40-day average and short when it is below. On a market that moves sideways like the one above, what happens most often?
A moving average is the mean of the last n closes. A crossover rule compares a fast average with a slow one: long while the fast is above, short (or flat) while it is below. It is a smoothed way of asking whether recent prices are higher than older ones.
The price of smoothness is lag. On a steady trend an n-day average sits (n − 1) ÷ 2 days behind price, so a 200-day average reacts to a turn about 100 days late. Faster averages react sooner but switch more often on noise. There is no setting that is both quick and quiet: you choose where on that trade-off to sit, and in a range every setting pays for whipsaws.
- Close
- 20-day average
- 100-day average
- Crossover system
- Buy and hold
Generated markets, not real data. They show how a rule depends on the market it meets; they do not predict how real markets behave.
Signal and lag from two averages
- Last five closes
- 50, 51, 53, 52, 54
- 5-day average
- (50 + 51 + 53 + 52 + 54) ÷ 5 = 52.0
- 3-day average
- (53 + 52 + 54) ÷ 3 = 53.0
- Fast (3) above slow (5)?
- 53.0 > 52.0: long
- Lag of a 20-day average on a +0.5 a day trend
- (20 − 1) ÷ 2 × 0.5 = 4.75 below price
Price has risen a steady 1 point a day for months. About how far below price does its 41-day average sit?
In a range a crossover switches 12 times a year. Each switch costs 0.1% in trading costs and loses another 0.5% on average from buying high and selling low. What is the yearly drag?
The 20-day average is 101.4 and the 100-day average is 103.0. What does a long-short crossover rule hold?
Missed questions come back for review after one day, then three, then a week.
The highs of the last 5 days were 43.23, 45.59, 46.82, 45.68, 47.08. A 5-day breakout rule buys when the close is above the highest of them. At what price level does it buy?
Hint: The channel top is the highest high of the previous days (today is not included).
Three years of a fresh generated market are on screen; the next two years do not exist yet. Tune the rule on what you can see, commit to two predictions, then generate the future.
- Your rule so far
Over the next two years, after costs, this rule will…
What kind of market is this?
Generated markets, not real data. They show how a rule depends on the market it meets; they do not predict how real markets behave.
Want to feel it candle by candle? Feel the whipsaw in the choppy-range market →