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

Re: Message pops up say can't divide by zero



PureBytes Links

Trading Reference Links

Robert,

This indicator was written by me about a year ago for an article in
Futures that discussed the Bollinger bands indicator (Nov. -97). It
normalizes the price to fluctuate around zero, with the upper
Bollingerband set to 100 and the lower band to -100, for easier
interpretation.

Alternative (and much better) code:

{Indicator name: $%B}
Input: Price(C), Length(18), SDev(2);
Vars: Upper(0), Lower(0), Where(0);
Upper = 100 * (Price - $Lowerband(Price, Length, SDev));
Lower = $Upperband(Price, Length, SDev) - $Lowerband(Price, Length,
SDev);
If Lower <> 0 Then
	Where = ((Upper / Lower) - 50) * 2;
Plot1(Where, "Where");
Plot2(100,"Upper");
Plot3(-100,"Lower");

{Function name: $Lowerband}
Input: Price(NumericSeries),Length(NumericSimple),SDev(NumericSimple);
$Lowerband = Average(Price, Length) - StdDev(Price, Length) * SDev

{Function name: $Upperband}
Input: Price(NumericSeries),Length(NumericSimple),SDev(NumericSimple);
$Upperband = Average(Price, Length) + StdDev(Price, Length) * SDev

Thomas Stridsman
Futures magazine