Interactive formulas

E

energydoc

I am calculating a rolling historical volatility for a series of commodity
returns, using the following formula =STDEV(D6:D35)*SQRT(252)
I want to be able to type in the # of days back to go (e.g. in the example
above, it is a 30-day rolling stdev) in the cell above the top value. That
is, I want to be able to type "50" into the cell and have the formula update
to STDEV(D6:D55)*SQRT(252) automatically.
 
P

Pete_UK

Assuming you enter the number of days in A1, try this:

=IF(A1>0,STDEV(INDIRECT("D6:D"&A1+5)*SQRT(252),0)

This returns 0 if A1 is blank - you might also want to set some
maximum for A1, such as:

=IF(AND(A1>0,A1<100),STDEV(INDIRECT("D6:D"&A1+5)*SQRT(252),0)

Hope this helps.

Pete
 
A

Arvi Laanemets

Hi

=STDEV(OFFSET($D$6,,,$X$1,1)*SQRT(252)

, where cell X1 contains the number of days
 
H

Harlan Grove

Arvi Laanemets said:
=STDEV(OFFSET($D$6,,,$X$1,1)*SQRT(252)
....

OFFSET is a volatile function, so it recalcs all the time. One nonvolatile
alternative would be

=STDEV($D$6:INDEX($D:$D,$X$1+5))*SQRT(252)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top