yes,
it does not work in that way. Fill the myClose with some sample data and than check the math. When the calculation will be ok will fix the first part.

delete the
StartDate= 20060101;
EndDate = 20060601;

BarPeriod = 15;

just plain c