boolean flag=true; if(flag){ if((iMA (_Symbol,TF2,35,0,MODE_EMA,PRICE_OPEN)> iMA (_Symbol,TF2,55,0,MODE_EMA,PRICE_OPEN)) && (iMA (_Symbol,TF1,50,0,MODE_EMA,PRICE_CLOSE)> iMA (_Symbol,TF1,55,0,MODE_EMA,PRICE_OPEN)) && (iMA (_Symbol,TF,35,0,MODE_EMA,PRICE_CLOSE)> iMA (_Symbol,TF,50,0,MODE_EMA,PRICE_OPEN))) { rule=1; flag=false; if(PositionsTotal()==0) OrderEntry(ORDER_TYPE_BUY,4); } switch(rule) { case 1: if((iMA (_Symbol,TF,35,0,MODE_EMA,PRICE_CLOSE)> iMA (_Symbol,TF,55,0,MODE_EMA,PRICE_OPEN))) { flag=true; MqlTradeRequest request={0}; MqlTradeResult result={0}; //--- parameters of request if(PositionsTotal()==0) OrderEntry(ORDER_TYPE_SELL,4); } break; default: break; } void OrderEntry(ENUM_ORDER_TYPE order_type,int pos_volume) { if(order_type==ORDER_TYPE_BUY) pos_price=SymbolInfoDouble(Symbol(),SYMBOL_ASK); if(order_type==ORDER_TYPE_SELL) pos_price=SymbolInfoDouble(Symbol(),SYMBOL_BID); //--- declare and initialize the trade request and result of trade request MqlTradeRequest request={0}; MqlTradeResult result={0}; //--- parameters of request ZeroMemory(request); ZeroMemory(result); request.action =TRADE_ACTION_DEAL; // type of trade operation request.symbol =Symbol(); // symbol request.volume =pos_volume; // volume of 0.1 lot request.type =order_type; // order type request.price =pos_price; // price for opening request.deviation=5; // allowed deviation from the price request.magic =EXPERT_MAGIC; // MagicNumber of the order //--- send the request if(!OrderSend(request,result)) PrintFormat("OrderSend error %d",GetLastError()); // if unable to send the request, output the error code //--- information about the operation