buy/sell on 2 ma interception.

 
 

I want a simple indicator that buys when aqua intercepts red from down.and sells when aqua intercepts red from up.

 
static int enson;


 
 double uc=iMA(NULL,0,4,0,MODE_SMA,PRICE_CLOSE,0);
 double odo=iMA(NULL,0,14,0,MODE_SMA,PRICE_CLOSE,0);


 if ((enson==-1  && uc>odo)  ) {   
  BuyValue=1; 
}
if ((enson==1  && uc<odo  )  ) {     
SellValue=1; 
}  
if (uc < odo) {enson =-1;}
if (uc >odo) { enson =1;}
if(OrdersHistoryTotal()==0 || OrdersHistoryTotal()-1==0){
 if ((enson==-1  && uc>odo)  ) {   
  BuyValue=1;
 }
 if ((enson==1  && uc<odo )  ) {     
SellValue=1; 
}  } 
here I tried but..
 
 if(TimeCurrent()>lasttradetime + 3600){
 
 double uc=iMA(NULL,0,4,0,MODE_SMA,PRICE_CLOSE,0);
 double odo=iMA(NULL,0,21,0,MODE_SMA,PRICE_CLOSE,0);
 if(uc==odo){zaman=TimeCurrent();}
 if(TimeCurrent()>zaman + 2)
 {
 if (uc>odo && !kard==1)
 {BuyValue=1;
 if(kard==1){BuyValue=0;}}
 if (odo>uc&& !kard==-1)
 {SellValue=1;
 if(kard==-1){SellValue=0;}}
 }

again didt work on exact interception??
Reason: