TriAverage_Gen (Function)
The TriAverage_Gen series function returns a smoothed average that places the majority of the weighting on the middle portion of the specified length.
Syntax
TriAverage_Gen(Price, Length)
Returns (Double)
The function returns the triangular average value.
Parameters
Name |
Type |
Description |
Price |
Numeric |
Specifies which bar value (price, function, or formula) to use. |
Length |
Numeric |
Sets the number of bars to consider. |
Remarks
This function returns the triangular average of values over all Length bars compared to the TriAverage function that returns the triangular average of an even number of Length bars.
In calculating the Triangular Average, the Average is inherently double-smoothed.
The input parameter Price can be a bar value such as Close, High, Low, Open, or Volume. It can also be any mathematical calculation such as: ( High + Low) / 2, or a numeric function such as RSI, Stochastic, or ADX.
Examples
Assigns to Value1 the Triangular Moving Average based on the Close of the last 14 bars:
Value1 = TriAverage_Gen(Close, 14);
Assigns to Value2 the Triangular Moving Average based on the High of the last 21 bars.
Value2 = TriAverage_Gen(High, 21);
Additional Example
If you wanted to place a Buy on Close order when the Close crossed above the Triangular Moving Average, you could use the following syntax:
If Close Crosses Above TriAverage_Gen(Close, 15) Then
Buy This Bar on Close;