Back-testing a Popular Trading Strategy

Back-testing the Moving Average Cross Strategy in TradingView

Sofien Kaabar, CFA
3 min readDec 6, 2023

--

Moving averages may provide interesting trading strategies. This article back-test the most famous moving average strategy and shows how to code it in TradingView.

Moving Averages & Crosses

Moving averages are widely used technical analysis tools in financial markets. They are calculated by taking the average price of an asset over a specified period of time, and they help smooth out short-term price fluctuations, providing a clearer picture of the underlying trend.

A simple moving average is calculated by summing up the prices over a certain period and then dividing by the number of periods. An exponential moving average gives more weight to recent prices, making it more responsive to price changes.

Moving average crossovers occur when two different moving averages with different periods intersect or cross each other on a price chart.

Moving average crossovers are often used by traders to identify potential buy or sell signals. However, it’s important to note that they are lagging indicators, meaning they may signal a trend change after it has already occurred.

  • A bullish cross occurs whenever the…

--

--