Williams % R indicator code value at divide by 0

 

What does the WPR indicator do for a value when the difference between the highest and lowest is zero? Here is the calculation from the indicator.

//----Williams’ Percent Range calculation
   i = Bars - ExtWPRPeriod - 1;
   if(nCountedBars > ExtWPRPeriod) i = Bars - nCountedBars - 1;  
   while(i >= 0){
       double dMaxHigh = High[Highest(NULL, 0, MODE_HIGH, ExtWPRPeriod, i)];
       double dMinLow = Low[Lowest(NULL, 0, MODE_LOW, ExtWPRPeriod, i)];      
       if(!CompareDouble((dMaxHigh - dMinLow), 0.0))
           ExtWPRBuffer[i] = -100*(dMaxHigh - Close[i]) / (dMaxHigh - dMinLow);
       i--;
   }
 
Ruptor: What does the WPR indicator do for a value when the difference between the highest and lowest is zero?
It leaves the buffer[i] as it is. (Probably EMPTY_VALUE)
if(!CompareDouble(...)
 
I should change the wording of the question to what does the screen buffer make of it and what is the consequence for the display? On the screen it looks like the display buffer/filter combination assumes the same value as the previous point because the line doesn't appear to move. If the value was taken as zero or the enormous empty value was used the graph line would spike to zero or infinity but it doesn't.
 
EMPTY_VALUE nothing is displayed for that bar. The line gaps.
 
I haven't seen any gaps. The situation seems to happen often enough to see. It would make more sense to use the previous value instead of leaving a funny number in the indicator to prevent problems with EA usage getting duffy numbers.
 
Ruptor:

What does the WPR indicator do for a value when the difference between the highest and lowest is zero? Here is the calculation from the indicator.

What is your value for ExtWPRPeriod ?
 
13 for the period but I can't see why that matters? An empty value in any indicator would stuff any EA that was reading it unless it was handled wouldn't it. Gaps are bad news.
 
Ruptor:
13 for the period but I can't see why that matters? An empty value in any indicator would stuff any EA that was reading it unless it was handled wouldn't it. Gaps are bad news.
Have you already seen the highest high and the lowest low of 13 candles of a forex chart being equals ? Don't waste your time with theoretical issues.
 
It is not a waste of time to identify all possible sources of error as any good engineer will tell you. This indicator also has the problem of a bias because it allows limitless negative excursions but has a ceiling to positive values of zero so it if it is filtered this would make the bias worse.
Reason: