DALEÄ!! AVERAGE TRUE RANGE TRAILING STOP (DATE SPECIFIC VERSION) ! Author: Sylvain Vervoort, TASC, June 2009 ! Coded by: Richard Denning 4/12/09 ! INPUTS: mo is 10. da is 2. yr is 2008. isLong is 1. ! 1 = for longs, 0 = for shorts atrLen is 5. atrMult is 3.5. ! ABBREVIATIONS: C is [close]. C1 is valresult(C,1). H is [high]. L is [low]. ! AVERAGE TRUE RANGE TR is Max(H - L,max(abs(C1 - L),abs(C1- H))). ATR is expAvg(TR,atrLen). ! ATR TRAILING STOP FROM DATE startDate is makeDate(mo,da,yr). daysSinceStart is scanany(ruledate() = startDate, 5040) then offSetToDate(month(),day(),year()). loss is ATR * atrMult. longStop is C-Loss. shortStop is C+Loss. maxVal is iff(reportdate() >= startDate,^highresult(longStop,^daysSinceStart+1),C). minVal is iff(reportdate() >= startDate,^lowresult(shortStop,^daysSinceStart+1),C). ! PLOT "TRAIL" AS CUSTOM INDICATOR TO SEE STOP ON CHART: trail is iff(reportdate() >= startDate and isLong = 1,maxVal, iff(reportdate() >= startDate and isLong <> 1,minVal,C)). Buy if reportdate() = startDate and isLong = 1. Exit if C < trail. SellShort if reportdate() = startDate and isLong <> 1. Cover if C > trail.  Rule Libraryÿÿ CCodeViewØÿÿÿÿ00:00