Apologies guys fell down a black hole! Thanks for all your help. This is where I think I have got too. I would very much appreciate your feedback:
Modified Moving Average – 8 Day Period MMA8
N:=8;
TN8:=Mov(C,N,S);
s8:=((n-1)/2)*
C+((n-3)/2)*
Ref(C,-1)+((n-5)/2)*
Ref(C,-2)+((n-7)/2)*
Ref(C,-3)+((n-9)/2)*
Ref(C,-4)+((n-11)/2)*
Ref(C,-5)+((n-13)/2)*
Ref(C,-6)+((n-15)/2)*
Ref(C,-7),
MMA8:=TN8+(6*S8)/((n+1)*n);
MMA8
Modified Moving Average – 9 Day Period MMA9
N:=9;
TN9:=Mov(C,N,S);
s9:=((n-1)/2)*
C+((n-3)/2)*
Ref(C,-1)+((n-5)/2)*
Ref(C,-2)+((n-7)/2)*
Ref(C,-3)+((n-9)/2)*
Ref(C,-4)+((n-11)/2)*
Ref(C,-5)+((n-13)/2)*
Ref(C,-6)+((n-15)/2)*
Ref(C,-7)+((n-17)/2)*
Ref(C,-8),
MMA9:=TN9+(6*S9)/((n+1)*n);
MMA9
Modified Moving Average – 17 Day Period MMA17
N:=17;
TN17:=Mov(C,N,S);
s17:=((n-1)/2)*
C+((n-3)/2)*
Ref(C,-1)+((n-5)/2)*
Ref(C,-2)+((n-7)/2)*
Ref(C,-3)+((n-9)/2)*
Ref(C,-4)+((n-11)/2)*
Ref(C,-5)+((n-13)/2)*
Ref(C,-6)+((n-15)/2)*
Ref(C,-7)+((n-17)/2)*
Ref(C,-8)+((n-19)/2)*
Ref(C,-9)+((n-21)/2)*
Ref(C,-10)+((n-23)/2)*
Ref(C,-11)+((n-25)/2)*
Ref(C,-12)+((n-27)/2)*
Ref(C,-13)+((n-29)/2)*
Ref(C,-14)+((n-31)/2)*
Ref(C,-15)+((n-33)/2)*
Ref(C,-16),
MMA17:=TN17+(6*S17)/((n+1)*n);
MMA17
Substituting the above into this standard MACD formula:
Standard MACD
shortperiods:=Input("Enter the shorter MOV periods: ",8);
longperiods:=Input("Enter the longer MOV periods: ",17);
signal:=Input("Enter the number of signal line periods: ",9);
MOV(C,shortperiods)-MOV(C,longperiods);
MOV(MOV(C,shortperiods,E)-MOV(C,longperiods,E),signal,E)
Should give the following:
N:=8;
TN8:=Mov(C,N,E);
s8:=((n-1)/2)*
C+((n-3)/2)*
Ref(C,-1)+((n-5)/2)*
Ref(C,-2)+((n-7)/2)*
Ref(C,-3)+((n-9)/2)*
Ref(C,-4)+((n-11)/2)*
Ref(C,-5)+((n-13)/2)*
Ref(C,-6)+((n-15)/2)*
Ref(C,-7),
MMA8:=TN8+(6*S8)/((n+1)*n);
N:=17;
TN17:=Mov(C,N,E);
s17:=((n-1)/2)*
C+((n-3)/2)*
Ref(C,-1)+((n-5)/2)*
Ref(C,-2)+((n-7)/2)*
Ref(C,-3)+((n-9)/2)*
Ref(C,-4)+((n-11)/2)*
Ref(C,-5)+((n-13)/2)*
Ref(C,-6)+((n-15)/2)*
Ref(C,-7)+((n-17)/2)*
Ref(C,-8)+((n-19)/2)*
Ref(C,-9)+((n-21)/2)*
Ref(C,-10)+((n-23)/2)*
Ref(C,-11)+((n-25)/2)*
Ref(C,-12)+((n-27)/2)*
Ref(C,-13)+((n-29)/2)*
Ref(C,-14)+((n-31)/2)*
Ref(C,-15)+((n-33)/2)*
Ref(C,-16),
MMA17:=TN17+(6*S17)/((n+1)*n);
MMA8-MMA17
N:=9;
TN9:=Mov((MMA8-MMA17),N,E);
s9:=((n-1)/2)*
(MMA8-MMA17)+((n-3)/2)*
Ref((MMA8-MMA17),-1)+((n-5)/2)*
Ref((MMA8-MMA17),-2)+((n-7)/2)*
Ref((MMA8-MMA17),-3)+((n-9)/2)*
Ref((MMA8-MMA17),-4)+((n-11)/2)*
Ref((MMA8-MMA17),-5)+((n-13)/2)*
Ref((MMA8-MMA17),-6)+((n-15)/2)*
Ref((MMA8-MMA17),-7)+((n-17)/2)*
Ref((MMA8-MMA17),-8),
MMA9:=TN9+(6*S9)/((n+1)*n);
I have the following questions regarding the above:
1. I have made all the formulae exponential even though some people use simple moving averages – Is this correct for a strict interpretation of DiNapoli.
2. Does everyone agree with the logic?
3. Is this syntactically correct (me never having coded an indicator before – probably shows too!)? Ideally I would like to cut and paste it directly into Metastock. For instance should I be using different ‘N’ and ‘n’ in each section?
4. Lastly, pumrysh I do not understand the purpose / necessity for this section of your coding:
{Zero Lag EMA}
Period:= Input("What Period",1,250,10);
EMA1:= Mov(P,Period,E);
EMA2:= Mov(EMA1,Period,E);
Difference:= EMA1 - EMA2;
ZeroLagEMA:= EMA1 + Difference;
ZeroLagEMA {end}
--
Carriolan