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

BEWARE: The DMI is correct



PureBytes Links

Trading Reference Links



> -----Message d'origine-----
> De : Bengtsson, Mats [mailto:mats.bengtsson@xxxxxxxx]
> Envoyé : mardi 31 juillet 2001 21:35
> À : Patrick Gamble; pierre.orphelin@xxxxxxxxxxxxxx
> Cc : omega-list@xxxxxxxxxx; Bob Fulks
> Objet : RE: AW: TradeStation Precision - Summary with example
>
>
> This will be a lengthy mail, but not too many words, just my
> opinion "a bug is a bug", followed by the run of the Omega DMIPlus
function for one of my
> sybols compared with a dmi that should be a little more correct (only data
> shown is lines with precision errors). The symbol data has only three
> decimals as is standard in Omega. The output below is the second symbol
> printing with errors (the first was ericsson). The selected
> dmipluslength 5 is arbitrary, I guess by changing lengths the errors can
becomes
> smaller or greater, I have not tried to optimise in either direction.
>

Yes, I see the differences, and need to go into your code to explain them.
The bug has been craated by the "Better DMI", not the Omega DMI !

>
> LAPOB,Date990416,OmegaDMI,11.425,BetterDMI,15.599,diff,-4.174,diff
> percent,-2
> 6.76
> LAPOB,Date990419,OmegaDMI,9.061,BetterDMI,12.372,diff,-3.310,diffp
> ercent,-26
> .76
> LAPOB,Date990420,OmegaDMI,7.508,BetterDMI,10.251,diff,-2.743,diffp
> ercent,-26
> .76

And so on ( 26% I cant believe it!).

So lets see noxw what you did:


> {*******************************************************************
> Description: Directional Movement Index Plus
> Provided By: Omega Research, Inc. (c) Copyright 1999
> ********************************************************************}
>
> Inputs: Length(NumericSimple) ;
> Variables: Counter(0), TRange(0), MyRange(Length), PlusDM14(0), PlusDM(0),
> MinusDM(0);
> Var: OldDM14(0),OldPlusDm(0);
>
> If CurrentBar = 1 Then Begin
> 	MyRange = Length;
> 	MIBTest2 = 0;
> 	PlusDM14 = 0;
> 	OldDM14=0;
> 	TRange = 0;
> 	For Counter = 0 To MyRange - 1 Begin
> 		If High[Counter] - High[Counter+1] < 0 Then
> 			PlusDM = 0
> 		Else
> 			PlusDM = High[Counter] - High[Counter+1];
> 		If Low[Counter+1] - Low[Counter] < 0 Then
> 			MinusDM = 0
> 		Else
> 			MinusDM = Low[Counter+1] - Low[Counter];


Anyone can see that PusDM and MinusDM are sum values of raw price
difference, so the will never overflow the TS precison ( after 100,000 bars,
maybe...).

This also applies to price differences like If High[Counter] -
High[Counter+1] < 0 Then
 			PlusDM = 0
Price comparizon with 3, or 5 digits are not affected by the TS float 7
digit precision.

But anyway you decided to add a check condition that is bad designed,
dangerous and   worthless ( yourMIBGreaterEqual function)


> 		OldPlusDM=PlusDM;
> 		If MIBGreaterEqual(MinusDM,PlusDM) Then
> 			PlusDM = 0 ;

And this is where your error is!
================================
MinusDM,PlusDM having the requested price precision in TS, you function may
turn the comparizon into a false result because you added an epsilon to it
WHEN IT WAS NOT REQUESTED!!!!!!!!!
This means that when the result should have been correct in TS, your
function give a different result, setting Plusdm to 0 when it has not have
had to be set.

This obviously occus when MinusDM,PlusDM are STRICTLY equals in respect with
the price digit precision, but you function in this case turns the
difference to a non zero difference, so that the >= part of the condition is
turned into a > condition when it should be a = condition.

Same remark with the second part of the code when currentbar>1

150 posts to see this result, something sad on Omega List...

I only hope that when you analyse a trading system to write, you more
carefully examine the pro and the cons of your buy sell conditions and do
not only focus on the winning trades.
So why did you do that about the TS precision issue?
Becasue as most of the whiners, you wanted to demonstrate what was of your
interest, at any price.
And due to the poor critical point of view here when it has to come to
defend TRAD, none has verified your assumptions.

Excepted myself, as usual.

Useless to say that rewriting all the TS functions is a hint for the dustbin
hint (big model).



Sincerely,

Pierre Orphelin
www.sirtrade.com
TradeStation Technologies representative in France

Pensée su jour:
" Au pays des aveugles, les borgnes sont rois"






> 		if (MinusDm>=OldPlusDM) then
> 			OldPlusDM=0;
> 		{MinusDM not set to 0 because it is not used}
> 		TRange = TRange + TrueRange[Counter];
> 		PlusDM14 = PlusDM14 + PlusDM;
> 		OldDM14=OldDM14+OldPlusDM;
> 	End;
> 	If TRange <> 0 Then BEGIN
> 		MIBTest2 = (100 * PlusDM14 / TRange)-(100 * OldDM14 /
> TRange);
> 		if ((100 * PlusDM14 / TRange)-(100 * OldDM14 / TRange)<>0)
> then
>
> FileAppend("d:\temp\dmiError.csv",GetSymbolname+",Date"+numtostr(d
ate,0)+",O
> megaDMI,"+numtostr((100 * PlusDM14 /
> TRange),3)+",BetterDMI,"+numtostr((100
> * OldDM14 / TRange),3)+",diff,"+numtostr((100 * PlusDM14 / TRange)-(100 *
> OldDM14 / TRange),3)+",diffpercent,"+numtostr(((100 * PlusDM14 /
> TRange)-(100 * OldDM14 / TRange))/(100 * OldDM14 /
> TRange)*100,2)+newline);
> 	End
> 	Else
> 		MIBTest2 = 0 ;
> End
> Else
> 	If CurrentBar > 1 Then Begin
> 		If High[0] - High[1] < 0 Then
> 			PlusDM = 0
> 		Else
> 			PlusDM = High[0] - High[1];
> 		If Low [1] - Low [0] < 0 Then
> 			MinusDM = 0
> 		Else
> 			MinusDM = Low[1] - Low[0];
> 		OldPlusDM=PlusDM;
> 		If MIBGreaterEqual(MinusDM,PlusDM) Then
> 			PlusDM = 0;
> 		if (MinusDm>=OldPlusDM) then
> 			OldPlusDM=0;
> 		{MinusDM not set to 0 because it is not used}
> 		If MyRange > 0 Then Begin
> 			TRange = TRange[1] - (TRange[1] / MyRange) +
> TrueRange;
> 			PlusDM14 = PlusDM14[1] - (PlusDM14[1] / MyRange) +
> PlusDM;
> 			OldDM14=OldDM14[1] -(OldDM14[1]/MyRange)+OldPlusDM;
> 		End;
> 		If TRange <> 0 Then Begin
> 			MIBTest2 = (100 * PlusDM14 / TRange)-(100 * OldDM14
> / TRange);
> 			if ((100 * PlusDM14 / TRange)-(100 * OldDM14 /
> TRange)<>0) then
>
> FileAppend("d:\temp\dmiError.csv",GetSymbolname+",Date"+numtostr(d
ate,0)+",O
> megaDMI,"+numtostr((100 * PlusDM14 /
> TRange),3)+",BetterDMI,"+numtostr((100
> * OldDM14 / TRange),3)+",diff,"+numtostr((100 * PlusDM14 / TRange)-(100 *
> OldDM14 / TRange),3)+",diffpercent,"+numtostr(((100 * PlusDM14 /
> TRange)-(100 * OldDM14 / TRange))/(100 * OldDM14 /
> TRange)*100,2)+newline);
> 		End
> 		Else
> 			MIBTest2 = 0 ;
> 	End ;
>
>
> mibgreaterequal:
> Inputs: LeftValue(Numericsimple),RightValue(NumericSimple);
> MIBGreaterEqual=LeftValue>=(RightValue-MIBFloatCompareValue(LeftValue));
>
>
> mibfloatcomparevalue:
> Inputs: Value(Numericsimple);
> Var: AbsCurrentValue(0);
> AbsCurrentValue=absValue(Value);
> if (AbsCurrentValue<1) Then Begin
> 	MIBFloatCompareValue=0.0000005;
> End
> else if (AbsCurrentValue<10) Then Begin
> 	MIBFloatCompareValue=0.000005;
> End
> else if (AbsCurrentValue<100) Then Begin
> 	MIBFloatCompareValue=0.00005;
> End
> else if (AbsCurrentValue<1000) Then Begin
> 	MIBFloatCompareValue=0.0005;
> End
> else if (AbsCurrentValue<10000) Then Begin
> 	MIBFloatCompareValue=0.005;
> End
> else Begin
> 	MIBFloatCompareValue=0.05;
> End
>
> Indicator to output all of it:
> Plot mibtest2(5);
>