Annualized Volatility of the equity curve


I want to add the annualized volatility of the equity curve as a custom metric. This is the code that I use:


if( Status("action") == actionPortfolio )
    bo = GetBacktesterObject();

    bo.Backtest(); // run default backtest procedure

    st = bo.GetPerformanceStats(0); // get stats for all trades
	eq = bo.EquityArray;
	Volat = 16*100*StDev(ln( eq/Ref(eq,-1) ), BarCount -2  );
	// Here we add custom metric to backtest report
    bo.AddCustomMetric( "Volat (%) ", LastValue(Volat) );

When I set the period for the stdev i find that Barcount - 2 gives some values. Barcount -1 or Barcount don't return any values (zero).

I found Barcount - 2 with trial and error so I just want to confirm that I am calculating STDEV correctly for all bars.