PureBytes Links
Trading Reference Links
|
Jim,
The effect originates in the recursive nature of the XAverage. The cause
can be eliminated by calculating the ratio outside of the function. The
resulting value is then passed to the exponential average.
Here is a sample of the EasyLanguage you could use to modify the technique.
Inputs:
UpVol(close of data2),
DnVol(close of data3),
FstLen(19), SlwLen(39);
Vars:
McOsc(0);
if DnVol <> 0 then
Value1 = UpVol / DnVol ;
McOsc = XAverage(Value1, FstLen) - XAverage(Value1, SlwLen) ;
If McOsc >= McOsc[1] then
Plot1(McOsc,"McOsc");
If McOsc < McOsc[1] then
Plot2(McOsc, "McOsc.");
Plot3(0, "ZLine");
Best regards,
Benjamin Blanco
http://www.blancofamily.net/ezlang.htm
----- Original Message -----
From: "Jim Johnson" <jejohn@xxxxxxxxxxx>
To: "Omega List" <omega-list@xxxxxxxxxx>
Sent: Thursday, August 29, 2002 4:12 PM
Subject: division by zero error
Hello Omega List,
I'm trying to write a version of McClellan Oscillator that uses the
ratio of Up Volume to Down Volume instead of the difference. This
code keeps giving a division by zero error--but I can't see it.
Suggestions? thanks.
{---------------------------}
{ bars above 0 are plotted green and below 0 are plotted red.}
Inputs: UpVol(close of data2), DnVol(close of data3), FstLen(19),
SlwLen(39);
Vars: McOsc(0);
McOsc = IFF(DnVol <> 0, XAverage(UpVol / DnVol, FstLen) -
XAverage(UpVol / DnIss, SlwLen), 0);
If McOsc >= McOsc[1] then
Plot1(McOsc,"McOsc");
If McOsc < McOsc[1] then
Plot2(McOsc, "McOsc.");
Plot3(0, "ZLine");
{-----------------------------}
--
Best regards,
Jim Johnson mailto:jejohn@xxxxxxxxxxx
|