Oh time suspend your flight!

 


Time Current () and StringToTime () send me the same thing.

What is the mistake ???

 Print("CloseTime:"+HistoryDealGetInteger(ticket,DEAL_TIME)+" Time current:"+TimeCurrent()+" Time Convert:"+StringToTime(TimeCurrent()));  


 
stanislass:

What is the mistake ???

There is no mistake. According to the documentation:

______________________________________________

Print

It enters a message in the Expert Advisor log. Parameters can be of any type.

void  Print(
   argument,     // first value
   ...           // next values
   );

Parameters

...

[in]  Any values separated by commas. The number of parameters cannot exceed 64.

Note

Arrays cannot be passed to the Print() function. Arrays must be input element-by-element.

Data of double type are shown with the accuracy of up to  16 digits after a decimal point, and can be output either in traditional or in scientific format, depending on what entry will be more compact. Data of float type are output with 5 digits after a decimal point. To output real numbers with another accuracy or in a predefined format, use the  PrintFormat() function.

Data of bool type are output as "true" or "false" lines. Dates are shown as YYYY.MM.DD HH:MI:SS. To show data in another format, use  TimeToString(). Data of color type are returned either as R,G,B line or as a color name, if this color is present in the color set.

Print() function does not work during optimization in the  Strategy Tester.

______________________________________________

Meaning: although datetime format variables like the returned value of TimeCurrent() represent "seconds since 1.1.1970", it is the default behaviour of the print() function to already display the dates correctly - no need for a conversion if you don't want a special format.

StringToTime also returns datetime format, so we shouldn't expect any different result (although: StringToTime(TimeCurrent()) doesn't make much sense - you're trying to convert something to datetime that already represents datetime --> it compiles and works, but you get a warning "implicit conversion from number to string").

 
Chris70:

There is no mistake. According to the documentation:

______________________________________________

Print

It enters a message in the Expert Advisor log. Parameters can be of any type.

void  Print(
   argument,     // first value
   ...           // next values
   );

Parameters

...

[in]  Any values separated by commas. The number of parameters cannot exceed 64.

Note

Arrays cannot be passed to the Print() function. Arrays must be input element-by-element.

Data of double type are shown with the accuracy of up to  16 digits after a decimal point, and can be output either in traditional or in scientific format, depending on what entry will be more compact. Data of float type are output with 5 digits after a decimal point. To output real numbers with another accuracy or in a predefined format, use the  PrintFormat() function.

Data of bool type are output as "true" or "false" lines. Dates are shown as YYYY.MM.DD HH:MI:SS. To show data in another format, use  TimeToString(). Data of color type are returned either as R,G,B line or as a color name, if this color is present in the color set.

Print() function does not work during optimization in the  Strategy Tester.

______________________________________________

Meaning: although datetime format variables like the returned value of TimeCurrent() represent "seconds since 1.1.1970", it is the default behaviour of the print() function to already display the dates correctly - no need for a conversion if you don't want a special format.

StringToTime also returns datetime format, so we shouldn't expect any different result (although: StringToTime(TimeCurrent()) doesn't make much sense - you're trying to convert something to datetime that already represents datetime --> it compiles and works, but you get a warning "implicit conversion from number to string").


Ok, that's a bit like what I thought. But "HistoryDealGetInteger (ticket, DEAL_TIME)", considered as an integer, escapes to the rule.

The subtleties of metaquotes will always surprise me.


Thank you Chris

Ps. In this case, no warning

 
stanislass:

Ok, that's a bit like what I thought. But "HistoryDealGetInteger (ticket, DEAL_TIME)", considered as an integer, escapes to the rule.

Yes, there is some truth to this, because they didn't implement a dedicated function such as "HistoryDealGetDatetime", but

datetime dealtime=(datetime)HistoryDealGetInteger(ticket,DEAL_TIME);

can fill this gap if you want "accurate" semantics - although it is unnecessary (=redundant), because although the name of the functions suggests Integer, the type for DEAL_TIME actually already is datetime (therefore it doesn't "escape the rule" and triggers no warning), even without a dedicated "HistoryDealGetDatetime". I'm not sure if what might seem like negligeance or lack of accuracy here really is a bad thing. It serves simplicity if we don't have thousands of function names to remember.