PureBytes Links
Trading Reference Links
|
Hi
Jayson,Maybe Tomasz can crack
this?Yuki
<SPAN
class=093321914-07082003>
<SPAN
class=093321914-07082003>Perhaps Jayson can.....
<SPAN
class=093321914-07082003>
The
problem appears to be in the iif statements....... IIf<FONT
size=2>( C > <FONT
size=2>Ref( C<FONT
size=2>, -1 ) , ( <FONT
size=2>C - Ref(
C ,-<FONT
size=2>1 ) ) ,0 ) ,5<FONT
color=#282828 size=2> )
by
changing 0 to a very small number greater than 0 (.00001) the problem solves
itself...... If you reach the same conclusion I will update the
library....
<SPAN
class=093321914-07082003>
<SPAN
class=093321914-07082003>jayson
<SPAN
class=093321914-07082003>
<SPAN
class=093321914-07082003>
<SPAN
class=093321914-07082003>
<FONT
color=#008000 size=2>
//Dynamic Momentum Index Tushar Chande Translated to
AFL by Jayson Casavant
//Cmo5 formula
CMO5_1=Sum( <FONT
size=2>IIf( C<FONT
size=2> > Ref( <FONT
size=2>C, -1 ) ,
( C - <FONT
size=2>Ref( C
,-1 ) ) ,.00001 ) ,<FONT
size=2>5 )
;
CMO5_2=Sum( <FONT
size=2>IIf( C<FONT
size=2> < Ref( <FONT
size=2>C ,-1 ) ,
( Ref( <FONT
size=2>C ,-1 ) -
C ) ,.00001 ) ,<FONT
size=2>5
);
CMO5=DEMA(<FONT
size=2>100 * (( CMO5_1 -CMO5_2) /(
CMO5_1+CMO5_2)),3<FONT color=#282828
size=2>);
//Cmo10 formula
CMO10_1=Sum( <FONT
size=2>IIf( C<FONT
size=2> > Ref( <FONT
size=2>C, -1 ) ,
( C - <FONT
size=2>Ref( C
,-1 ) ) ,.00001 ) ,<FONT
size=2>10 )
;
CMO10_2=Sum( <FONT
size=2>IIf( C<FONT
size=2> < Ref( <FONT
size=2>C ,-1 ) ,
( Ref( <FONT
size=2>C ,-1 ) -
C ) ,.00001 ) ,<FONT
size=2>10
);
CMO10=DEMA(<FONT
size=2>100 * (( CMO10_1 -CMO10_2) /(
CMO10_1+CMO10_2)),3<FONT color=#282828
size=2>);
//Cmo20 formula
CMO20_1=Sum( <FONT
size=2>IIf( C<FONT
size=2> > Ref( <FONT
size=2>C, -1 ) ,
( C - <FONT
size=2>Ref( C
,-1 ) ) ,.00001 ) ,<FONT
size=2>20 )
;
CMO20_2=Sum( <FONT
size=2>IIf( C<FONT
size=2> < Ref( <FONT
size=2>C ,-1 ) ,
( Ref( <FONT
size=2>C ,-1 ) -
C ) ,.00001 ) ,<FONT
size=2>20
);
CMO20=DEMA(<FONT
size=2>100 * (( CMO20_1 -CMO20_2) /(
CMO20_1+CMO20_2)),3<FONT color=#282828
size=2>);
// dmi formula
dmi=((StDev(<FONT
size=2>C,5<FONT
size=2>)* CMO5)+(StDev(<FONT
size=2>C,10)*
CMO10)+(StDev(<FONT
size=2>C,20<FONT
color=#282828 size=2>)*
CMO20))/(StDev(<FONT
size=2>C,5<FONT
size=2>)+StDev(<FONT
size=2>C,10<FONT
size=2>)+StDev(<FONT
size=2>C,20<FONT
color=#282828 size=2>));
pds=Param(<FONT
size=2>"Smoothing",3<FONT
size=2>,1,<FONT
size=2>10,1<FONT
color=#282828 size=2>);
pds1=Param(<FONT
size=2>"Trigger Line",5<FONT
size=2>,1,<FONT
size=2>10,1<FONT color=#282828
size=2>);
Plot(<FONT color=#0000ff
size=2>EMA(dmi,pds),<FONT color=#ff00ff
size=2>"Dynamic Momentum Index"<FONT color=#282828
size=2>,colorWhite<FONT
color=#282828 size=2>,1<FONT
color=#282828 size=2>);
Plot(<FONT color=#0000ff
size=2>MA(dmi,pds1),<FONT color=#ff00ff
size=2>"trigger",<FONT color=#000000
size=2>colorYellow,<FONT
color=#ff00ff size=2>1);
Buy=Cross<FONT
size=2>(EMA(dmi,pds),<FONT
size=2>MA<FONT
color=#0000ff>(dmi,pds1));<FONT
color=#0000ff>
Sell=<FONT
size=2>Cross(MA<FONT
size=2>(dmi,pds1),EMA<FONT color=#282828
size=2>(dmi,pds));
PlotShapes(<FONT color=#0000ff
size=2>IIf(<FONT color=#000000
size=2>Buy,<FONT color=#000000
size=2>shapeUpArrow,<FONT
color=#000000 size=2>shapeNone)
,colorBrightGreen<FONT
color=#282828 size=2>);
PlotShapes(<FONT color=#0000ff
size=2>IIf(<FONT color=#000000
size=2>Sell,<FONT color=#000000
size=2>shapeDownArrow,<FONT
color=#000000 size=2>shapeNone<FONT color=#282828
size=2>),colorRed<FONT
color=#282828 size=2>);
PlotGrid(<FONT color=#ff00ff
size=2>70,<FONT color=#000000
size=2>colorRed);<FONT
color=#0000ff size=2>
PlotGrid(<FONT color=#ff00ff
size=2>30,<FONT color=#000000
size=2>colorBrightGreen);
<FONT face=Tahoma
size=2>-----Original Message-----From: Yuki Taga
[mailto:yukitaga@xxxxxxxxxxxxx]Sent: Thursday, August 07, 2003 6:01
AMTo: JaysonSubject: Re: [amibroker] Re: DMI
problemHi Jayson,Maybe Tomasz can crack
this?YukiThursday, August 7, 2003, 12:50:33 AM, you
wrote:J> I am just getting back from watching the Tennis Master
tournament up inJ> Montreal so am a bit bogged down here. The code I
posted was simplyJ> translated from MS....... I will try to figure it out
later in the day. IJ> qouls have guessed that DT was on the right path I
will experiment with theJ> smoothing.......J>
Regards,J> JaysonJ> -----Original Message-----J> From:
DIMITRIS TSOKAKIS [mailto:TSOKAKIS@xxxxxxxxx]J> Sent: Wednesday, August
06, 2003 7:15 AMJ> To: amibroker@xxxxxxxxxxxxxxxJ> Subject:
[amibroker] Re: DMI problemJ> It is strange.J> The huge
dmi inJ> dmi=((StDev(C,5)* CMO5)+(StDev(C,10)*
CMO10)+(StDev(C,20)*CMO20))/J>
(StDev(C,5)+StDev(C,10)+StDev(C,20));J> is not because of some very small
denominator [usual reason], but isJ> due to a huge numerator.J> In
this numerator, the huge is the CMO5 and inJ> CMO5=DEMA(100 * (( CMO5_1
-CMO5_2) /( CMO5_1+CMO5_2)),3);J> we do not have very small denominator,
the whole 100 * (( CMO5_1 -J> CMO5_2) /( CMO5_1+CMO5_2)) is cool, the
DEMA(...,3) makes the hugeJ> value.J> You should cancel CMO5 from
the formula, or limit it in the [-J> 100,100] interval.J> So,
replace the first lines withJ> //Cmo5 formulaJ> CMO5_1=Sum( IIf( C
> Ref( C, -1 ) , ( C - Ref( C ,-1 ) ) ,0 ) ,5 ) ;J> CMO5_2=Sum( IIf( C
< Ref( C ,-1 ) , ( Ref( C ,-1 ) - C ) ,0 ) ,5 );J> CMO5=DEMA(100 * ((
CMO5_1 -CMO5_2) /( CMO5_1+CMO5_2)),3);J>
CMO5=IIf(CMO5>100,99,CMO5);J>
CMO5=IIf(CMO5<-100,-99,CMO5);J> //Cmo10 formulaJ> CMO10_1=Sum(
IIf( C > Ref( C, -1 ) , ( C - Ref( C ,-1 ) ) ,0 ) ,10 ) ;J>
CMO10_2=Sum( IIf( C < Ref( C ,-1 ) , ( Ref( C ,-1 ) - C ) ,0 ) ,10
);J> CMO10=DEMA(100 * (( CMO10_1 -CMO10_2) /(
CMO10_1+CMO10_2)),3);J> CMO10=IIf(CMO10>100,99,CMO10);J>
CMO10=IIf(CMO10<-100,-99,CMO10);J> //Cmo20 formulaJ>
CMO20_1=Sum( IIf( C > Ref( C, -1 ) , ( C - Ref( C ,-1 ) ) ,0 ) ,20 )
;J> CMO20_2=Sum( IIf( C < Ref( C ,-1 ) , ( Ref( C ,-1 ) - C ) ,0 ) ,20
);J> CMO20=DEMA(100 * (( CMO20_1 -CMO20_2) /(
CMO20_1+CMO20_2)),3);J> CMO20=IIf(CMO20>100,99,CMO20);J>
CMO20=IIf(CMO20<-100,-99,CMO20);J> Now we have just a few problems
with 8308, 5406 and 1861.J> I noticed that there are also some
EMA(dmi,pds) {empty} values !!!!!!!J> I give up, Jason should look at the
formula again !!!J> Dimitris TsokakisJ> --- In
amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx>J>
wrote:>> I run the same for the ^N225 database and [!!] many
examplesJ> appeared.>> Let me search please and
revert.>> Dimitris Tsokakis>> --- In
amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS"J>
<TSOKAKIS@xxxx>>> wrote:>> > Yuki,>> >
I added to your formula>> > Filter=1;>> >
AddColumn(Highest(EMA(DMI,PDS)),"DMIh");>> >
AddColumn(Lowest(EMA(DMI,PDS)),"DMIl");>> >
AddColumn(Highest(MA(DMI,PDS1)),"TRIGGERh");>> >
AddColumn(Lowest(MA(DMI,PDS1)),"TRIGGERl");>> > and explored for
the n=1 last quotations the whole N100 database>> from>>
> Jan2000 till now.>> > No value was found out of the [-100,100]
range.>> > [101*900 different bars]>> > Dimitris
Tsokakis>> > --- In amibroker@xxxxxxxxxxxxxxx, Yuki Taga
<yukitaga@xxxx> wrote:>> > > I attach two charts, both
displaying DMI as described by Jason:>> > >>> >
> //Dynamic Momentum Index Tushar Chande Translated to AFL
by>> Jayson>> > Casavant>> > > //Cmo5
formula>> > > CMO5_1=Sum( IIf( C > Ref( C, -1 ) , ( C - Ref(
C ,->> 1 ) ) ,0 ) ,5 ) ;>> > > CMO5_2=Sum( IIf( C <
Ref( C ,-1 ) , ( Ref( C ,-1 ) ->> C ) ,0 ) ,5 );>>
> > CMO5=DEMA(100 * (( CMO5_1 -CMO5_2) /(
CMO5_1+CMO5_2)),3);>> > >>> > > //Cmo10
formula>> > > CMO10_1=Sum( IIf( C > Ref( C, -1 ) , ( C - Ref(
C ,->> > 1 ) ) ,0 ) ,10 ) ;>> > > CMO10_2=Sum( IIf(
C < Ref( C ,-1 ) , ( Ref( C ,-1 ) ->> > C ) ,0 ) ,10
);>> > > CMO10=DEMA(100 * (( CMO10_1 -CMO10_2) /(
CMO10_1+CMO10_2)),3);>> > >>> > > //Cmo20
formula>> > > CMO20_1=Sum( IIf( C > Ref( C, -1 ) , ( C - Ref(
C ,->> > 1 ) ) ,0 ) ,20 ) ;>> > > CMO20_2=Sum( IIf(
C < Ref( C ,-1 ) , ( Ref( C ,-1 ) ->> > C ) ,0 ) ,20
);>> > > CMO20=DEMA(100 * (( CMO20_1 -CMO20_2) /(
CMO20_1+CMO20_2)),3);>> > >>> > > // dmi
formula>> > > dmi=((StDev(C,5)* CMO5)+(StDev(C,10)*
CMO10)+(StDev(C,20)*>> > >
CMO20))/(StDev(C,5)+StDev(C,10)+StDev(C,20));>> > >
pds=Param("Smoothing",3,1,10,1);>> > > pds1=Param("Trigger
Line",5,1,10,1);>> > >>> > >
Plot(EMA(dmi,pds),"Dynamic Momentum Index",colorDarkGreen,1);>> >
> Plot(MA(dmi,pds1),"trigger",colorRed,1);>> > >>>
> > Buy=Cross(EMA(dmi,pds),MA(dmi,pds1));// AND Trend;>> >
> Sell=Cross(MA(dmi,pds1),EMA(dmi,pds));// AND NOT (Trend);>> >
> PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBrightGreen);>>
> > PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed);>>
> >>> > > What is the difference in these two DMI
plots? I simplyJ> scrolled>> > the>> >
> screen one date to the right.>> > >>> > > I
have this problem with several stocks, but the date that the>> >
> indicator goes haywire on is not the same for any of them. IJ>
also>> > > cannot find anything wrong with the data on the date
that the>> > > indicator goes nuts. It is data that is
right in line with both>> > > price and volume, not
extraordinary in any way. But theJ> indicator>> > >
becomes worthless, suddenly.>> > >>> > > Can
anyone clue me in here?>> > >>> > >
YukiSend
BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
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.
|