Questions from Beginners MQL5 MT5 MetaTrader 5 - page 140

 
DC2008:

1. If you omit the checks, you can go like this:

2. Yes

3. The question is not clear.

1. What are the checks for? If without them less resources would be wasted?

2. For example, in mql4 there are variable names:

int start()
  {
   int
   Total,                           // Количество ордеров в окне 
   Tip=-1,                          // Тип выбран. ордера (B=0,S=1)
   Ticket;                          // Номер ордера
   double
   MA_1_t,                          // Значен. МА_1 текущее
   MA_2_t,                          // Значен. МА_2 текущее 
   One_Lot,                         // Стоимость одного лота
   Price,                           // Цена выбранного ордера
   SL,                              // SL выбранного ордера 
   TP;                              // TP выбранного ордера
   bool 
   Ans  =false,                     // Ответ сервера после закрытия
   Cls_B=false,                     // Критерий для закрытия  Buy
   Cls_S=false,                     // Критерий для закрытия  Sell

In which section of mql5 to list these variables that are above in the code that are in mql4 in int start?

Global variables are set before int start. All EA code is taken from the tutorial herehttps://с.mql4.com/book

 
forexman77:

1. What are the checks for? If without them fewer resources would be wasted?

2. In mql4 there are variable names for example:

In which section of mql5 to list these variables that are above in the code that are in mql4 in int start?

Global variables are set before int start. The whole code of the Expert Advisor is taken from the tutorial herehttps://с.mql4.com/book.

1. For reliable real trading of the Expert Advisor.

These are local variables and you can copy them to the OnTick function, which replaces the start() of the 4.

However, I would like to warn you: trading functions should NOT be transposed one to one!

 
DC2008:

1. For reliable EA operation on real.

2. these are local variables and you can copy them into the OnTick function, which replaces start() from the four.

However, I would like to warn you, the trading functions should NOT be copied from one to another!

Do you mean that some variables are counted differently in five? Sorry, I don't know anything about mql5 yet, so I cannot completely understand you. Could you give me an example of why you cannot transfer functions from mql4 to one another? Is there a forum branch for dummies?)

I am trying to insert the code:

datetime iTimeMQL4(string symbol,int tf,int index)
{
   if(index < 0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   datetime Arr[];
   if(CopyTime(symbol, timeframe, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}

I see errors in void OnTick():

TFMigrate' - function not defined

implicit enum conversion

I tried the same errors in int OnInit(). What am I doing wrong?

In mql5 we put flags, tickets, stop and profit lots, etc. into global variables that need to be stored outside the main code, i.e. the principle is the same as in mql4.

 
forexman77:

Do you mean that some variables are counted differently in 5? I'm sorry, but I don't know anything about mql5 and I can't quite understand you. Could you give me an example of why mql4 functions cannot be transferred to one another? Is there a branch on this forum for completely dummies?)

You should give up on mql4 and don't translate "stupidly" line by line, but start "dancing from the stove"! There are a lot of examples and ready-made Expert Advisors in kodobase and in the standard MQ delivery for the five. If this is "higher maths" for you, then order an EA in the "Work" section.

Now the answers to your questions:

  1. Copy the TFMigrate function from the article, it is in the beginning.
  2. As for the variables, the principle is the same.
 
DC2008:

You can't just start "dancing from the stovepipe" instead of "dumbly" translating line by line! There are a lot of examples and ready-to-use EAs in kodobase and in the standard MQ package for five. If this is "higher maths" for you, then order an EA in the "Work" section.

Now the answers to your questions:

  1. Copy the TFMigrate function from the article, it is in the beginning.
  2. As for the variables, the principle is the same.
I'm trying to put your function
int HourMQL4(){MqlDateTime tm;TimeCurrent(tm);return(tm.hour);};
into void OnTick(), it asks to put it into global 'HourMQL4' - the function can be declared only in the global scope. Is it really necessary to put it there? If I do, there will be no error. Is a semicolon after a curly bracket necessary?
 
How to determine the current time in minutes from the beginning of the day?

I have thought of it this way:

datetime  vrema=TimeCurrent(MqlDateTime{int hour;});
int tek_vrema= vrema*60;
I'm not sure about the first line if the code is correct.
 
forexman77:
I try to put your function into void OnTick(), it asks to put it into global 'HourMQL4' - function can be declared only in the global scope. Is it really necessary to put it there? If I do, there will be no error. Is a semicolon after a curly bracket necessary?

The function cannot be included into a function.

 
forexman77:
How to determine the current time in minutes from the beginning of the day?

I thought of it this way:

I'm not sure about the first line if the code is correct.

This is correct:

   MqlDateTime tm;
   TimeCurrent(tm);
   int tek_vrema=tm.hour*60;
 
Good afternoon, could you please tell me the indicator or Expert Advisor that notifies with a beep after the formation of a candlestick pattern like in the picture. Ie the beep was after 7 opposite candles, or 6 candles, so this number can be changed. Thank you.
 
DC2008:

That's how it's done:

Thank you so 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

 MqlDateTime tm;
 TimeCurrent(tm);
 int tek_vrema=tm.hour*60+tm.min;

Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура даты
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура даты
  • www.mql5.com
Стандартные константы, перечисления и структуры / Структуры данных / Структура даты - Документация по MQL5
Reason: