Deleting or closing a pending buylimit

Back to topics list To post a new topic, please log in or register
avatar
14
jtubbs13791 2016.01.17 21:33
 
void CloseStack1stLevel1M ()
{
for(int b= OrdersTotal()-1; b >= 0; b--)
   {
   if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
     if(OrderMagicNumber() == MagicNumber1M)
        if(OrderSymbol() == Symbol())
          if(OrderType()==OP_BUY)
             if(OrdersTotal() == 0)
               CloseBuyStack1stLevelLimitOrder1M();
   }
for(int b= OrdersTotal()-1; b >= 0; b--)
   {
   if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
     if(OrderMagicNumber() == MagicNumber1M)
        if(OrderSymbol() == Symbol())
          if(OrderType()==OP_SELL)
            if(OrdersTotal() == 0)
                CloseSellStack1stLevelLimitOrder1M();
   }
}
void CloseBuyStack1stLevelLimitOrder1M()
{

for(int b= OrdersTotal()-1; b >= 0; b--)
   {
   if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
     if(OrderMagicNumber() == Stack1stLevelMagicNumber1M)
        if(OrderSymbol() == Symbol())
          if(OrderType()==OP_BUYLIMIT)
             OrderDelete(OrderTicket(),clrNONE);
   }

}
void CloseSellStack1stLevelLimitOrder1M()
{
for(int b= OrdersTotal()-1; b >= 0; b--)
   {
   if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
     if(OrderMagicNumber() == Stack1stLevelMagicNumber1M)
        if(OrderSymbol() == Symbol())
          if(OrderType()==OP_SELLLIMIT)
             OrderDelete(OrderTicket(),clrNONE);
   }

}
I am having issues with deleting or closing a pending buylimit. here is my coding what am I doing wrong? its probably simple
avatar
12985
WHRoeder 2016.01.17 21:43 #
 
  1. for(int b= OrdersTotal()-1; b >= 0; b--)
       {
                 if(OrdersTotal() == 0)
                   CloseBuyStack1stLevelLimitOrder1M();
       }
    If OrdersTotal() is zero the for loop will do nothing. If OrdersTotal() is nonzero the last if statement will always be false. Either way nothing happens.
  2. Check your return codes and find out why. 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
Back to topics list  

To add comments, please log in or register