+1 888 340 6572

T3Average.series

Article/Author: Origin: Gary Fritz`s site. Originally provided by Bob Fulks, 12/14/1997

File Includes:
Function - T3Average.series
Function - T3Average
Function - T3Average.simple
Function - XAverage.V
Indicator - T3
Indicator - T3Average
Indicator - T3.Demo

Category: Function > T3Average.series

Description:

This function is an EasyLanguage version of the moving average described in the January, 1998 issue of S&C magazine, p.57, "Smoothing Techniques for More Accurate Signals", by Tim Tillson. It is translated from the MetaStock code presented in the article and recoded for efficiency.

The variable, "Hot", is a damping coefficient which is set to the suggested default value of 0.7. The variable "b" is substituted for the variable, "a" used in the article since "a" is a reserved word. The variables e1 through e6 calculate the exponential moving averages in-line rather than calling other functions.

The resulting indicator plotting this function appears to duplicate the results shown in Figure 4 of the article. The series version of this function uses previous values and, hence, cannot call variables.

Inputs:
Price -
Periods -
NOTE:The "Periods" input can need not be an integer.

EasyLanguage Code:

INPUTS: PRICE(NUMERICSERIES), PERIODS(NUMERICSIMPLE);

VARIABLES: B(0), B2(0), B3(0), E1(PRICE), E2(PRICE), E3(PRICE),
E4(PRICE), E5(PRICE), E6(PRICE), C1(0), C2(0), C3(0),
C4(0), F1(0), F2(0), HOT(0.7);

IF PERIODS + 1 <> 0 THEN BEGIN

IF CURRENTBAR <= 1 THEN BEGIN

B = HOT;
B2 = B * B;
B3 = B * B * B;
C1 = -B3;
C2 = 3 * B2 + 3 * B3;
C3 = -6 * B2 - 3 * B - 3 * B3;
C4 = 1 + 3 * B + B3 + 3 * B2;
F1 = 2 / (PERIODS + 1);
F2 = 1 - F1;

END ELSE BEGIN

E1 = F1 * PRICE + F2 * E1;
E2 = F1 * E1 + F2 * E2;
E3 = F1 * E2 + F2 * E3;
E4 = F1 * E3 + F2 * E4;
E5 = F1 * E4 + F2 * E5;
E6 = F1 * E5 + F2 * E6;

END;

T3AVERAGE.SERIES = C1 * E6 + C2 * E5 + C3 * E4 + C4 * E3;

END;