It looks like that the StringToTime() function doesn't accept the format of "00:10", you may check out the function's reference in the Documentation section.
If the "00:10" means 10 seconds, you may simply write the code as:
datetime time = (datetime)PositionGetInteger(POSITION_TIME)+(datetime)10;
It looks like that the StringToTime() function doesn't accept the format of "00:10", you may check out the function's reference in the Documentation section.
If the "00:10" means 10 seconds, you may simply write the code as:
thnx for relpay
but i want used delay
string delay="00:10";
Hi Can someone please solve the following problem for me? :)
output :
2013.12.28 08:27:52 Core 1 2013.09.04 13:58:40 time : 2057.05.08 13:10:00
2013.12.28 08:27:52 Core 1 2013.09.04 13:58:40 open order Position 2013.09.04 13:00:00
It's because
string delay="00:10";
when converted to a datetime gives you :
2013.12.20 10:21:59.930 SomeTests (EURUSD,H1) delay = 2013.12.20 00:10:00
Please read the documentation about StringToTime():
The function converts a string containing time or date in "yyyy.mm.dd [hh:mi]" format into datetime type.
So if you want absolutely to proceed this way, you have to use :
string delay="1970.01.01 00:10";
"Time" can have 2 different meanings: position and duration.
StringToTime() accept a string that represent a position in time (a particular moment) and not a duration/delay.
datetime data-type store seconds, so if you want to add your delay to a date, first you need to have its value in seconds.
If you want to represent a delay with the format HH:MM (hours : minutes), you need to extract from it the minutes substring with StringSubstr()
then convert it to integer with StringToInteger(), convert to seconds and add this value to your POSITION_TIME.
Something like this: (simplified)
StringToInteger(StringSubstr("00:10",3,2))*60
see: https://www.mql5.com/en/articles/599#convert_add_substract
- 2013.04.26
- Dmitry Fedoseev
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Can someone please solve the following problem for me? :)
output :
2013.12.28 08:27:52 Core 1 2013.09.04 13:58:40 time : 2057.05.08 13:10:00
2013.12.28 08:27:52 Core 1 2013.09.04 13:58:40 open order Position 2013.09.04 13:00:00