Thanks Apprentice. Sorry for the late reply but I have been away for a few days. This seems to be the best version yet. The only thing I have found is that it
MUST be used on a chart with 1 minute periods. If, for example, I use a 30 minute period the maximum level on a "normal" bar chart may be different to the correponding level on the range bar chart. One case I looked at had the "real" candle high = 1.64715 while the range bar high = 1.64523; a difference of 19.2 pips. But if you use the 1 minute period there doesn't seem to be a problem. And these bars load very quickly.

They don't seem to put much or any overhead on the drawing time.
I have already looked around the internet for other versions but could only find *.exe file for MT4; not the mq4 file. If you want to see another implementation why not look at the version used in Strategy Trader? You may be able to get the code for that? Those range bars seem to follow all the rules.
While the range bar indicator seems to work very well there is a problem when other indicators are also placed on the chart. For instance, if I also place a moving average on the chart it is initially placed in the correct position. But after every new range bar is formed the MA is not updated. Is there any way to fix this?
Also, when I draw a 10 pip range bar using a 1 minute timeframe I get about 35-40 bars. If I draw 20 pip range bars I only get about 5-10 bars on the chart. Is it possible to 'force' a number of bars to be drawn? My guess is that this is a function of the amount of 1 minute data read by default when the chart is populated, so we may have to live with this.
I think this version seems to follow all the rules.
Thanks again for your efforts.