Download MetaTrader 5

OrderClose error 3

To add comments, please log in or register
gudruolis
674
gudruolis  

guys,

for some strange reason 1 our of 3 pairs does not work on MT4 tester, and i cant understand why.

error closing order. what can be wrong and why 2 pairs work, the 3rd wont (all pairs are in market watch window - valid).

here is the code.

any ideas please?


for(i=OrdersTotal()-1;i>=0;i--)
      {
         
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) 
         {
         
         if(TimeCurrent()-OrderOpenTime()<2) a=88;
                      
         if(OrderMagicNumber()==Magic && cl>0 && OrderType()==OP_BUY) n=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),900);
         
         if(OrderMagicNumber()==Magic && cl>0 && OrderType()==OP_SELL) n=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),900);
                           
         if(OrderMagicNumber()==Magic && cl>0 && (OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYLIMIT)) n=OrderDelete(OrderTicket());
         
         if(OrderMagicNumber()==Magic && cl>0 && (OrderType()==OP_SELLSTOP || OrderType()==OP_BUYSTOP)) n=OrderDelete(OrderTicket());
                                             
         }
         
      }
whroeder1
14780
whroeder1  
gudruolis: for some strange reason 1 our of 3 pairs does not work on MT4 tester, and i cant understand why.
'Testing Features and Limits in MetaTrader 4' - MQL4 Articles
Trading is permitted for the symbol under test only, no portfolio testing

Attempts to trade using another symbol will return error

gudruolis
674
gudruolis  


hi, whroeder1,

im not multipair testing.

just using same EA for different pairs.

So for example - EA closes correctly orders for GBPJPY, but it doesnt close for EURUSD. It closes correctly for GBPAUD.

so what can be the root for error?

code below does not "fix" to any pair..


MarketInfo(OrderSymbol()
whroeder1
14780
whroeder1  
gudruolis: so what can be the root for error?
Check your return codes (OrderSelect and OrderClose) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
To add comments, please log in or register