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 - Trade-Adjusted by Jose Silva
Self-adjusting Exponential Moving Average, adjusts periodicity to trade frequency - with multiple output choice.


Exponential Moving Average - Trade-Adjusted

{ 6-loop trade-adjusted EMA }
{ Adjusts EMA periodicity to trade frequency }

{ (c) Copyright 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 }
avg:=Input("Crossover trades per year",2,1000,12);
plot:=Input("[1]EMA, [2]Signals, [3]EMA periods",1,3,1);

{ Base EMA periods }
pds:=21;

{ Year count }
yCount:=
LastValue(Year()-ValueWhen(1,Cum(1)=1,Year()));

{ Loop 1 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Loop 2 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Loop 3 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Loop 4 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Loop 5 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Loop 6 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Final output }
EMA:=Mov(C,pds,E);
long:=Cross(C,EMA);
short:=Cross(EMA,C);

{ Plot EMA on price chart }
If(plot=1,EMA,If(plot=2,long-short,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.

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!