Download MetaTrader 5
To add comments, please log in or register
Sell your CPU capacity and earn money!
jtubbs13791
71
jtubbs13791 2016.01.17 20: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
whroeder1
13599
whroeder1 2016.01.17 20: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
/
To add comments, please log in or register