Beginner's questions in MQL5. Professionals don't pass by.

 

Decided to create a topic similar to the existing one on the 4 forum, there's a popular trail to it). If it's repeated, kill it without regret.

Of course the theme is not just for fun. I decided to tackle MQL5 and several questions appeared at once:

1) is the scope of structures the same as that of simple variables?

2)MqlRates structure. I want to find the last 10 extrema and therefore I do not know how much price data I will need. Shall I copy all available data? Isn't it resource consuming?

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

1) Is the scope of structures the same as just variables?

Structures are one of the data types (composite data types). Therefore, it is better to talk about variables of structure type. The rules about scope apply equally to variables of simple types and structure types. So far I haven't seen any exceptions.

Figar0:

2)MqlRates structure. I want to find the last 10 extrema and therefore I do not know how much price data I will need. Shall I copy all available data? Isn't it resource consuming?

:) It all depends on the level of extremum. If an extremum is being searched for over the entire observation period, there is no way to get 10 items even if "to copy all available data".

Actually, it is not always necessary to use the predefinedMqlRates structure. In many cases, it is sufficient to create your own "light" structure (e.g., high-low) and work with variables of that type. I can't say anything about resource consumption, because I'm not interested in this question (I do without usingMqlRates structure).

 

Another one of my approaches to MQL5: I decided to use its capabilities to optimize Expert Advisors since MT4 allows me to optimize them within 24 hours, and the capabilities of multicore processors and agents are so dissimilar... However, before bothering with recoding "real" Expert Advisors, I decided to check what I will get. I have written a simple Expert Advisor with perseptron ala AI Reshetov, not even indicators to enter but simple close price difference, I have optimized it by H4 open prices, a year ago. CPU cores are all loaded, and agents seem to be working, and cloud is moving, but.... :Slower than in MT4 many times simply Why is everything so sad????

Знакомство с MQL5: написание простого советника и индикатора
Знакомство с MQL5: написание простого советника и индикатора
  • 2010.03.16
  • Denis Zyatkevich
  • www.mql5.com
В этой статье проведен краткий обзор языка MQL5, приведен пример написания советника и индикатора. Данная статья ориентирована как на читателей, знакомых с программированием на языке MQL4, так и на тех, кто только начинает знакомство с программированием торговых систем и индикаторов.
 
Figar0:

Another one of my approaches to MQL5: I decided to use its capabilities to optimize Expert Advisors since MT4 allows me to optimize them within 24 hours, and the capabilities of multicore processors and agents are so dissimilar... However, before bothering with recoding "real" Expert Advisors, I decided to check what I will get. I have written a simple Expert Advisor with perseptron ala AI Reshetov, not even indicators to enter but simple close price difference, I have optimized it by H4 open prices, a year ago. CPU cores are all loaded, and agents seem to be working, and cloud is moving, but.... :Slower than in MT4 many times simply Why is everything so sad????

Somewhere there is a logical error in the code. I don't believe that MT5 is slower than MT4.
 
Figar0:

Another one of my approaches to MQL5: I decided to use its capabilities to optimize Expert Advisors since MT4 allows me to optimize them within 24 hours, and the capabilities of multicore processors and agents are so dissimilar... However, before bothering with recoding "real" Expert Advisors, I decided to check what I will get. I have written a simple Expert Advisor with perseptron ala AI Reshetov, not even indicators to enter, but differences of close prices. I optimize it by H4 open prices, a year ago. CPU cores are loaded, and agents seem to be working, and cloud is moving, but.... :Slower than MT4 many times over Justwhy everything is so sad????

Probably because MQ4 and MQ5 files are not attached.

There are programmers here. It is improper to ask such questions without attaching the source code.

 
Renat:

Probably because the MQ4 and MQ5 files are not attached.

There are programmers here. It is not good to ask such questions without the source code attached.

I'm far from thinking that my code is a model of perfection, I wrote it in 20 minutes, and just to check, moreover, given that in MQ5 I'm still a pig in oranges), but I think there is nothing so terrible for performance. Here it is.
Files:
First.mq5  19 kb
 
and MQ4?
 

Renat:
 MQ4?

And in MQ4 I just took ArtificialIntelligence.mq4 and attached it just in case, of course they are not identical, but they are almost equally time-consuming, at least simply due to their simplicity. But here's what we have:

On 8 cores in MT5 (disabled all agents):

2011/11/11 15:01:07 PM Statistics locals 13371 tasks (100%), remote 0 tasks (0%), cloud 0 tasks (0%)
2011.11.11 15:01:07 Statistics passed in 1 hours 07 minutes 51 seconds

Total: 4071/13371=0.3044 sec per pass.

On one core in MT4:

2011.11.11 15:17:40 There were 6345 passes done during optimization
2011 11/11/11 15:17:40 ArtificialIntelligence: optimization stopped, 2103 cache records were used, 2103 cache records rejected
2011.11.11 15:17:12 ArtificialIntelligence: optimization started

Total: 28/6345=0.0044129 sec per pass.

Two orders of magnitude . Both are genetics, EURUSD H4 open prices, interval from 1.01.11 till today, single computer, Win7 x64. What slows down the optimization in MT5 so much? Do I have such a critical error there????

 
Figar0:

Two orders of . Both are genetics, both are EURUSD H4 opening prices, interval 1.01.11 to today, same computer, Win7 x64. What is so slowing down the optimisation in MT5? Do I have such a critical error there????

What is the simulation type, 1 or 2?


 
Rosh:

What type of modelling, 1 or 2?

" Opening prices only", the second must be
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы - Документация по MQL5
 

I think I am beginning to understand what is going on here:

2011.11.11 16:11:37 Core 1 EURUSD,H4: 1271227 ticks (1344 bars) generated within 1326 ms (total bars in history 2904, total time 1372 ms)

Why are there so many ticks at opening prices? Moreover, if I put "OHLC on M1" model, the same thing happens:

2011.11.11 16:15:48 Core 1 EURUSD,H4: 1271227 ticks (1344 bars) generated within 2075 ms (total bars in history 2904, total time 2106 ms)

I double-checked it 10 times and with the first and second type of builds (from Rosh's picture) number of ticks does not change..... Imho not good, or I'm doing something wrong?

Build 527.

Z.I. Tested all the ticks:

2011/11/11 16:24:55 Core 1 EURUSD,H4: 18578763 ticks (1344 bars) generated within 24819 ms (total bars in history 2904, total time 25319 ms)

With the "all ticks" model there are only 14 times more ticks than with the "open prices" model on H4. Either I'm nuts, or one of two ... So the "opening price" model just doesn't exist?