Counting Periods

 

Has anyone had any experience with counting periods. I am trying to write code which will count the number of 1 minute periods. Can get the count of the first period, but not subsequent periods. Seem to be just swimming in circles.

int LTM=0,AB,AC,AD;

AB = LTM; //------ Past Period

{

LTM = Minute(); //------- Current Period

{
if(LTM > AB)
{AC = (LTM - AB);} //------ Convert Past and Present to Single Value

if(AC == 1)
{AD = AD + 1; AB = 0;} //------ If Condition met, Count Period, Reset Past Value
}

if(AC > 5)
{AC = 0;} //----- Reset Count

Alert(" LTM= ",LTM," AB= ",AB," AC= ",AC," AD= ",AD); //-------- AD is the Count of Periods

}

Thanks!

Yellowbeard

 

Ahhh! Figured it out! Here it is!

AB = LTM; //------ Past Period - Place right after int Start(); - Creates point when Past and Present don't equal

{

LTM = Minute(); //------- Current Period

{
if(LTM != AB) //------ When Past and Present don't equal, count
{AC = AC + 1;}

}

if(AC > 5) //------ When count exceeds 5 periods, reset count
{AC = 0;}


if(AC == 0) //----- Start count at 1
{AC = 1;}


Alert(" LTM= ",LTM," AB= ",AB," AC= ",AC); //-------- AC is the Count of Periods
}

Reason: