Can you upgrade to 9.x?
In that case it should as simple as:
Code:
select date,
avg("closePrice") over (partition by ticker order by date) rows between current row and 20 preceding
from "SecurityData"
where ticker = 'XYZ'
and date <= '2011-12-16'
order by date desc
The "rows between current row and 20 preceeding" clause was introduced in 9.0 and as far as I understand your question this is exactly what you need.