TriangularAverage

Category: Indicators

The Triangular Moving Average (TMA) is a technical indicator used in financial markets to smooth price data and reduce market noise. The TMA is a double-smoothed simple moving average. The first smoothing is applied to the raw data points, and the second smoothing is applied to the average itself. This results in a line that is smoother than a standard moving average, which can provide clearer signals about the trend direction over a specified number of periods.

Syntax:

TriangularAverage[N](price)

This function calculates the Triangular Moving Average of the given price over the last N periods.

Example:

once ssMA = close
MA = TriangularAverage[50](close)
if(MA > ssMA + (MA/100)*1) THEN
  ssMA = MA
ELSIF (MA < ssMA - (MA/100)*1) THEN
  ssMA = MA
ELSE
  ssMA = ssMA
ENDIF
RETURN ssMA

In this example, the Triangular Moving Average is calculated for the last 50 periods of the close price. The result is stored in the variable MA. The script then compares MA to a previously stored moving average ssMA. If MA is greater than ssMA by 1% of MA, ssMA is updated to the new value of MA. Similarly, if MA is less than ssMA by 1% of MA, ssMA is updated. If neither condition is met, ssMA remains unchanged. Finally, ssMA is returned as the output of the script.

Additional Information:

  • The Triangular Moving Average is particularly useful in trending markets where it helps to identify the trend direction more clearly than other types of moving averages.
  • Choosing the right period N is crucial as it affects the sensitivity and smoothness of the moving average.
Logo Logo
Loading...