Triangular Moving Average – Trading Strategy Backtest (Does It Work?)
Last Updated on August 22, 2022 by Oddmund Groette
Triangular moving average strategy backtest
Moving averages are the most common and useful technical indicators in forex trading, owing to their effect in smoothening out price movements and showing the actual direction of the trend. There are various types of moving averages. Apart from the common ones you know, such as the Simple Moving Average (SMA) and Exponential Moving Average (EMA), there is also the Triangular Moving Average (TMA) – the moving average we cover in this article. But do you know what it is? And do you know if a simple average works to trade profitably in the markets?
Yes, triangular moving average strategies do work. Our backtests show that a triangular moving average can be used profitably for both mean-reversion and trend-following strategies on stocks.
Triangular moving averages are similar to the simple moving average (SMA). It can provide a smooth line like the simple moving average. However, the triangular moving average is averaged twice to create an extra smooth and steady average line.
Table of contents:
Triangular moving average strategy backtest and best settings
Before we go on to explain what a triangular moving average is and how you can calculate it, we go straight to the essence of what this website is all about: quantified backtests.
Our hypothesis is simple:
Does a triangular moving average strategy work? Can you make money by using triangular moving averages strategies?
We look at the most traded instrument in the world: the S&P 500. We test on SPDR S&P 500 Trust ETF which has the ticker code SPY.
All in all, we do four different backtests:
- Strategy 1: When the close of SPY crosses BELOW the N-day moving average, we buy SPY at the close. We sell when SPY’s closes ABOVE the same average. We use CAGR as the performance metric.
- Strategy 2: Opposite, when the close of SPY crosses ABOVE the N-day moving average, we buy SPY at the close. We sell when SPY’s closes BELOW the same average. We use CAGR as the performance metric.
- Strategy 3: When the close of SPY crosses BELOW the N-day moving average, we sell after N-days. We use average gain per trade in percent to evaluate performance, not CAGR.
- Strategy 4: When the close of SPY crosses ABOVE the N-day moving average, we sell after N-days. We use average gain per trade in percent to evaluate performance, not CAGR.
The results of the first two backtests look like this:
Strategy 1
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
8.96 |
7.61 |
5.72 |
4.57 |
2.78 |
1.88 |
MDD |
-29.13 |
-34.56 |
-39.97 |
-44.3 |
-51.53 |
-50.15 |
Strategy 2
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
0.69 |
1.98 |
3.74 |
4.91 |
6.69 |
7.54 |
MDD |
-72.82 |
-52.67 |
-44.27 |
-39.2 |
-41.14 |
-31.19 |
The results from the backtests are pretty revealing: in the short run, the stock market shows tendencies of mean-reversion. In the long run, it is better to use trend-following strategies.
Why do we reach that conclusion?
Because if we use a short moving average, the best strategy is to buy when stocks drop below the average and sell when it turns around and closes above the moving average (buy on weakness and sell on strength). This can clearly be seen in the first test above for the 5-day moving average. The 5-day moving average returns a CAGR of 8.96%, which is almost as good as buy and hold even though the time spent in the market is substantially lower.
When we buy on strength and sell on weakness, in the second test in the table above, the best strategy is to use many days in the average. The longer the average is, the better. The 200-day moving average returns 7.54%, which is pretty decent. Worth noting is that the max drawdown is much better compared to buy and hold (31 vs 56%).
The results from backtests 3 and 4 look like this (the results are not CAGR, but average gains per trade):
Strategy 3
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.23 |
0.42 |
1.17 |
1.86 |
4.33 |
8.65 |
10 |
0.2 |
0.43 |
1.07 |
2.03 |
4.5 |
8.49 |
25 |
0.31 |
0.75 |
1.05 |
2.37 |
4.53 |
10.27 |
50 |
0.26 |
0.41 |
1.37 |
1.84 |
5.4 |
10.15 |
100 |
0.76 |
1.13 |
1.88 |
3.52 |
5.27 |
7.66 |
200 |
0.17 |
0.51 |
0.88 |
3.35 |
6.07 |
8.07 |
Strategy 4
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.24 |
0.2 |
0.93 |
2.06 |
3.98 |
8.31 |
10 |
0.13 |
0.21 |
0.83 |
1.84 |
4.1 |
8.53 |
25 |
0.21 |
0.28 |
0.91 |
1.51 |
3.67 |
8 |
50 |
0.06 |
0.27 |
0.68 |
1.75 |
3.84 |
8.2 |
100 |
0.62 |
0.81 |
1.62 |
2.3 |
5.66 |
8.68 |
200 |
0.3 |
-0.47 |
0.23 |
2.25 |
4.87 |
7.21 |
As expected, the longer you are in the stock market, the better returns you get. This is because of the tailwind in the form of inflation and productivity gains. It doesn’t matter much if you buy when it crosses above or below the triangular moving average.
However, be aware that this is just one method of testing a moving average. There are basically unlimited ways you can use a moving average and your imagination is probably the most restricting factor!
What is a triangular moving average (TMA)?
The triangular moving average is a type of moving average that shows the average price of an asset over a particular number of data points, usually several price bars. It is similar to the simple moving average, but it is averaged twice, creating an extra smooth moving average line.
Like the simple moving average, the triangular moving average can provide smooth lines, but the double averaging makes the TMA line even smoother and more wavelike. The implication is that the calculated result of the triangular moving average is not as reactive as other moving averages, such as the simple moving average and exponential moving average. However, the triangular moving average can provide excellent insight to help you stay in the trend longer and make more profits.
Generally, the triangular moving average is mostly applied to the price and overlays the price data. But it can also be applied to the volume data, in which case it would overlay the volume indicator.
How to calculate a triangular moving average
A triangular moving average can be calculated using various input data, such as prices, volume, or other technical indicators, but it often focuses on the price data. The TMA calculation is the sum of simple moving average values divided by the number of periods you want to average. Hence, before calculating the triangular moving average, you should first calculate the simple moving average (SMA).
The formulas for the calculations are given below:
SMA = (P1 + P2 + P3 + P4 + … + PN) / N
Then, take the average of all the SMA values to get TMA values.
TMA = (SMA1 + SMA2 + SMA3 + SMA4 + … SMAN) / N
Interestingly, you will not need to do the calculations manually since most trading platforms will handle all the calculations for you.
Why use a triangular moving average?
The triangular moving average performs similar functions as the simple moving average. It shows the average price of an asset over a specified number of data points. Due to its double averaging, the triangular moving average performs the function of double-smoothing the price data, which will produce a line that doesn’t react as quickly as a simple moving average would.
Since the triangular moving average reacts more slowly to price changes than other moving averages, such as the exponential moving average (EMA) and simple moving average (SMA), it helps the trader to identify the longer-term trend and stay longer in a trend, milking more profits as the trend progresses.
How to use a triangular moving average
Usually, the triangular is built into most trading platforms. However, you must note that not all platforms have a TMA indicator. To see if your platform provides the indicator, you should just open a chart and then go to the indicator section. Search for “Triangular Moving Average.” If it isn’t there, you can try applying a standard Moving Average, then go into the indicator’s setting and see whether you can change the calculation to triangular. Some platforms label the TMA as “Moving Average Triangular” or “MovAvgTriangular,” so make sure to search thoroughly.
If it turns out that your platform doesn’t have TMA, you can add a custom-calculated Moving Average and insert the TMA formula. Alternatively, you can also apply an SMA to your chart and then another SMA that uses the first SMA as its input.
How can you use a triangular moving average?
Traders can use the triangular moving average to double-smooth the price data. The TMA produces a line on your trading chart. However, the TMA line will not react as fast as the SMA line. For example, during volatile market conditions, the TMA will not react quickly, which means it will take a much longer time for the TMA line to change direction. So, the indicator is best used to identify the long-term trend.
The lag time of the TMA line can be very useful in many ways: if the price moves are ranging, the triangular moving average will not react much to change in price movement, allowing traders to know that the trend hasn’t shifted. It takes a more sustained move in the price to cause the TMA to change directions.
Overall, you can use the triangular moving average to know the direction of the main trend. You can also use it to trail the price when if you are a position trader and wish to stay with the trend for a long time until the trend clearly changes direction.
Drawbacks with a triangular moving average
The triangular moving average is not the best choice for traders looking for an indicator that responds instantly to slight price changes. It may not be very useful for generating signals if you are a swing trader or a day trader because it lags a lot. Even for position trading, when the trend does turn, the TMA will react slowly, which could mean you give up more profits than you should.
Another major drawback of the triangular moving average is that it often tends to be far away from the market price when there is a strong trend. As a result, the triangular moving average is less effective for determining a close support or resistance level.
Relevant articles about moving averages strategies and backtests
Moving averages have been around in the trading markets for a long time. Most likely, moving average strategies were the start of the systematic and automated trading strategies developed in the 1970s, for example by Ed Seykota. We believe it’s safe to assume moving averages were a much better trading indicator before the 1990s due to the rise of the personal computer. The most low-hanging fruit has been “arbed away”.
That said, our backtests clearly show that you can develop profitable trading strategies based on moving averages but mainly based on short-term mean-reversion and longer trend-following. Furthermore, there exist many different moving averages and you can use a moving average differently/creatively, or you can combine moving averages with other parameters.
For your convenience, we have covered all moving averages with both detailed descriptions and backtests. This is our list:
- Moving average trading strategies
- Exponential moving average (backtest strategy)
- Hull moving average (backtest strategy)
- Linear-weighted moving average (backtest strategy)
- Adaptive moving average (backtest strategy)
- Smoothed moving average (backtest strategy)
- Variable moving average (backtest strategy)
- Weighted moving average (backtest strategy)
- Zero lag exponential moving average (backtest strategy)
- Volume weighted moving average (backtest strategy)
- Triple exponential moving average TEMA (backtest strategy)
- Variable Index Dynamic Average (backtest strategy)
- Guppy multiple moving average (backtest strategy)
- McGinley Dynamic (backtest strategy)
- Geometric moving average GMA (backtest strategy)
- Fractal adaptive moving average FRAMA (backtest strategy)
- Fibonacci moving averages (backtest strategy)
- Double exponential moving average (backtest strategy)
- Moving average slope (backtest strategy)
We have also published relevant trading moving average strategies:
- The 200-day moving average strategy
- Trend-following system/strategy in gold (12-month moving average)
- Trend following strategies Treasuries
- Is Meb Faber’s momentum/trend-following strategy in gold, stocks, and bonds still working?
- Trend following strategies and systems explained (including strategies)
- Does trend following work? Why does it work?
- A simple trend-following system/strategy on the S&P 500 (By Meb Faber and Paul Tudor Jones)
- Conclusions about trend-following the S&P 500
- Why arithmetic and geometric averages differ in trading and investing
Triangular moving average – takeaways
Our takeaway from the backtests is that triangular moving average strategies work well if you buy on weakness (a close below the moving average) when you use a short number of days. Opposite, it’s best to buy on strength (a close above the moving average) when you use a long moving average.