MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal

Automated Trading and Strategy Testing Forum

downloadhistory.mq5 Script
downloadhistory.mq5
Author: gdtt
Custom Graphical Controls. Part 2. Control Library Custom Graphical Controls. Part 2. Control Library Subscribe to signal
Silent Winner
15.00%, 348.27 USD
ProfessorFx PlatinumProfessorFx Platinum Try product
ProfessorFx Platinum
Author: achidayat
Screenshot
EURUSD, D1
Real

// How to get Position opening time?

To add comments, please log in or register
polymath
177
polymath 2012.08.11 18:48

Hi guys,

I'm just wondering if there is a function to get the position opening time here in MQL5? I've read the various trade functions and the data structures but can't seem to locate this function.  I'm intending to close a position based on a fixed time after being opened if the takeprofit and stoploss hasn't been triggered yet.  Thanks in advance!

Interview with Irina Korobeinikova (irishka.rf)
Having a female member on the MQL5.community is rare. This interview was inspired by a one of a kind case. Irina Korobeinikova (irishka.rf) is a fifteen-year-old programmer from Izhevsk. She is currently the only girl who actively participates in the "Jobs" service and is featured on the Top Developers list.
Pawel W.
566
Enigma71fx 2012.08.11 18:50
polymath:

Hi guys,

I'm just wondering if there is a function to get the position opening time here in MQL5? I've read the various trade functions and the data structures but can't seem to locate this function.  I'm intending to close a position based on a fixed time after being opened if the takeprofit and stoploss hasn't been triggered yet.  Thanks in advance!

PositionGetInteger(POSITION_TIME). Returns a datetime type.

For more info on position properties, click a green link in your post. 

polymath
177
polymath 2012.08.11 19:43
Wow, that was fast :D Thanks Enigma71fx!
onewithzachy
954
onewithzachy 2012.08.12 00:29
Enigma71fx:

PositionGetInteger(POSITION_TIME). Returns a datetime type.

For more info on position properties, click a green link in your post. 

Hi polymath,

... and you have to select first with PositionSelect() http://www.mql5.com/en/docs/trading/positionselect

 

 

polymath
177
polymath 2012.08.12 09:55
Thanks onewithzachy, that's what I did :D
/ To add comments, please log in or register