Interdum stultus opportuna loquitur...

Thursday, July 28, 2005

ChartRant: AD Hairball Feedback...

Note - from June 24th 2009, this blog has migrated from Blogger to a self-hosted version. Click here to go straight there.

A couple of folks have e-mailed and pointed out that the Commodity RantCharts generated a 'Division by Zero Error' when they tried to chart the Australian Dollar.

This was caused by the fact that the Commodities chart only uses the current front-month futures; at the start of the chart data (80 trading days ago) the current front-month did not trade. This means that in the data, the high and the low are the same - which causes a hairball the formula for the %R for the very first observation on the chart (the rest of the data is perfectly fine, and so is the final chart).

The formula  is

%R = 1-(C-L14)(H14-L14)


H14 is the highest high in the last 14 periods, and

L14 is the lowest low in the same timeframe.

If the two are equal (which by chance they are, in this dataset) it produces a divide by zero error. I've changed the code so that it simply starts the %R one period further on if it encounters this problem.