{ Downloaded From https://www.WiseStockTrader.com } {Average True Range - custom smoothing v2.0 Smoothing types for ATR: 1 - Exponential MA 2 - Simple MA 3 - Time Series MA 4 - Triangular MA 5 - Variable MA 6 - Volume adjusted MA 7 - Weighted MA 8 - MetaStock (Wilder's) Copyright © 2002-2009 Jose Silva. For personal use only. http://www.metastocktools.com } {Inputs} pds:=Input("ATR smoothing periods",1,260,5); type:=Input("[1]EMA [2]SMA [3]TmSr [4]Tri [5]Var [6]Vol [7]Wght",1,8,2); {ATR custom smoothing} x:= If(type=1,Mov(ATR(1),pds,E), If(type=2,Mov(ATR(1),pds,S), If(type=3,Mov(ATR(1),pds,T), If(type=4,Mov(ATR(1),pds,TRI), If(type=5,Mov(ATR(1),pds,VAR), If(type=6,Mov(ATR(1),pds,VOL), If(type=7,Mov(ATR(1),pds,W), ATR(pds)))))))); {Automatic OverBought/Sold historical levels} avg:=Cum(x)/Cum(IsDefined(x)); pk:=Ref(x,-1)=HHV(x,3) AND Ref(x,-1)>avg; pk1:=ValueWhen(1,pk,Ref(x,-1))*pk; oBought:=Cum(pk1)/Cum(pk); tr:=Ref(x,-1)=LLV(x,3) AND Ref(x,-1)