Saving OrderOpenTime() after OrderSend()

 

Hey guys,

Is there any simple way to save the open time of an order after the OrderSend() function. Something like...

//global 
datetime buyordertime;

Start()
int BuyOrder=OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,StopLoss,TakeProfit,"buy order",MagicNumber,0,clrBlue);
buyordertime=OrderOpenTime();

 Or do I have to write a for() after the OrderSend() selecting the order and then save it? 

Any help is appreciated.  

 

Just add the OrderSelect function at the right place (donno if it is wise to RefreshRates() before that, read here and there it is recommended, but as you want to access a recently opened order, maybe not in this case):

//global 
datetime buyordertime;

Start()
int BuyOrder=OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,StopLoss,TakeProfit,"buy order",MagicNumber,0,clrBlue);
//RefreshRates() ??
OrderSelect(Buyorder,SELECT_BY_TICKET,MODE_TRADES);
buyordertime=OrderOpenTime();
 
PomeGranate:

Just add the OrderSelect function at the right place (donno if it is wise to RefreshRates() before that, read here and there it is recommended, but as you want to access a recently opened order, maybe not in this case):

 

 

Fantastic! Thanks! Can I make it this: 
//global 
datetime buyordertime;

Start()
int BuyOrder=OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,StopLoss,TakeProfit,"buy order",MagicNumber,0,clrBlue);
//RefreshRates() ??
if(BuyOrder>0) OrderSelect(Buyorder,SELECT_BY_TICKET);
buyordertime=OrderOpenTime();
Also, will saving the OrderOpenPrice() help distinguish between 2 orders of the same OrderType() and MagicNumber? Meaning, if the above order gets sent twice at 2 different times can I use OrderOpenPrice() to help distinguish between the two orders?
 

1. Of course you can, why shouldn't you? ^^ (that probably even saves resources)

2. No, I think you can't. For that, you'll have to build more elaborate order management (looping through orders etc.)

 
PomeGranate:

2. No, I think you can't. For that, you'll have to build more elaborate order management (looping through orders etc.)

Can you suggest any properties of each order to look at in these loops to make the EA distinguish between the two?
 
DeanDeV:
Can you suggest any properties of each order to look at in these loops to make the EA distinguish between the two?

OrderTicket()

 
honest_knave:

OrderTicket()

 

 

Thanks.
Reason: