int seconds_in_trade=(int)(TimeCurrent()-OrderOpenTime())
should give you the duration in seconds.
Then code to convert the seconds into hours and minutes
If you just need the value as a string for a Print, Comment or label
datetime time_in_trade=TimeCurrent()-OrderOpenTime(); Print(TimeToStr(time_in_trade,TIME_MINUTES));
should do it
but I'm not sure what would happen if a trade is open more than 24 hours, so probably only good for short term trades
Thanks GumRai.. The first explicit conversion is what I needed.. I didnt know I could do an (<datatype>) conversion. I'm new to MQL4.. Thanks for you help.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'm trying to come up with a real simple piece of code that just shows me the number of minutes / hours that I'm in an open position.
Basically what I know I should do is use
TimeCurrent()-OrderOpenTime()
But this gives me a Time formatted value from year 1970. I'd rather just have a number of hours / minutes I can work with.
Anyone know if there is a function for this?