Delettion of pending orders - page 2

 
t0mbfunk:

ok so it should be:

(OrderSelect(a,SELECT_BY_TICKET,MODE_TRADES))

Is there anything else I did wrong?

yes there is it should not be this....
 
t0mbfunk:

ok so it should be:

If you want to select by ticket give it a ticket number,  if you want to select by position give it a position number,  don't use a position with select by ticket or a ticket with select by position . . .  the clue is in the selection method.
 

"yes there is it should not be this...." wow so much helpful information in one comment..

 
RaptorUK:
If you want to select by ticket give it a ticket number,  if you want to select by position give it a position number,  don't use a position with select by ticket or a ticket with select by position . . .  the clue is in the selection method.


OK here I've tweaked my ea to select by ticket...


//-- | Orders Execution |-----------------------------------------------------------------------------/
void OrderEntry(int direction)
{
  if(direction == 1)
  {
    double ssl = 0;
    double stp = 0;
    if(SL != 0)ssl = High[1] + (SL*pips);
    if(TP != 0)stp = Close[1] - (TP*pips);
    if(OpenOrdersThisPair(Symbol()) < MaxOpenOrders)
      sellticket = OrderSend(Symbol(),OP_SELLSTOP,LotSize,Close[1]-BrStopLevel,Slippage,ssl,stp,NULL,MagicNumber,0,Red);
  }
  
  if(direction == 0)
  {
    double bsl = 0;
    double btp = 0;
    if(SL != 0)bsl = Low[1] - (SL*pips);
    if(TP != 0)btp = Close[1] + (TP*pips);
    if(OpenOrdersThisPair(Symbol()) < MaxOpenOrders)
      buyticket = OrderSend(Symbol(),OP_BUYSTOP,LotSize,Close[1]+BrStopLevel,Slippage,bsl,btp,NULL,MagicNumber,0,Green);
  }
}
//-------------------------------------------------------------------------------------------------------/

//-- | Deletion of Absolete Orders | ---------------/
void AbsoleteOrders()
{
  for(int as=OrdersTotal()-1;as>=0;as--)
  {
    if(OrderSelect(as,SELECT_BY_TICKET))
      if(OrderMagicNumber()==MagicNumber)
        if(OrderSymbol()==Symbol())
          if(OrderType()==OP_SELLSTOP)
            datetime SOOpenTime = OrderOpenTime();
            int SellOrdernBarsSinceOpen = iBarShift(NULL,0,SOOpenTime);
              if(SellOrdernBarsSinceOpen >= 2 && (OrderType() == OP_SELLSTOP))
                OrderDelete(sellticket,CLR_NONE);        
  }
  
  for(int ab=OrdersTotal()-1;ab>=0;ab--)
  {
    if(OrderSelect(ab,SELECT_BY_TICKET))
      if(OrderMagicNumber()==MagicNumber)
        if(OrderSymbol()==Symbol())
          if(OrderType()==OP_SELLSTOP)
            datetime BOOpenTime = OrderOpenTime();
            int BuyOrdernBarsSinceOpen = iBarShift(NULL,0,BOOpenTime);
              if(BuyOrdernBarsSinceOpen >= 2 && (OrderType() == OP_SELLSTOP))
                OrderDelete(buyticket,CLR_NONE);
  }                      
}
 
t0mbfunk:

OK here I've tweaked my ea to select by ticket...


No,  you haven't . . .    why is  ab  a ticket number ?  why is it not a position number ?
 
t0mbfunk:
Is there anything else I did wrong?
Try reading what he posted. Try reading the links posted. He has twice said that it should NOT BE SELECT_BY_TICKET
Reason: