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 #

Exponential Moving Average - Cycle-adaptive by Jose Silva
Cycle-adaptive EMA - periodicity determined by historical price cycles.

{ Cycle-adaptive Exponential Moving Avg v1.1 }
{ EMA periodicity determined by historical
price cycle based on ZigZag cycles }
{ (c) Copyright 2004 Jose Silva }
{ http://www.metastocktools.com }

pr:=Input("ZigZag cycle reversal %",0,100,5);
choose:=Input("EMA periods based on: [1]Cycle, [2]Cycle Avg",1,2,1);
multi:=Input("EMA periodicity: Cycle/Avg length x",.1,100,2);
x:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5 P=6",1,6,6);
shift:=1+Input("EMA vertical shift %",
-100,100,0)/100;
plot:=Input("[1]EMA [2]Signals [3]Cycle [4]CyAvg [5]CyStdDev",1,6,1);

x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C)))));
zz:=Zig(x,pr,%);
zzpk:=Ref(zz,-1)>zz AND Ref(zz,-1)>Ref(zz,-2);
zztr:=Ref(zz,-1)<zz AND Ref(zz,-1)<Ref(zz,-2);
PkTr:=zzpk OR zztr;
CycleCount:=Cum(PkTr)-1;
CycleCount:=If(CycleCount=0,.000001,CycleCount);
CycleLenAvg:=Cum(CycleLen)/CycleCount;

pds:=If(choose=1,ValueWhen(1,CycleLen>0
AND CycleCount>0,CycleLen),CycleLenAvg)*multi;
pds:=
pds:=If(pds<1,1,pds);
Ema:=x*2/(pds+1)+PREV*(1-2/(pds+1));
Ema:=Ema*shift;
signals:=Cross(x,Ema)-Cross(Ema,x);

If(plot=1,Ema,If(plot=2,signals,
If(plot=3,CycleLen,
If(plot=4,CycleLenAvg,
If(plot=5,Stdev(CycleLen,21),pds)))))

Source / From: TOP
http://www.metastocktools.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.