0
votes

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);
1

1 Answers

1
votes
#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.