PureBytes Links
Trading Reference Links
|
David,
I enjoyed reading thru your code. I have often thought of removing the
duplicate looping that occurs in using this indicator in order to reduce
computation times.
I thought it interesting that when I overlaid your indicator on top of the
ADX in the library there were small variances, in amplitude, with some
possibly significant divergences. For example, MSFT 30min bars 7/10/00 and
8/03/00. Most of the stocks in my small sampling showed no variance.
The differences are probably insignificant for most applications(?)
I wonder what the determining factor is.
Eric Svendsen
----- Original Message -----
From: david b. stanley <davestan@xxxxxxxxxx>
To: <omega-list@xxxxxxxxxx>
Sent: Wednesday, August 09, 2000 4:12 PM
Subject: ADX w/o Functions
> There was some discussion a couple of weeks ago on ADX and the
> code space problems it causes.
> I took all the related functions ADX uses to calculate and incoporated
>
> them into the ADX code itself thus reducing the redundancy of the
> separate functions. WYSIWYG when using it this way. There are
> no hidden function calls other than "absvalue" and "currentbar".
> The code is in indicator form. The only input is "Length" which is
> set to a default of 14.
>
> dbs
>
> {
> Indicator: ADX_
>
> Calculates and plots ADX with no function calls to
> DMIPlus
> DMIMinus
> DMI
> ADX.
>
> last update: 8/9/2000
>
> code by: david b. stanley
>
> *****************************************}
>
> inputs:
> Length(14);
>
> vars:
> Counter(0),
> TRange(0), MyRange(Length),
> PlusDM(0),MinusDM(0),
> Plus14(0),
> Minus14(0),
> DMIup(0),DMIdn(0),
> DMI_(0),
> CummDMI(0), Return(0),
> ADX_(0);
>
> {ZZZZZZZZZZZZ...DMIup/DMIdn...ZZZZZZZZZZZZZ}
>
> if CurrentBar = 1 then begin
>
> MyRange = Length;
> DMIup = 0;
> Plus14 = 0;
> Minus14 = 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];
>
> if MinusDM >= PlusDM then PlusDM = 0;
> if PlusDM >= MinusDM then MinusDM = 0;
>
> TRange= TRange + TrueRange[Counter] ;
>
> Plus14 = Plus14 + PlusDM ;
> Minus14 = Minus14 + MinusDM ;
>
> end;{...counter=0 to myrange-1}
>
> if TRange <> 0 then begin
> DMIup = 100 * Plus14 / TRange;
> DMIdn = 100 * Minus14 / TRange;
> end
> else begin
> DMIup = 0 ;
> DMIdn = 0;
> end;
>
> end{...currentbar=1}
>
> 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];
>
> if MinusDM >= PlusDM then PlusDM = 0;
> if PlusDM >= MinusDM then MinusDM = 0;
>
> if MyRange > 0 then begin
> TRange = TRange[1] - (TRange[1] / MyRange) + TrueRange;
> Plus14 = Plus14[1] - (Plus14[1] / MyRange) + PlusDM;
> Minus14 = Minus14[1] - (Minus14[1] / MyRange) + MinusDM;
> end;
>
> if TRange<>0 then begin
> DMIup = 100 * Plus14 / TRange;
> DMIdn = 100 * Minus14 / TRange;
> end
> else begin
> DMIup = 0;
> DMIdn = 0;
> end;
>
> end;{...currentbar>1}
>
>
> {ZZZZZZZZZZZZZZZ...DMI_...ZZZZZZZZZZZZZZZZ}
>
> if DMIup + DMIdn= 0 then DMI_ = 0
> else
> DMI_ = 100 * AbsValue(DMIup - DMIdn)
> / (DMIup + DMIdn);
>
>
> {ZZZZZZZZZZZ...ADX_...ZZZZZZZZZZZZZ}
>
> Return = 0 ;
>
> if CurrentBar >= 1 and Length > 0 then begin
>
> if CurrentBar < Length then begin
> CummDMI = 0 ;
> for Counter = 0 to CurrentBar - 1 begin
> CummDMI = CummDMI + DMI_[Counter] ;
> end ;
> Return = CummDMI / CurrentBar ;
> end
> else
> Return = (ADX_[1] * (Length - 1) + DMI_) / Length ;
>
> end ;
>
> ADX_ = Return ;
>
>
> {ZZZZZZZZZZZZ...Plot...ZZZZZZZZZZZZZ}
>
>
> plot1(adx_,"adx");
>
|