selecting a pending order when it reaches the price

To add comments, please log in or register
Farvardin Faili
218
Farvardin Faili  

hi i have a simple question... i want to select a pending order when it reaches its price for example in the code below 2 orders gets opened and the second one is a buystop as you see....i want to modify the stoploss of the first order that is a buy after the second order reaches its price(Ask+20*Point)....

if(open_pair(Symbol())<2)//open orders based on the current symbol
{
   int ticket=OrderSend(Symbol(),OP_BUY,0.02,Ask,5,0,Ask+30*Point);
   int ticket2=OrderSend(Symbol(),OP_BUYSTOP,0.02,Ask+20*Point,5,0,Ask+30*Point);
   if(ticket2>0)
     bool modify=OrderModify(ticket,OrderOpenPrice(),Ask-30*Point,OrderTakeProfit(),0);
   }
  }

the problem is it just modifies the order when buystop simply opens not when it reaches its price can you help me how to solve that....thank you in advance

To add comments, please log in or register