Saving OrderOpenTime() after OrderSend()

Back to topics list To post a new topic, please log in or register
avatar
120
DeanDeV 2015.06.19 15:25
 

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.  

avatar
54
PomeGranate 2015.06.19 15:50 #
 

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();

 

 

avatar
120
DeanDeV 2015.06.19 17:50 #
 
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?
avatar
54
PomeGranate 2015.06.19 18:26 #
 

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.)

avatar
120
DeanDeV 2015.06.20 22:40 #
 
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?
avatar
736
honest_knave 2015.06.20 22:47 #
 
DeanDeV:
Can you suggest any properties of each order to look at in these loops to make the EA distinguish between the two?

OrderTicket()

 

 

avatar
120
DeanDeV 2015.06.21 08:20 #
 
honest_knave:

OrderTicket()

 

 

Thanks.
Back to topics list  

To add comments, please log in or register