# Moving averages and their metastock formulas

#### oxusmorouz

##### Well-Known Member
Most people would have heard about a simple, weighted, exponential moving average. Also, some softwares like metastock are designed to include other types of moving averages such as variable moving average, vol weighted, triangular and time series, which isn't as popular as the ones first mentioned.

Here, I shall post some other variants so enable the user to experiment with varities. The explanation of these averages got from google, for they are no magic indicators.

1) Hull Moving Average (Coded by, Mr.Jose Silva, www.metastocktools.com)

Formula :
period:=Input( "Period", 1,200,20) ;
sqrtperiod:= Input("Square Root of Period",1,20, 4);
Mov(2*(Mov(C, period/2, W))-Mov(C, period,W) ,sqrtperiod, W);

2) AMA

Formula:
Periods := Input("Time Periods:",1,1000, 10);
Direction := CLOSE - Ref(CLOSE,-periods);
Volatility := Sum(Abs(ROC(CLOSE,1,\$)),periods);
ER := Abs(Direction/Volatility);
FastSC := 2/(2 + 1);
SlowSC := 2/(30 + 1);
SSC := ER * (FastSC - SlowSC) + SlowSC;
Constant := Pwr(SSC,2);
AMA := If(Cum(1) = periods +1, Ref(CLOSE,-1) + constant * (CLOSE - Ref(CLOSE,-1)),PREV + constant * (CLOSE - PREV));
AMA

3) ARSI:

Formula:
war:=Input("Time Periods:",1,1000, 20);;
SC:=(Abs(RSI(war)/100 - 0.5)*2);
ARSI:=If(Cum(1)<war,C,PREV+SC*(C-PREV));

ARSI

4) Kalman MA:

Formula:
PRICEE:=C;
Smooth:=.13785*(2*PriceE - Ref(PriceE,-1)) + .0007*(2*Ref(PriceE,-1) - Ref(PriceE,-2)) + .13785*(2*Ref(PriceE,-2) -Ref(PriceE,-3)) +
1.2103*PREV - .4867*Ref(PREV,-1);

SMOOTH;

5) T3 :

Formula:
Periods:=Input("Time Periods:",1,63,5);
a:=Input("Hot:",0,2,.7);
e1:=Mov(P,Periods,E);
e2:=Mov(e1,Periods,E);
e3:=Mov(e2,Periods,E);
e4:=Mov(e3,Periods,E);
e5:=Mov(e4,Periods,E);
e6:=Mov(e5,Periods,E);
c1:=-a*a*a;
c2:=3*a*a+3*a*a*a;
c3:=-6*a*a-3*a-3*a*a*a;
c4:=1+3*a+a*a*a+3*a*a;
c1*e6+c2*e5+c3*e4+c4*e3;

6) Lagless MA (Coded by Mr.Josesilva, www.metastocktools.com)

Formula:
prd:=Input("Periods",1,250,21);
2*Mov(C,prd,E)-Mov(Mov(C,prd,E),prd,E);

These are just a few types of MAs and several others exist, such as Jurikers, Elhers etc. This should allow the user to broaden his/her outlook and think beyond simple, weighted or exponential averages.

Oxusmorouz.

#### oxusmorouz

##### Well-Known Member
oops, forgive me for the typos.
2nd para 1st line : "to enable the user"
2nd para line : "can be got"
Sorry for the repost...couldn't edit the 1st one.

#### bharaata

##### New Member
Can someone write down the maths of these formula.

#### rh6996

##### Well-Known Member
Most people would have heard about a simple, weighted, exponential moving average. Also, some softwares like metastock are designed to include other types of moving averages such as variable moving average, vol weighted, triangular and time series, which isn't as popular as the ones first mentioned.

Here, I shall post some other variants so enable the user to experiment with varities. The explanation of these averages got from google, for they are no magic indicators.

1) Hull Moving Average (Coded by, Mr.Jose Silva, www.metastocktools.com)

Formula :
period:=Input( "Period", 1,200,20) ;
sqrtperiod:= Input("Square Root of Period",1,20, 4);
Mov(2*(Mov(C, period/2, W))-Mov(C, period,W) ,sqrtperiod, W);

2) AMA

Formula:
Periods := Input("Time Periods:",1,1000, 10);
Direction := CLOSE - Ref(CLOSE,-periods);
Volatility := Sum(Abs(ROC(CLOSE,1,\$)),periods);
ER := Abs(Direction/Volatility);
FastSC := 2/(2 + 1);
SlowSC := 2/(30 + 1);
SSC := ER * (FastSC - SlowSC) + SlowSC;
Constant := Pwr(SSC,2);
AMA := If(Cum(1) = periods +1, Ref(CLOSE,-1) + constant * (CLOSE - Ref(CLOSE,-1)),PREV + constant * (CLOSE - PREV));
AMA

3) ARSI:

Formula:
war:=Input("Time Periods:",1,1000, 20);;
SC:=(Abs(RSI(war)/100 - 0.5)*2);
ARSI:=If(Cum(1)<war,C,PREV+SC*(C-PREV));

ARSI

4) Kalman MA:

Formula:
PRICEE:=C;
Smooth:=.13785*(2*PriceE - Ref(PriceE,-1)) + .0007*(2*Ref(PriceE,-1) - Ref(PriceE,-2)) + .13785*(2*Ref(PriceE,-2) -Ref(PriceE,-3)) +
1.2103*PREV - .4867*Ref(PREV,-1);

SMOOTH;

5) T3 :

Formula:
Periods:=Input("Time Periods:",1,63,5);
a:=Input("Hot:",0,2,.7);
e1:=Mov(P,Periods,E);
e2:=Mov(e1,Periods,E);
e3:=Mov(e2,Periods,E);
e4:=Mov(e3,Periods,E);
e5:=Mov(e4,Periods,E);
e6:=Mov(e5,Periods,E);
c1:=-a*a*a;
c2:=3*a*a+3*a*a*a;
c3:=-6*a*a-3*a-3*a*a*a;
c4:=1+3*a+a*a*a+3*a*a;
c1*e6+c2*e5+c3*e4+c4*e3;

6) Lagless MA (Coded by Mr.Josesilva, www.metastocktools.com)

Formula:
prd:=Input("Periods",1,250,21);
2*Mov(C,prd,E)-Mov(Mov(C,prd,E),prd,E);

These are just a few types of MAs and several others exist, such as Jurikers, Elhers etc. This should allow the user to broaden his/her outlook and think beyond simple, weighted or exponential averages.

Oxusmorouz.
What is a variable moving average? How is it denoted in Metastock? I mean what is its abbreviation?

#### biggles

##### Active Member
help requested for this in metastock

{( Closing Price [today] - Closing Price [yesterday] ) / Closing Price [yesterday]} * Volume [today]

thanks

#### rh6996

##### Well-Known Member
help requested for this in metastock

{( Closing Price [today] - Closing Price [yesterday] ) / Closing Price [yesterday]} * Volume [today]

thanks
Do you mean to plot the value of : Todays close (minus) yesterdays close and this value divided by yesterdays close and then this value is multiplied by todays volume !!
There would be negative values also because todays price if lower than previous day would generate negative values!
Please share how do you wish to use this value?
Shall try to seek help from knowledgeable people to post Metastock formula for this Indicator!

#### mangup

##### Well-Known Member
help requested for this in metastock

{( Closing Price [today] - Closing Price [yesterday] ) / Closing Price [yesterday]} * Volume [today]

thanks
Pl checkout below formula -
((C- ref(C,-1))/ref(C,-1))*V