Moving Average Crossover

Home / Honest answer

Honest answer

The best settings? An honest answer.

People keep asking which two numbers to use. The truthful answer is that it depends, and that the search for a magic pair is where many traders go wrong.

Why there is no universal best

A moving average crossover has few moving parts: the two lengths, the type of average, the price input and the timeframe. Changing any of them changes what the signal does. And the market is not a constant. A pair that is smooth and profitable in a trending stretch can be a steady loser in a range, and which one you get next is not something a setting can know. Anyone offering a single best pair is either describing one past stretch or oversimplifying.

What actually changes the picture

FactorWhat it changes
Fast lengthShorter reacts sooner and crosses more; longer is smoother and later.
Gap between lengthsLines close in length tangle and cross often; a wide gap gives fewer, later crossings.
TimeframeA 9/21 on a 1-minute chart covers minutes; on a daily chart it covers weeks. The same numbers describe different market behaviour.
InstrumentVolatility, liquidity and tick size differ, so the same pair can behave very differently in different markets.
Session and regimeOpen, midday and close behave differently, as do trending and ranging days.
CostsCommissions and slippage are paid on every trade, and faster pairs trade more, so costs weigh more on them.

You can feel the first two rows in the crossover playground: shrink the gap between the lengths and the crossing count tends to climb.

How to test settings properly

  1. Write the rule down first. Entry, exit, position size, stop, session. A vague idea cannot be tested.
  2. Include real costs. Commissions and a realistic slippage allowance. A rule that looks fine without costs may not survive them.
  3. Split your data. Design on one period, then check on a period the design never saw (out-of-sample). Walk-forward testing repeats this across successive windows.
  4. Look for a plateau, not a peak. Test neighbouring settings. If 9/21 works but 8/21 and 10/22 collapse, the result is probably noise. A genuine behaviour tends to degrade gradually.
  5. Look beyond profit. Check drawdown, number of trades, the longest losing streak and how much of the result came from a few trades.
  6. Test across instruments and years. An idea that only ever worked once is a coincidence.
  7. Forward-test on a simulator. Trading it live on simulated money shows what a backtest cannot: how it feels, and whether you can follow the rule.

Our sister site has a full walkthrough of the process: backtesting on strategies.ninja, with more on rules at strategies.ninja.

The overfitting trap. If you try fifty pairs and keep the best, you have measured how good the luckiest one was, not how good the idea is. The more combinations you try, the more the winner flatters the history.

A practical way to choose

Start from the time horizon you want to trade. If you want signals over days or weeks, you need slower averages; for minutes to hours, faster ones. Choose a fast/slow ratio that is not too tight, add a filter or two for sideways markets (see the EMA crossover guide), and keep a short list rather than hunting for a winner. Then test it as above and accept that the outcome may be that the crossover is not for your market. If you work in NinjaTrader, the NinjaTrader page and NinjaTrader Guru help with the setup, and Affordable Indicators builds tools for the platform.

Trading involves substantial risk of loss. None of this is advice to use any setting.

Frequently asked questions

What is the best moving average crossover setting?

There is no universal best. The pair that looked best on one instrument, timeframe and stretch of history often looks ordinary on another. What you can do is choose a pair that fits your timeframe and style, then test it carefully and see how sensitive the results are to small changes.

Is 50/200 or 9/21 better?

They answer different questions. 50/200 is a slow, long-term filter normally used on daily charts; 9/21 is a fast pair used on intraday charts. Neither is better in the abstract.

What is overfitting in a crossover test?

Trying many length combinations and keeping the one with the best past result nearly always finds one that looks good by chance. That pair has fitted noise in the history, so there is little reason to expect it to repeat.

How much data do I need to test a crossover?

Enough to include different market conditions, such as trends, ranges and volatile and quiet periods, and enough trades that one lucky or unlucky streak does not decide the answer. There is no magic number, so treat a small sample with caution.

Keep reading