[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] TREND DETECTORS WITH VARIABLE PERIOD



PureBytes Links

Trading Reference Links




Some uptrends are sustainable for more than 10-20 days.A 
fast trend detector, like DEMA(StochD(40),20) would buy at B0 and sell at 
S0.The very next days it would force the trader to follow the undesirable 
whipsaws W1, W2 and probably loosea part of the B0/S0 profits.[see the black 
line]A slow trend follower like DEMA(StochD(40),50) would start at 
B1[missing the interesting first 7 bars] and stop at S1[6 bars after the 
actual end of the trend]. The use of the slow period helps to avoid 
whipsaws but expose the profitsto a probable dramatic decrease after the 
actual peak. If the start of the trend was sharp with the well known gap 
upsthen the remaining profits would not be similar to this great trend.[see 
the yellow line].The technical analyst wish would be 1. to begin 
ASAP, 2. avoid the whipsaws and 3. get out as closer to the actual 
peak.It is the basic T/A problem with almost any indicator and here 
is a solution proposal : the variable smoothing.Begin with the fast 
indicator and, as the trend goes on, increase smoothing factor adding +1 delay 
per bar.If the trend holds for 20 bars, the beginning would be per=20 and 
today you would run a per=40.If the trend stops for any reason, sharply back 
to per=20 to begin another, bearish cycle.The result is the ENTRY/EXIT of 
the att. ^NDX gifPaste in your IB the
 
/*TREND DETECTOR WITH VARIABLE PERIOD, by D. Tsokakis, 
Apr2003*/t=20;// the initial fast 
periodx=DEMA(StochD(40),t);Plot(x,"",1,8);// fast trend 
detectortA=50;// slow 
periodxA=DEMA(StochD(40),tA);Plot(xA,"",7,8);// slow trend 
detectorCond1=Ref(x,-1)==LLV(x,3);Plot(50*Cond1,"",5,2);// the start of 
the fast uptrendCond2=Ref(x,-1)==HHV(x,3);Plot(50*Cond2,"",4,2);// the 
end of the fast uptrendk1=BarsSince(Cond1);// uptrend bar 
counterk2=BarsSince(Cond2);// downtrend bar 
counterPlot((k2>k1)*10,"",5,2);Plot((k2<k1)*10,"",4,2);t1=IIf(k2>k1,t+k1,t+k2);// 
the variable periodx1=DEMA(StochD(40),t1);// the variable trend 
detectorPlot(x1,"",(x1>Ref(x1,-1))*5+(x1<Ref(x1,-1))*4,8);GraphXSpace=1; 

 
The method accepts further calibration if you replace t1 
with
coeff=0.5; // delay calibration, set coeff from 0.5 
to 1.5
t1=IIf(k2>k1,t+coeff*k1,t+coeff*k2);// the calibrated 
variable periodaccording to your needs.
The DEMA smoothing gives very reliable results and accepts 
variable periods by design.
Dimitris Tsokakis
 






Yahoo! Groups Sponsor












Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



Attachment:
varTREND.gif

Attachment: Description: "Description: GIF image"