OrderOpenPrice from pending orders

 

Hello, I would like to know if someone can help me with ideas about my next problem:

I am opening a pending order at 1:30:00, after 30 min at 2:00:00 it will turn to sell/buy. I have the next code to close the position after 10 hours, it will use OrderOpenPrice from sell/buy position not from my pending and i would like to use it from my pending.

I was thinking to have case#1 for eur/usd case#2aud/usd and so on... and for each case to take OrderOpenPrice from pending to stock it in a constant and than call it when it will turn to sell/buy and continue with the code below. But it is a long and hard way to do it. If anyone else has others idea to do it, i would be glad to hear from you.

Thank you.

extern int maxDuration = 10; 

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
//----
   return(0);
  }
//====================================================================
//====================================================================
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//====
//+------------------------------------------------------------------+
//| |EXPERT
//+------------------------------------------------------------------+
int start()
   {

for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
    OrderSelect(pos, SELECT_BY_POS)            
&&  OrderSymbol()== Symbol()){               
    int duration = TimeCurrent() - OrderOpenTime();
    if (duration >= maxDuration*60*60)
         OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(),3*Point);
}      return(0);
      }
 

not a good idea

the price is not reliable (it can be changed during the execution) use ticket no. instead 

 
Ok so i will use the ticket select for pending and after i will have to call the time when it was open. How am i able to use that opentime when my pending turn to sell/buy?
Reason: