Hi Can someone please solve the following problem for me? :)
printf(" open order Position "+(datetime)PositionGetInteger(POSITION_TIME));
printf(" time : "+time );
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 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;
thnx for relpay
but i want used delay
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)