Question about MA (iMA) - Really easy one I guess

 

Hi all, 

 I'm trying to create a buy statement as if :

 MA2=iMA(NULL,0,12,0,MODE_SMA,PRICE_OPEN,1); 

 iClose(NULL,0,0)>MA2 

 

But every time I test it with strategy testing, it creates buy positions even if iClose lower than MA2.. How can I state that BUY ONLY if Bid > MA2 ?

 Thanks