EA opening multiple trades after a condition is met

 

Can someone help me please? I have this code that will open a buy trade when this condition is met but the problem is, as long as the ema 10, 23, 32 and cross up it wont stop opening positions until they cross down. How can I stop this and only have the ea open one position when the condition is met and then will only open another when the same condition is met a second time?


 if((iMAMQL4(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,0)>iMAMQL4(NULL,0,23,0,MODE_EMA,PRICE_CLOSE,0))&&(iMAMQL4(NULL,0,32,0,MODE_EMA,PRICE_CLOSE,0)>iMAMQL4(NULL,0,55,0,MODE_EMA,PRICE_CLOSE,0))) // Here is your open buy rule

     {
     OrderSelect(0,SELECT_BY_POS);
     orderC
        if(StopLoss>0) TheStopLoss=SymbolInfoDouble(_Symbol,SYMBOL_ASK)-StopLoss*MyPoint;
        if(TakeProfit>0) TheTakeProfit=SymbolInfoDouble(_Symbol,SYMBOL_ASK)+TakeProfit*MyPoint;
        trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,Lots,SymbolInfoDouble(_Symbol,SYMBOL_ASK),TheStopLoss,TheTakeProfit);
        return;
 
Please edit your post and use the code button (Alt+S) when pasting code.

EDIT your original post, please do not just post the code correctly in a new post.

Please only post code that will compile.

 

Do not double post!

I have deleted your duplicate.

Reason: