ADX opening condition doesn't work??? help please

 
Hello
could someone please help me with this. I can't understand.
I'm developing a expert working with MA but I only want to open a trade if the ADX is above a certain level.
I tried several ways to put that condition for entering trades and all of them somehow make that the expert never opens any trades.
It opens trades without the (ADX>x) condition, but as soon as I try to only allow to enter trades when ADX above x
here's one example of a way I tried to put the ADX condition in:


currFema=iMA(NULL, 0, FastEma, 0, MODE_EMA, PRICE_CLOSE, 1);
lastFema=iMA(NULL, 0, FastEma, 0, MODE_EMA, PRICE_CLOSE, lastbars);
beforeFema=iMA(NULL, 0, FastEma, 0, MODE_EMA, PRICE_CLOSE, lastbars+1);
previousFema=iMA(NULL, 0, FastEma, 0, MODE_EMA, PRICE_CLOSE, 2);
currSema=iMA(NULL, 0, SlowEma, 0, MODE_EMA, PRICE_CLOSE, 1);
lastSema=iMA(NULL, 0, SlowEma, 0, MODE_EMA, PRICE_CLOSE, lastbars);
beforeSema=iMA(NULL, 0, SlowEma, 0, MODE_EMA, PRICE_CLOSE, lastbars+1);
TrendSma=iMA(NULL, 0, TrendSma, 0, MODE_SMA, PRICE_CLOSE, 0);
ADX=iADX(NULL, 0, ADX, PRICE_CLOSE,MODE_MAIN,1);
lastADX=iADX(NULL, 0, ADX, PRICE_CLOSE,MODE_MAIN,2);



//---- check for open buy order
if((lastFema>lastSema && beforeFema<beforeSema) &&(currFema>currSema && currFema>previousFema)&& ADX>adxline)
{
res=OrderSend(Symbol(),OP_BUY, Lots, Ask,5, LongTS, 0, "", perfectorder, 0,Blue);
return;
}
etc

the adxline is a external variable.

I can compile it fine. but ince I test it no trades are open. obviously I checked if with the given conditions if it should open trades, on a chart, and it should. I tried to put the ADX condition here:


if(ADX>adxline)
{
//---- check for open buy order
if((lastFema>lastSema && beforeFema<beforeSema) &&(currFema>currSema && currFema>previousFema)&& ADX>adxline)
{
res=OrderSend(Symbol(),OP_BUY, Lots, Ask,5, LongTS, 0, "", perfectorder, 0,Blue);
return;
}
etc.

nothing seems to work. if someone can please help I thank you very much
 
Please give me a full code and one else use the button "MQL" for imput your code  into the form.