Home Money & Finance The Moving Average crossover strategy for trading indices

The Moving Average crossover strategy for trading indices

by Olufisayo
Moving Average crossover strategy

The Moving Average crossover strategy for trading indices is a method of trading stock indexes by applying technical analysis.

This is a swing trading strategy with a time horizon of up to a few days up to a few months. Because of the nature of the method, it means that there could be significant drawdowns before potentially the market moves in the direction of profit, so please make sure that you are aware of all the risks involved with trading and using this strategy.

This strategy could be used for both long (buy) and short (sell) trades

The strategy itself is simple – you need to use two simple moving average indicators. In our case, it will be the 200 period and 100 period SMAs. Once the 100-day crosses under the 200 days, a short position is opened. When the 100 day Moving Average goes above the 200 day, the short position is closed and a buy position is opened. The buy position is closed once the condition to open a short is met.

Time to check whether this strategy is profitable



For this, we will use tradingview’s backtesting capabilities which are good enough to check whether a strategy is worth pursuing. There are other more sophisticated backtesting solutions that can be used later to optimize parameters and properly evaluate the strategy.

Moving Average crossover strategy

The backtest chart on tradingview

What do the results from the backtest show?

Since June 2016 this strategy has produced only 9 opportunities with a total of 8 closed trades. Out of these 8 trades 25% were profitable, and overall, the strategy produced a profit. However, the drawdown during trades was very severe with max drawdown on the account being 3x bigger than the profit. Also, the average bars in a trade were 215 which means that on average these trades were held for 215days.



Are these backtest results good or bad?

The answer is somewhere in the middle. If you are looking for longer term trades, and can sustain the drawdown, this could be a good strategy. However, improvements can be made by adding additional parameters for opening and closing trades and using different parameters for the Simple Moving averages. So overall it’s a good starting point to build a better strategy.

The verdict

The Moving average crossover strategy for index trading still works and backtest results show it’s profitable. However, the returns aren’t very high, and traders should be able to sustain significant drawdown. Therefore, additional work on optimizing and adding more conditions for opening and closing trades may prove to be beneficial. If you are looking to do swing trading and use this strategy, but don’t have a broker to trade with, you can find a broker here.

Full PinescriptTradingview code:



//@version=5
strategy(“My script”,overlay=true)
//setting up SMAs
one_hundred_ma = ta.sma(close, 100)
two_hundred_ma = ta.sma(close, 200)
//setting up crossover and crossunder
crossover = ta.crossover(one_hundred_ma,two_hundred_ma)
crossunder = ta.crossunder(one_hundred_ma,two_hundred_ma)
//plotting SMAs
plot(one_hundred_ma,color=color.red)
plot(two_hundred_ma)
//strategy for long
strategy.entry(“Long”, strategy.long, 1, when = crossover)
strategy.close(“Long”, when = crossunder)
//strategy for short
strategy.entry(“Short”, strategy.short, 1, when = crossunder)
strategy.close(“Short”, when = crossover)

Photo by Anna Nekrashevich

Related Articles