Time[] in MT4 but no in MT5

To add comments, please log in or register
intrania13
23
intrania13  

Dear Coder,

I need your help to explain me how to use the function of Time[] in MT5 which is exit in MT4 but not in MT5. How can I fix it in MT5?

Vladimir Karputov
Moderator
125943
Vladimir Karputov  
intrania13:

Dear Coder,

I need your help to explain me how to use the function of Time[] in MT5 which is exit in MT4 but not in MT5. How can I fix it in MT5?

In the indicator or in the adviser?
Stanislav Korotky
25153
Stanislav Korotky  
intrania13:

Dear Coder,

I need your help to explain me how to use the function of Time[] in MT5 which is exit in MT4 but not in MT5. How can I fix it in MT5?

Use CopyTime. Here is an article with details about migrating from MQL4 to MQL5.
Bernhard Schweigert
29066
Bernhard Schweigert  
Stanislav Korotky:
Use CopyTime. Here is an article with details about migrating from MQL4 to MQL5.

"In MQL5 chart period constants changed, and some new time periods (M2, M3, M4, M6, M10, M12, H2, H3, H6, H8, H12) were added."

Thanks this article really helps

Bernhard Schweigert
29066
Bernhard Schweigert  

check this one too

https://www.mql5.com/en/articles/66

Transferring Indicators from MQL4 to MQL5
Transferring Indicators from MQL4 to MQL5
  • 2010.07.28
  • Vasily
  • www.mql5.com
This article is dedicated to peculiarities of transferring price constructions written in MQL4 to MQL5. To make the process of transferring indicator calculations from MQL4 to MQL5 easier, the mql4_2_mql5.mqh library of functions is suggested. Its usage is described on the basis of transferring of the MACD, Stochastic and RSI indicators.
BeLikeTrader
3784
BeLikeTrader  
Why the didnt put Time[] TimeDayOfTheWeek()  That were pretty good functions!!!
BeLikeTrader
3784
BeLikeTrader  

I mean seriously... compare this code to express the same idea.. and are you still wondering why MQL5 has been a failure? Why change it to copy time or not make some compatibility so we dont have to rewrite all indicators? Omg...


MQL4:

Alert(Time[0]);

MQL5:

//--- variables for function parameters
int start = 0; // bar index
int count = 1; // number of bars
datetime tm[]; // array storing the returned bar time
//--- copy time 
CopyTime(_Symbol,PERIOD_D1,start,count,tm);
//--- output result
Alert(tm[0])
Marco vd Heijden
Moderator
8390
Marco vd Heijden  
I agree.
To add comments, please log in or register