0

Triangular Moving Average AFL Code

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.

Preferred Timeframe

It’s recommended to use this indicator in higher timeframes like Daily or Weekly.

Also Read: Elder’s Force Index AFL Code

Screenshot

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 Screenshot

Triangular Moving Average AFL Download

Download the AFL code for triangular moving average from the below link:

Triangular Moving Average AFL Download

AFL Explanation

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)

Where

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:

  1. If TRIMA is rising, it signifies uptrend
  2. If TRIMA is falling, it signifies downtrend
  3. If TRIMA crosses above price, go long
  4. If TRIMA crosses below price, go short
  5. If lower period TRIMA crosses above higher period TRIMA, go long
  6. If lower period TRIMA crosses below higher period TRIMA, go short
  7. 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

Disclaimer:

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 support@tradingtuitions.com

Related Posts

Leave a Reply

Your email address will not be published.