Download MetaTrader 5
To add comments, please log in or register
Do you know that MQL5 has structures?
Dennis
21
Dennis 2016.02.22 19:45 

Im logging trade times using OrderOpenTime() and OrderCloseTime(), which helps me keep track of my trades. However, at times, I need to manually close a trade that has been opened by my EA. But whenever I close a trade manually, the EA does not record the OrderCloseTime(). 

How can i get my EA to recognize my manual action, and print the OrderCloseTime() for such trades?

 Thanks. 

whroeder1
13596
whroeder1 2016.02.23 01:18  
bondstrader: whenever I close a trade manually, the EA does not record the OrderCloseTime().
Your EA is broken; fix your EA. We can't see your code; there are no mindreaders here.
Zirkon
123
Zirkon 2016.02.27 18:38  
bondstrader:

Im logging trade times using OrderOpenTime() and OrderCloseTime(), which helps me keep track of my trades. However, at times, I need to manually close a trade that has been opened by my EA. But whenever I close a trade manually, the EA does not record the OrderCloseTime(). 

How can i get my EA to recognize my manual action, and print the OrderCloseTime() for such trades?

 Thanks. 

A manual trade has a magic number =0, include this processing in your EA.
Keith Watford
Moderator
7887
Keith Watford 2016.02.27 21:52  
bondstrader:

Im logging trade times using OrderOpenTime() and OrderCloseTime(), which helps me keep track of my trades. However, at times, I need to manually close a trade that has been opened by my EA. But whenever I close a trade manually, the EA does not record the OrderCloseTime(). 

How can i get my EA to recognize my manual action, and print the OrderCloseTime() for such trades?

 Thanks. 

As the EA opens trades, store the ticket numbers in an array

Loop through the array and check whether the order has been closed

If so, log the OrderOpenTime() and OrderCloseTime() and remove the order from the array

whroeder1
13596
whroeder1 2016.02.28 02:55  
GumRai: As the EA opens trades, store the ticket numbers in an array
EA's must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect loop to recover, or persistent storage (GV/file) of ticket numbers required.
Keith Watford
Moderator
7887
Keith Watford 2016.02.29 01:34  
GumRai:

As the EA opens trades, store the ticket numbers in an array


WHRoeder:
EA's must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect loop to recover, or persistent storage (GV/file) of ticket numbers required.
As Bondstrader is writing trade details to a log, I would think that he has some recovery code. So he would have to re-populate the array from the log in such an event.
/
To add comments, please log in or register