Using the code below, a security with exactly 20 bars of data produces SD output for 20 periods as all zero, with 18 periods only SD3 calculates, but it takes 10 periods for SD2 and SD1 to calculate. This happens also on securities with > 200 bars. What am I missing here?

```
function C_2_C( n, _close )
{
_ret = log( _close ) - log( Ref( _close, -1 ) );
_avg = 1 / n * Sum( _ret, n );
_vol = 1 / ( n - 1 ) * Sum( ( _ret - _avg ) ^ 2, n );
return _vol;
}
function Yang_Zhang_Vol( n, _open, _high, _low, _close )
{
_N_o = log( _open ) - log( Ref( _close, -1 ) ); // normalized open
_N_u = log( _high ) - log( _open ); // normalized high
_N_d = log( _low ) - log( _open ); // normalized low
_N_c = log( _close ) - log( _open ); // normalized close
V_rs = 1 / n * Sum( _N_u * ( _N_u - _N_c ) + _N_d * ( _N_d - _N_c ), n ); // RS volatility estimator
_N_o_avg = 1 / n * Sum( _N_o, n );
V_o = 1 / ( n - 1 ) * Sum( ( _N_o - _N_o_avg ) ^ 2, n );
_N_c_avg = 1 / n * Sum( _N_c, n );
V_c = 1 / ( n - 1 ) * Sum( ( _N_c - _N_c_avg ) ^ 2, n );
k = 0.34 / ( 1.34 + ( n + 1 ) / ( n - 1 ) );
V_yang_zhang = V_o + k * V_c + ( 1 - k ) * V_rs;
return V_yang_zhang;
}
Periods = Min( LastValue(BarCount-1), 200 );
SD1 = sqrt( Yang_Zhang_Vol( Periods, O, H, L, C ) ) * sqrt( 252 );
SD2 = sqrt(C_2_C(Periods,C)) * sqrt(252);
SD3 = StDev(log(C/Ref(C,-1)),Periods) * sqrt(252);
```