how to enter order "x" pips away, and close pending limit orders

 

Hi, I need some assistance on changing my order to enter a limit order "x" pips away, for example 5 pips away, if AUD/USD is .7255, buy limit would be .7250, or if Eur/usd was 1.1558, sell limit would be 1.1563

This is the current buy/sell Order code I have for instant execution but I want to change

//for buy
res=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"",MagicNumber,0,Green);

//for sell
res=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"",MagicNumber,0,FireBrick);


Additionally, how do I close a pending buy limit or sell limit order if not executed.

I'm currently closing orders with this code:

   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderMagicNumber()!=MagicNumber || OrderSymbol()!=Symbol()) continue;
      //--- check order type 
      if(OrderType()==OP_BUY)
        {
         //here is the close buy condition  
         if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,Black))
            Print("OrderClose error ",GetLastError());
         break;
        }
      if(OrderType()==OP_SELL)
        {
         // here is the close sell condition  
         if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,Sienna))
            Print("OrderClose error ",GetLastError());
         break;
        } 
     }
 

if AUD/USD is .7255, buy limit would be .7260

Buy Limit has to be below the current price

 

Additionally, how do I close a pending buy limit or sell limit order if not executed.

You use OrderDelete() for a pending order

 
Keith Watford:

if AUD/USD is .7255, buy limit would be .7260

Buy Limit has to be below the current price

True, typo, but that's just an example.
Reason: