MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

 A B C D E F G H I J K L M N O P R S T U V W Y Z #

Stochastic Oscillator Monthly EMA by Roy Larsen
Hi,

I would like to plot a monthly stochastic on a weekly chart ?

Here is the code of the stochastic I use :

Mov(Stoch(14,1),5,E)

Regards,

Marco

======================================

Hi Marco

Here's a monthly stochastic for daily charts. You can also use it for weekly charts, but remember that the end-of-month date is different for daily and monthly charts than it is for weekly charts. This is because the end of a month does not necessarily coincide with the end of a week. For example, on a weekly chart May 2005 finished on the 27th, but on daily and monthly charts it finished on the 31st.

Kind regards

Roy Larsen
www.metastocktips.co.nz

Stochastic Oscillator Monthly EMA

{2005 Roy Larsen, www.metastocktips.co.nz}
{for use on daily charts}

N:=Input("Monthly Stochastic Oscillator Periods (%K)",1,99,14);
K:=Input("%K Slowing Periods" ,1,99,1);
D:=Input("%D EMA Periods",1,99,5);
Q:=Input("Display Mode, 0=Static 1=Dynamic 2=Test",0,2,1);
{0=Display, update at end-of-month}
{1=Display, update on each new bar}
{2=Backtest, update on first bar of new month}
G:=LastValue(Sum(Month()<>ValueWhen(2,1,Month()),5)=5);
M:=G OR Month()<>ValueWhen(2,1,Month());
F:=G OR PeakBars(1,Zig(If(G*(Cum(1)=1),1,DayOfMonth()),1,\$),1)=0;
A:=LastValue(Cum(1)-1)=Cum(1);
B:=ValueWhen(2,1,A);
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
Hm:=HighestSince(1,M,H);
Hm:=ValueWhen(1,J,If(J=1,Hm,ValueWhen(2-G,1,Hm)));
Lm:=LowestSince(1,M,L);
Lm:=ValueWhen(1,J,If(J=1,Lm,ValueWhen(2-G,1,Lm)));
Cm:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Hm:=ValueWhen(1,Hm>0,Hm);
Lm:=ValueWhen(1,Lm>0,Lm);
Z:=Cum(LowestSince(N,M,Lm)*(J>0));
Z:=Cm-(Z-ValueWhen(K+1,J,Z));
I:=Cum((HighestSince(N,J,Hm)-LowestSince(N,J,Lm))*(J>0));
I:=I-ValueWhen(K+1,J,I);
I:=ValueWhen(1,Cum(I>0)>0,I);
X:=100*Z/I; A:=2/(1+D);
X:=ValueWhen(1,Cum(J>0)>=K+N,X);
Y:=ValueWhen(1,J,PREV)*(1-A)+X*A;
Y:=ValueWhen(1,Cum(J>0)>=N+K+D,Y);
X; {%K}
Y; {%D}

======================================

Hi Roy,

It works fine :)

Thank you very much

Regards,
Marco

Source / From: TOP
EquisMetastock[at]yahoogroups[dot]com

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.