← Back to Home
Trading Strategy
πŸ“ˆ

Moving Average Crossover Strategy

One of the oldest and most widely used trend-following techniques.

Start Automating Free β†’

Want to automate this strategy? Try auto-Trading free β€” no credit card required.

Moving Average Crossover Strategy chart

Overview

What is Moving Average Crossover Strategy?

The moving average crossover is among the most widely taught trend-following strategies in technical analysis. The core idea is straightforward: you plot two moving averages of different lengths on a price chart and generate a trade signal whenever the faster average crosses above or below the slower one.

A bullish crossover β€” sometimes called a "golden cross" when the 50-day MA crosses above the 200-day MA β€” occurs when the short-period average rises above the long-period average. This indicates that recent prices are climbing faster than the longer-term trend and is interpreted as a buy signal. The opposite, a bearish or "death cross", occurs when the short-period average falls below the long-period average.

Popular combinations include the 5/20 pair for intraday trading, the 20/50 pair for swing trading, and the 50/200 pair for longer-term position trading. The choice of periods affects the sensitivity of the signals: shorter periods generate more signals with more false positives, while longer periods are slower to react but tend to produce cleaner signals.

The main limitation of the strategy is that it is a lagging indicator β€” by definition, a crossover can only occur after price has already moved. In ranging markets, this can lead to repeated whipsaws. Traders typically add a filter such as a volume confirmation or an ADX reading above 25 to avoid trading crossovers in low-volatility, directionless markets.

auto-Trading allows you to automate crossover strategies using the no-code strategy builder. You simply select two EMA or SMA blocks, wire them into a crossover condition block, and attach a buy or sell action β€” no programming required.

How It Works in auto-Trading

Automate It

When the faster moving average (e.g., the 9-period EMA) crosses above the slower moving average (e.g., the 21-period EMA), auto-Trading generates a long entry signal. The bot submits a market or limit order depending on your settings. When the crossover reverses β€” the fast MA drops below the slow MA β€” the system closes the position and optionally opens a short. Risk parameters such as stop-loss distance and position size are set in the risk management module.

Try Free β†’

Strategy Code

Pick a script below, copy it, and use it on your chart.

Pine Script (TradingView)

This is a TradingView Pine Script strategy example for this page concept. Paste it into the TradingView Pine Editor, add it to your chart, and run it in the Strategy Tester.

//@version=6
strategy("Moving Average Crossover Strategy", overlay=true)
fastLen = input.int(20, "Fast Length")
slowLen = input.int(50, "Slow Length")
fast = ta.ema(close, fastLen)

Get full strategy code access

Enter your email address and full name to unlock this strategy code.

ThinkScript (thinkorswim)

This is a thinkorswim ThinkScript strategy example for this page concept. Open thinkorswim, create a custom strategy, paste the script, and apply it to your chart.

input fastLength = 20;
input slowLength = 50;
def fastMA = ExpAverage(close, fastLength);
def slowMA = ExpAverage(close, slowLength);
def buySignal = fastMA crosses above slowMA;

Get full strategy code access

Enter your email address and full name to unlock this strategy code.

Ready to automate Moving Average Crossover Strategy?

Join thousands of traders who use auto-Trading to execute this strategy automatically, 24/7.

Get Started Free β†’

All Strategies & Signals

Continue Learning

Trading Strategies

Trading Signals & Indicators