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 - Pivotal by Jose Silva

Exponential Moving Average - Pivotal

{ Pivotal Exponential Moving Average v1.1 }

{ PEMA based on trough/peak support/resistance.
Options:
[1] Composite EMA: (Upper+Lower)/2;
[2] Upper EMA band based on peaks;
Lower EMA band based on troughs;
[3] EMA shifts to Upper/Lower on crossovers }

{ ŠCopyright 2004~2005 Jose Silva.
The grant of this license is for personal use
only - no resale or repackaging allowed.
All code remains the property of Jose Silva.
http://www.metastocktools.com }

{ User inputs }
pds:=Input("EMA periods",1,2520,21)/2;
plot:=Input("EMA: [1]Composite, [2]Upper+Lower, [3]Long/Short",1,3,1);
spread:=Input("Upper/Lower EMA bands shift %",
0,100,2)/200;
x:=Input("use: [1]Close, [2]High/Low",1,2,1);

{ Peaks }
xpk:=If(x=1,C,H);
pk:=Ref(xpk,-1)=HHV(xpk,3);
pkVal:=ValueWhen(1,pk,Ref(xpk,-1));

{ Peak-based EMA }
pkpds:=If(pds>Cum(pk),Cum(pk),pds);
pkpds:=If(pkpds<1,1,pkpds);
pkEma:=pkVal*2/(pkpds+1)+PREV*(1-2/(pkpds+1));
pkEma:=pkEma*(1+spread);

{ Troughs }
xtr:=If(x=1,C,L);
tr:=Ref(xtr,-1)=LLV(xtr,3);
trVal:=ValueWhen(1,tr,Ref(xtr,-1));

{ Trough-based EMA }
trpds:=If(pds>Cum(tr),Cum(tr),pds);
trpds:=If(trpds<1,1,trpds);
trEma:=trVal*2/(trpds+1)+PREV*(1-2/(trpds+1));
trEma:=trEma*(1-spread);

{ Composite EMA }
Ema:=(pkEma+trEma)/2;
LngShtEma:=If(C>=Ema,trEma,pkEma);

{ Plot on price chart }
If(plot=1,Ema,If(plot=2,trEma,LngShtEma));
If(plot=1,Ema,If(plot=2,pkEma,LngShtEma))



Exponential Moving Average - Pivotal
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.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!