What I need: I would like to calculate the Standard Deviation of overnight returns on a 1 minute chart. i.e. For 3 days, Vol = Stdev( ln(Open(today)/Close(t-1)), ln(Open(t-1)/Close(t-2)), ln(Open(t-2)/Close(t-3)) ) * sqrt(260)
I took the code from VolatilityStdDev and clone it to make the following. It compiles OK however I get an error "Message: Error in study: Logarithm error." when plotting the function on a 1 minute chart.
Can someone point out the mistakes I made?
Code: Select all
inputs: NumDays( numericsimple ) ;
var0( SquareRoot( 260 ) ) ,
for j=0 to NumDays-1 begin
dayClose[j] = closeD(j);
dayOpen[j] = OpenD(j);
BL_CO_VOL = var0 * StandardDev( Log( OpenD(0) / dayClose ), NumDays, 1 ) ;