Triangular Moving Average also known as TRIMA adds extra smoothening to the simple moving average and is ideal to identify trends during choppy market conditions. As you would know that simple moving average gives equal weightage to all price points and exponential moving average gives more weightage to recent price points, but in case of triangular moving average more weightage is given to the middle portion of the time series.
It is a double smoothed moving average so that entry signals may lag i.e. the trend identification is delayed. However, there is an extra advantage of determining exit signals using TRIMA as it doesn’t get affected by any volatile market moves.
Similar to SMA and EMA, the triangular moving average is also a trend following indicator. It may be promising to use this along with other indicators or price action.
It’s recommended to use this indicator in higher timeframes like Daily or Weekly.
Also Read: Elder’s Force Index AFL Code
Below is the screenshot of the triangular moving average plotted in an Amibroker chart. It is plotted as a blue line over the candlestick chart.
Along with TRIMA, a simple moving average is also plotted as a white line. You can clearly see that triangular moving average is more smoothened and react slowly as compared to the simple moving average.
Triangular Moving Average AFL Download
Download the AFL code for triangular moving average from the below link:
After plotting the chart title and candlestick chart, SMA and TRIMA are calculated using the below formulas:
SMA = MA (Close, Periods)
TRIMA = MA (SMA, TRIMAPeriods)
SMA = simple moving average
Periods = time period for simple moving average
TRIMAPeriods = round (Periods/2)
And then, SMA and TRIMA are plotted on a candlestick chart by using the standard Amibroker “plot” function.
Please note that some charting platforms use the same time periods for both SMA and TRIMA.
Do you want to learn AFL coding from scratch and build your own profitable trading systems? Check out our best-selling Algorithmic trading Bootcamp course bundle.
Long and Short Rules
Here are the long and short rules you can consider while trading through TRIMA:
- If TRIMA is rising, it signifies uptrend
- If TRIMA is falling, it signifies downtrend
- If TRIMA crosses above price, go long
- If TRIMA crosses below price, go short
- If lower period TRIMA crosses above higher period TRIMA, go long
- If lower period TRIMA crosses below higher period TRIMA, go short
- TRIMA can also be used to assess the technical divergence between price and indicator. For example- if price makes a higher high and TRIMA makes a lower high, then the bullishness may be subsiding. And if price makes a lower low and TRIMA makes a higher low, then the bearishness may come to an end soon
All the AFL’s posted in this section are for learning purposes. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at email@example.com