OrderDelete Problem

 

Hi all

I would like to delete a pending order after 10 pips, that's if the buy order is in profit after 10 pips. With the code below it will delete sell stop all the time. I know you can delete by time function after a few minutes, hours & days etc. I would like to know is it possible to delete after certain amount of pips?

If so please help

double Pips=0;
   double Ticksize=MarketInfo(Symbol(),MODE_TICKSIZE);
   if(Ticksize==0.00001||Ticksize==0.001)
   Pips=Ticksize*10;
   else Pips=Ticksize;
   
   for(int Loop3=OrdersTotal()-1;Loop3>=0;Loop3--)
   {
    if(OrderSelect(Loop3,SELECT_BY_POS,MODE_TRADES))
    if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
    {
     if(OrderType()==OP_BUYSTOP)
     {
      if(OrderOpenPrice()<=Ask-10*Pips)
      {
       bool Delete=OrderDelete(OrderTicket(),clrHotPink);
      }
     }
     else if(OrderType()==OP_SELLSTOP)
     {
      if(OrderOpenPrice()>=Bid-10*Pips)
      {
       bool Delete=OrderDelete(OrderTicket(),clrHotPink);
      }
     }
    }
 
Jack Buda:

Hi all

I would like to delete a pending order after 10 pips, that's if the buy order is in profit after 10 pips. With the code below it will delete sell stop all the time. I know you can delete by time function after a few minutes, hours & days etc. I would like to know is it possible to delete after certain amount of pips?

If so please help

using 


OrderOpenTime()

 
Mehmet Bastem #:

using 


OrderOpenTime()

It still deletes everything like OrderOpenPrice().

double Pips=0;
   double Ticksize=MarketInfo(Symbol(),MODE_TICKSIZE);
   if(Ticksize==0.00001||Ticksize==0.001)
   Pips=Ticksize*10;
   else Pips=Ticksize;
   
   for(int Loop3=OrdersTotal()-1;Loop3>=0;Loop3--)
   {
    if(OrderSelect(Loop3,SELECT_BY_POS,MODE_TRADES))
    if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
    {
     if(OrderType()==OP_BUYSTOP)
     {
      if(OrderOpenTime()<=Ask-10*Pips)
      {
       bool Delete=OrderDelete(OrderTicket(),clrHotPink);
      }
     }
     else if(OrderType()==OP_SELLSTOP)
     {
      if(OrderOpenTime()>=Bid-10*Pips)
      {
       bool Delete=OrderDelete(OrderTicket(),clrHotPink);
      }
     }
    }
 
  1.      else if(OrderType()==OP_SELLSTOP)
         {
          if(OrderOpenPrice()>=Bid-10*Pips)

    Bid plus.

  2.       if(OrderOpenTime()>=Bid-10*Pips)
    Time <= price is meaningless.
-
 
Jack Buda:

Hi all

I would like to delete a pending order after 10 pips, that's if the buy order is in profit after 10 pips. With the code below it will delete sell stop all the time. I know you can delete by time function after a few minutes, hours & days etc. I would like to know is it possible to delete after certain amount of pips?

If so please help

Convert Pips back to price and use OrderOpenPrice.

Example: PriceDifference = CurrentPrice - OrderOpenPrice(). OrderClose = Pips (converted to price).

Therefore if PriceDifference >= OrdersClose.......Proceed to close your pending order. 

I'm not that good at coding yet so I hope the above gives you my line of thinking or approach. 

 
William Roeder #:
  1. Bid plus.

  2. Time <= price is meaningless.
-

Changed it, as you mentioned above but expiration as soon as pending order is open.

double Pips=0;
   double Ticksize=MarketInfo(Symbol(),MODE_TICKSIZE);
   if(Ticksize==0.00001||Ticksize==0.001)
   Pips=Ticksize*10;
   else Pips=Ticksize;
   
   for(int Loop3=OrdersTotal()-1;Loop3>=0;Loop3--)
   {
    if(OrderSelect(Loop3,SELECT_BY_POS,MODE_TRADES))
    if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
    {
     if(OrderType()==OP_BUYSTOP)
     {
      if(OrderOpenTime()<Ask-10*Pips)
      {
       bool Delete=OrderDelete(OrderTicket(),clrHotPink);
      }
     }
     else if(OrderType()==OP_SELLSTOP)
     {
      if(OrderOpenTime()<Bid+10*Pips)
      {
       bool Delete=OrderDelete(OrderTicket(),clrHotPink);
      }
     }
    }
    
   }