'What can i use in place of TimeSeconds() in mql5?
I used TimeSeconds(opening time of any candle selected)
in mql4 to track the current seconds as it is changing. i used it to set my Alert() to sound only twice. Now i want to do the same thing in Mql5, then i discover that mql5 does not have TimeSeconds()
. How can i go about it?
The following code was what i used in mql4.
datetime myTime = iTime(_Symbol,_Period,0);
int currentMinute = TimeMinute(TimeCurrent());
int openMinutesOfLastCandle = TimeSeconds(myTime);
Solution 1:[1]
#ifdef __MQL5__
int TimeSeconds(const datetime date)
{
MqlDateTime dt;
TimeToStruct(time,dt);
return dt.sec;
}
#endif
Alternative would be to use TimeCurrent()%60
to get seconds.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Daniel Kniaz |