PureBytes Links
Trading Reference Links
|
/*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;
/******************************************************************/
/*Here is an alternative.
The first method was increasing the smoothing period for every trendy
day, from the beginning till the end.
It will do it even if the trend lasts 3 or 13 or 53 bars.
A more realistic approach is to increase the period AFTER some
threshhold bars.
Keep the smoothing fast up to the 20th trendy bar and then increase
the period to stay more in the market and enjoy
the last [and the most interesting] part of the [prolonged] trend.
This will help to ignore the premature exit signals, ignore the
probable first pull-backs and catch the usual double peak
formation, but, the code will examine this possible scenario AFTER
the 20 confirmed trend bars.
The gif speaks better :
The initial trend detector is the black DEMA(StochD(40),20).
The variable detector stays closely for the first 20 bars and then
changes to a much slower mode.[green-red line]
The obvious benefit is to ignore premature exit at the first peak P1,
re-entry at R1 and goes to a final exit at P2.
The code for IB is*/
t=20;
x=DEMA(StochD(40),t);
Plot(x,"",1,8);
tA=50;
xA=DEMA(StochD(40),tA);//Plot(xA,"",7,8);
Cond1=Ref(x,-1)==LLV(x,3);
Plot(50*Cond1,"",5,2);
Cond2=Ref(x,-1)==HHV(x,3);
Plot(50*Cond2,"",4,2);
k1=BarsSince(Cond1);
k2=BarsSince(Cond2);
Plot((k2>k1)*10,"",5,2);
Plot((k2<k1)*10,"",4,2);
Coeff=2;
trendbars=20;// calibrate here the start of variable smoothing
t1=IIf(k2>k1 AND k2>trendbars,t+coeff*k1,IIf(k1>k2 AND
k1>trendbars,t+coeff*k2,t));
x1=DEMA(StochD(40),t1);
Plot(x1,"",(x1>Ref(x1,-1))*5+(x1<Ref(x1,-1))*4,8);
GraphXSpace=2;
--- In amibroker@xxxxxxxxxxxxxxx, "mrdavis9" <mrdavis9@xxxx> wrote:
> Rick, I found this mentioned on this yahooboard, and I am guessing
that I must have copied it from one of Dimitris emails. I just
copied and pasted it from my Amibroker program. I also could not
find it in the library when I went there to try and record my opinion
of it. I think I also remember reading that there are two versions
of it, and it would sure be nice if someone would post both versions
into the AFL library with narrative about each of them. My apologies
if it is already there, and I just couldn't find it. Ron D
>
>
>
>
>
>
>
> t=20;x=DEMA(StochD(40),t);Plot(x,"",1,8);
>
> tA=50;xA=DEMA(StochD(40),tA);//Plot(xA,"",7,8);
>
> Cond1=Ref(x,-1)==LLV(x,3);Plot(50*Cond1,"",5,2);
>
> Cond2=Ref(x,-1)==HHV(x,3);Plot(50*Cond2,"",4,2);
>
> k1=BarsSince(Cond1);k2=BarsSince(Cond2);
>
> Plot((k2>k1)*10,"",5,2);Plot((k2<k1)*10,"",4,2);
>
> Coeff=2;
>
> trendbars=20;// calibrate here the start of variable smoothing
>
> t1=IIf(k2>k1 AND k2>trendbars,t+coeff*k1,IIf(k1>k2 AND
k1>trendbars,t+coeff*k2,t));
>
> x1=DEMA(StochD(40),t1);
>
> Plot(x1,"",(x1>Ref(x1,-1))*5+(x1<Ref(x1,-1))*4,8);
>
> GraphXSpace=2;
>
>
======================================================================
=======
>
>
> Does this indicator have a name???? Can't search the AFL library
unless we know the name.
>
> Thanks,
>
> Rick
> -----Original Message-----
> From: mrdavis9 [mailto:mrdavis9@x...]
> Sent: Friday, May 02, 2003 2:39 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Cc: ronald davis
> Subject: Re: [amibroker] DIMITRIS- Question
>
>
> Wally, this is a screen shot of Dimitris trend detector
indicator. Notice how it sometimes lags the PSAR in getting into a
new trend. Also, notice how it kept you out of the PSAR whipsaw that
occurred on 04-10-03. I am going to post this to the AFL library
comments section of this indicator, assuming that it is now in the
library. I picked it up by reading this Amibroker yahoogroup. Ron D
>
>
>
> I read in one of the messages here that you came up with some
new
> trend indicator that seems to be better than PSAR. Could you
please
> point me to your relevant message concerning this indicator.
I am
> interested in this as PSAR is about the only indicator I have
some
> respect for.
>
> Thanks...
> Wally
>
>
>
>
>
>
> Yahoo! Groups Sponsor
>
>
>
>
>
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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.
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/YoVfrB/XP.FAA/uetFAA/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/
|