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

[amibroker] Re: TREND DETECTORS WITH VARIABLE PERIOD



PureBytes Links

Trading Reference Links

Thank you Dimities nice piece of work with TREND DETECTOR. I can see 
what you are doing thanks.
--- In amibroker@xxxxxxxxxxxxxxx, "Dimitris Tsokakis" <TSOKAKIS@xxxx> 
wrote:
> 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 loose
> a 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 profits
> to a probable dramatic decrease after the actual peak. If the start 
of the trend was sharp with the well known gap ups
> then 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 gif
> Paste in your IB the
> 
> /*TREND DETECTOR WITH VARIABLE PERIOD, by D. Tsokakis, Apr2003*/
> t=20;// the initial fast period
> x=DEMA(StochD(40),t);
> Plot(x,"",1,8);// fast trend detector
> tA=50;// slow period
> xA=DEMA(StochD(40),tA);
> Plot(xA,"",7,8);// slow trend detector
> Cond1=Ref(x,-1)==LLV(x,3);
> Plot(50*Cond1,"",5,2);// the start of the fast uptrend
> Cond2=Ref(x,-1)==HHV(x,3);
> Plot(50*Cond2,"",4,2);// the end of the fast uptrend
> k1=BarsSince(Cond1);// uptrend bar counter
> k2=BarsSince(Cond2);// downtrend bar counter
> Plot((k2>k1)*10,"",5,2);
> Plot((k2<k1)*10,"",4,2);
> t1=IIf(k2>k1,t+k1,t+k2);// the variable period
> x1=DEMA(StochD(40),t1);// the variable trend detector
> Plot(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 
period
> according to your needs.
> The DEMA smoothing gives very reliable results and accepts variable 
periods by design.
> Dimitris Tsokakis


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Make Money Online Auctions! Make $500.00 or We Will Give You Thirty Dollars for Trying!
http://us.click.yahoo.com/yMx78A/fNtFAA/i5gGAA/GHeqlB/TM
---------------------------------------------------------------------~->

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 http://docs.yahoo.com/info/terms/