First ... let take a look sample code on ur open buy rule :
--> iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,0)>iMA(NULL,0,100,0,MODE_EMA,PRICE_CLOSE,0)
above code mean EMA4 > EMA100 not EMA4 crossing EMA100
Second.. U need EMA4 and EMA100 at previous candle to determine its cross or not ...