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

Re: Divergence



PureBytes Links

Trading Reference Links

<<<
Dear Traders

Wondering if anyone may have the ela code for an indicator that will show
divergence between price and an oscillator or second data stream. I know TS
has one however i have found it to be less than reliable. Thanks in advance

Gaston
>>>

An elementary approach would be to establish new tops and new bottoms
at the event of your oscillator crossing it's midpoint and then record new
highs or lows as they occur. Something like the following and assuming
the midpoint of your oscillator is 0.

dave stanley

vars:
osc(0),
oscT1(0),oscT2(0),oscT3(0),oscB1(0),oscB2(0),oscB3(0),
priceT1(0),priceT2(0),priceT3(0),priceB1(0),priceB2(0),priceB3(0);

osc={...place your oscillator formula here...};

{...create new tops and bottoms...}

if osc crosses above 0 then begin
  oscT3=osct2;oscT2=oscT1;oscT1=osc;
  priceT3=priceT2;priceT2=priceT1;priceT1=H;
end;{...osc crosses above 0...}

if osc crosses below 0 then begin
  oscB3=oscB2;oscB2=oscB1;oscB1=osc;
  priceB3=priceB2;priceB2=priceB1;priceB1=L;
end;{...osc crosses below 0...}

{...increase tops and bottoms...}

if  osc>0 then begin
  if osc>oscT1 then oscT1=osc;
  if H>priceT1 then priceT1=H;
end;{...osc>0...}

if osc<0 then begin
  if osc<oscB1 then oscB1=osc;
  if L<priceB1 then priceB1=L;
end;{...osc<0...}

{
You now have the last 3 tops and bottoms of both the oscillator
and price stored away (assuming the oscillator has crossed 0
a total of 6 times
}
{
You can use these tops and bottoms for divergence comparison.
You can also use them in conjunction with the highest() and lowest()
functions as described in your EL manual.
i.e.
if highest(osc,28)<oscT1 and highest(H,28)=priceT1 then begin
  {...perform something here...}
end;
}
{
Warning: Be careful in your comparison calculations that you already
have a previous top or bottom to compare the current one to. Otherwise
you will be comparing it to 0. Nest your code for these comparisons
as follows....

if oscB2>0 then begin
end;
}