Questions from Beginners MQL5 MT5 MetaTrader 5 - page 141

 
forexman77:

Thank you very much! It works.

Explain the logic of mql5. In mql4, int Hour() is used to determine the time in hours. In mql5, there is no such constant, as far as I understood.

1.How does the program recognize that we are asking for the time in hours? I assume fromMqlDateTime?

2.To add the current time in minutes to the current time in hours, i.e. to find out the current time in minutes, the construction would be like this

1. Yes

2. Right.

 

Second day of reworking the EA from mql4 to mql5.

1. I need to find the opening time of the daily bar in seconds from 01.01.1970. I found the function on the forum:

//--- переменные для указания параметров функции
int start = 0; // индекс бара
int count = 1; // количество баров
datetime tp[]; // массив, в котором возвращается время баров
//--- копирование времени 
CopyTime(_Symbol,PERIOD_D1,start,count,tp);
//--- вывод результата
Alert(tp[0]);

I am not sure whether the function finds the time of the last or the first bar.

The time is displayed as the beginning of the trading day, in the form of date and time.

I found the StringToTime function; it seems to do what I need but I have tried different combinations and now I feel like a chimpanzee who cannot understand what button to push to open the door to the apple.

3. I don't have iBarShift, iLow, iLowest functions in mql5. Could you please advise how to find the daily minimum for a certain period of time or which functions inmql5 should be used to solve this problem?

Документация по MQL5: Преобразование данных / StringToTime
Документация по MQL5: Преобразование данных / StringToTime
  • www.mql5.com
Преобразование данных / StringToTime - Документация по MQL5
 
forexman77:

Second day of reworking the EA from mql4 to mql5.

1. I need to find the opening time of the daily bar in seconds from 01.01.1970. Found the function on the forum:

2. I found the StringToTime function and it seems to do what I need. But I tried different combinations and now I feel like a chimp who doesn't know which button to push to open the door to the apple.

I have no iBarShift, iLow, iLowest functions in mql5. Can you tell me how to find the minimum on a certain period of time every day, or what functions inmql5 should I use to solve this problem?

1,2. Please read here.

3. read here.

 
DC2008:

1,2. Read here.

3. Read here.

On the second question. Reread everything about datetime. "The datetime type is intended to store the date and time as the number of seconds elapsed since January 01, 1970."

Why then when calling the alert it says: 2013.10.02 00:00:00 and not the number of seconds.

 
forexman77:

On the second question. Reread everything on datetime. "The datetime type is intended to store the date and time as the number of seconds elapsed since January 01, 1970."

Why then when the alert is called it displays: 2013.10.02 00:00:00 and not the number of seconds.

Now read here. To output it in the alert, you must convert the datetime type to the int type.

 
DC2008:

Now read here. To output in the alert, you need to convert datetime type to int type.

I made a construction like this:

int start = 0; // индекс бара
int count = 1; // количество баров
datetime tp[]; // массив, в котором возвращается время баров
//--- копирование времени 
CopyTime(_Symbol,PERIOD_D1,start,count,tp);
//--- вывод результата
int st=tp[0];
Alert("st=",st);

I compared it to metatrader 4 and got the same number.

But the message is yellow when compiling mql5:

possible loss of data due to type conversion

I tried to do it like this:

int start = 0; // индекс бара
int count = 1; // количество баров
datetime tp[]; // массив, в котором возвращается время баров
//--- копирование времени 
CopyTime(_Symbol,PERIOD_D1,start,count,tp);
//--- вывод результата
Alert(IntegerToString(tp[0]));
No errors. But I don't know where to attachIntegerToString to get the value without alerting, because it will be used by Expert Advisor for calculations. Only I don't understand it will be a string value, i.e. can it be used as a comparison with another number?
 
forexman77:

Made a construction like this:

compared it to metatrader 4, it turns out the same number.

Except that the message comes out yellow when compiling mql5:

possible loss of data due to type conversion

It's simpler than that!

//--- вывод результата
Alert("st=",(int)tp[0]);
 

Can you tell me how to create a signal if I was once subscribed to another one?

That is, I have already unsubscribed from it. Is it really not possible?

Made 100% in less than 2 weeks and can't share with anyone(

 
this too is an interesting question
 
DC2008:

It's simpler than that!

Still, I will need the variable "st" not only in Alert, but also for calculations, and the "possible data loss due to type conversion" warning comes out when compiling.

I assume this is because I get a 10-digit number and the maximum value in int is 2 147 483 647, I currently get 1 380 758 400. Maybe it makes sense to use long and probably the EA will consume a lot of resources in this part?

Документация по MQL5: Общие функции / Alert
Документация по MQL5: Общие функции / Alert
  • www.mql5.com
Общие функции / Alert - Документация по MQL5
Reason: