Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello, am new to mql4, i need some help with this code to trade opposite
the ea place pending order and modify the pending order until it takes a trade..
so i double paste the order code for it to trade opposite but still no opposite trade
{ if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if(OrderMagicNumber()==Magic) { odty=OrderType(); if(odty==OP_BUYLIMIT || odty==OP_SELLLIMIT) continue; if(OrderSymbol()==Symbol()) { z++; switch(odty) { case OP_SELL: if(TrailingStop<0) break; st=NormalizeDouble(OrderStopLoss(),NDigits); p2=NormalizeDouble(Bid-trail,NDigits); if(!((st==0.0 || p2>st))) break; ordmdf=OrderModify(OrderTicket(),OrderOpenPrice(),p2,OrderTakeProfit(),0,Blue); if(!(!ordmdf)) break; Print("Order Modify Error",(GetLastError())); break; case OP_BUY: if(TrailingStop<0) break; st=NormalizeDouble(OrderStopLoss(),NDigits); p2=NormalizeDouble(Ask+trail,NDigits); if(!((st==0.0 || p2<st))) break; ordmdf=OrderModify(OrderTicket(),OrderOpenPrice(),p2,OrderTakeProfit(),0,Red); if(!(!ordmdf)) break; Print("Order Modify Error", (GetLastError())); break; case OP_SELLSTOP: price=NormalizeDouble(Ask+offset,NDigits); if(!((price<opp))) break; p2= NormalizeDouble(price -(StopLoss+MarketInfo(Symbol(),MODE_SPREAD)) * Point,NDigits); ordmdf = OrderModify(OrderTicket(),price,p2,OrderTakeProfit(),0,Blue); if(!(!ordmdf)) break; Print("Order Modify Error", (GetLastError())); break; case OP_BUYSTOP: price=NormalizeDouble(Bid-offset,NDigits); if(!((price>opp))) break; p2= NormalizeDouble(price +(StopLoss+MarketInfo(Symbol(),MODE_SPREAD)) * Point,NDigits); ordmdf = OrderModify(OrderTicket(),price,p2,OrderTakeProfit(),0,Red); if(!(!ordmdf)) break; Print("Order Modify Error", (GetLastError())); } } } } }