I've consulted the article on casting, https://www.mql5.com/en/docs/basis/types/casting and seen some other responses on this forum, but this particular instance seems different, possibly because it contains an array? The affected line is highlighted. You can see that TradeList and ctTrade have both been initialized as integers.
OrderOpenTime
Returns open time of the currently selected order.
datetime OrderOpenTime(); |
Consider using a struct:
struct Trade { int type; datetime opentime; int ticket; }
then
Trade tradelist[];
...
ArrayResize(tradelist,ctTrade);
tradelist[ctTrade-1].opentime=OrderOpenTime();
So "OrderOpenTime()" function returns datetime type value,it should be converted type casting as Integer as below:
Curiously (int)datetimevar doesn't change the value of datetimevar like (int)doublevar would change the value of doublevar to an int. So it works but it shouldn't :p
double a=1.5; datetime b=TimeGMT(); printf("*** double var : %g -- datetime var : %g",(int)a,(int)b);
(EURUSD,H1) *** double var : 1 -- datetime var : 1.56725e+09
Curiously (int)datetimevar doesn't change the value of datetimevar like (int)doublevar would change the value of doublevar to an int. So it works but it shouldn't :p
So that is based on seconds from 1970 !
So that is based on seconds from 1970 !
Yes you true, I just thought about. It is the number of seconds, so literally it is an integer but it's expressed as a datetime

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I've consulted the article on casting, https://www.mql5.com/en/docs/basis/types/casting and seen some other responses on this forum, but this particular instance seems different, possibly because it contains an array? The affected line is highlighted. You can see that TradeList and ctTrade have both been initialized as integers.