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 ) ;`

variables:

var0( SquareRoot( 260 ) ) ,

j(0);

Array:

dayClose[30](0),

dayOpen[30](0);

for j=0 to NumDays-1 begin

dayClose[j] = closeD(j);

dayOpen[j] = OpenD(j);

end;

BL_CO_VOL = var0 * StandardDev( Log( OpenD(0) / dayClose[1] ), NumDays, 1 ) ;