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 #

ATR - True & Reverse by Jose Silva
True, reverse & MetaStock versions of smoothed/normalized Average True Range indicator.

ATR - True & Reverse

{ True, Reverse & MetaStock ATR v3.0 }
{ (c) Copyright 2004 Jose Silva }
{ http://www.metastocktools.com }

{ Reverse True Range is the the *smallest*
of the following for each period:
* The distance from today's High
to today's Low;
* The distance from yesterday's Close
to today's High;
* The distance from yesterday's Close
to today's Low.}

{ user input }
plot:=Input("[1]True ATR, [2]Reverse ATR, [3]Both, [4]MS-ATR",1,4,1);
pds:=Input("Average True Range periods",
1,252,10);
pdsN:=Input("normalizing periods (1=none)",
1,2520,1);
smooth:=Input("Sine-weighted smoothing? [1]Yes, [0]No",0,1,0);

{ define True Range }
x1:=ValueWhen(2,1,C);
TrueRange:=Max(H-L,Max(Abs(x1-H),Abs(x1-L)));
RevTrueRange:=Min(H-L,Min(Abs(x1-H),Abs(x1-L)));

{ average True Range }
ATRtrue:=Mov(TrueRange,pds,E);
ATRrev:=Mov(RevTrueRange,pds,E);
ATRmeta:=Mov(TrueRange,pds*2-1,E);

{ normalize ATR }
ATRraw:=If(plot=1,ATRtrue,If(plot=2,ATRrev,
If(plot=4,ATRmeta,ATRtrue)));
ATRnorm:=100*(ATRraw-LLV(ATRraw,pdsN))
/(HHV(ATRraw,pdsN)-LLV(ATRraw,pdsN)+.000001);
ATRplot:=If(pdsN<2,ATRraw,ATRnorm);
rATRnorm:=100*(ATRrev-LLV(ATRrev,pdsN))
/(HHV(ATRrev,pdsN)-LLV(ATRrev,pdsN)+.000001);
rATRplot:=If(pdsN<2,RevTrueRange,rATRnorm);

{ optional sine-weighted smoothing }
ATRplot:=If(smooth=1,(Sin(30)*ATRplot
+Sin(60)*Ref(ATRplot,-1)
+Sin(90)*Ref(ATRplot,-2)
+Sin(60)*Ref(ATRplot,-3)
+Sin(30)*Ref(ATRplot,-4))
/(Sin(30)*2+Sin(60)*2+Sin(90)),ATRplot);
rATRplot:=If(smooth=1,(Sin(30)*rATRplot
+Sin(60)*Ref(rATRplot,-1)
+Sin(90)*Ref(rATRplot,-2)
+Sin(60)*Ref(rATRplot,-3)
+Sin(30)*Ref(rATRplot,-4))
/(Sin(30)*2+Sin(60)*2+Sin(90)),rATRplot);

{ plot ATR }
If(plot=3,rATRplot,ATRplot);
ATRplot

 

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!