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

Re: Why am I getting a divide-by-zero error?



PureBytes Links

Trading Reference Links

>I have a function called CMO on my system. I assume this is the one to
which you are referring. It is very simple:
>
>   CMO = 100*((C-C[Length])/(Summation(AbsValue((C-C[1])), Length)))
>
>There obviously is no divide-by-zero check.
>
>If you change it to:
>
>   Value1 = Summation(AbsValue((C - C[1])), Length);
>   if Value1 <> 0 then CMO = 100 * (C - C[Length]) / Value1;
>
>this should fix the problem.

Many thanks.  The original formula is the one I've been using.
I'm not sure why adding the divide-by-zero check would cure
my comparison problem when the original oscillator plots
just fine, but I'll give it a try.  At the absolute least, this version
of CMO is clearly better than the original.

Thanks again.

Owen Davies