OrderClose error 3

 

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());
                                             
         }
         
      }
 
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

 


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()
 
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
Reason: