Why not using closed bars only? MA crossovers are closed bar MA crosses otherwise its re-drawing.
double x1=iMA(NULL,PERIOD_H1,24,0,MODE_EMA,PRICE_MEDIAN,0 );
double y1=iMA(NULL,PERIOD_H1,28,0,MODE_EMA,PRICE_MEDIAN,0 );
Yep! Thats the problem. Change 0 to 1 in the end so it will look like this:
double x1=iMA(NULL,PERIOD_H1,24,0,MODE_EMA,PRICE_MEDIAN,1 );
double y1=iMA(NULL,PERIOD_H1,28,0,MODE_EMA,PRICE_MEDIAN,1 );
and change the next MA crosses to 2 and 3 respectively.
Ralph you were correct here.
But its quite a funny way of using MA cross - "crossed up = true"

A different way would be checking last 2 bars (1 bar back, 2 bars back) and seeing if they crossed.
And yes, your program seems absurd

I use this:
if(lastMA<lastMA2) {
if(nowMA>nowMA2)
cross=1; } // cross up
else if(lastMA>lastMA2) {
if(nowMA<nowMA2)
cross=-1; } // cross down
Instead of huge blocks of code. Hope this helps