Discussion of article "The Principles of Economic Calculation of Indicators"

 

New article The Principles of Economic Calculation of Indicators is published:

Calls to user and technical indicators takes up very little space in the program code of automated trading systems. Often it’s simply a few code lines. But it often happens that it is these few lines of code which use up the largest portion of time, which needs to be spent on testing the Expert Advisor. Therefore, everything that is related to data calculations within an indicator, needs to be considered much more thoroughly than would seem at first glance. This article will talk precisely about this.

Fig.11 The result of passing the test with the Expert Advisor AMA_Ex_Test

Author: Nikolay Kositsin

 

Thank you for the article.

I have one question. You use the first form of the indicator to optimise indicator calculations, there is begin. But if you can not use it (for correct calculations need open[], high[], low[], close[] ...) how to be? There is no begin in the second form.

 
Prival:

Thank you for the article.

I have one question. You use the first form of the indicator to optimise indicator calculations, there is begin. But if you can't use it (for correct calculations you need open[], high[], low[], close[] ...) how to be? There is no begin in the second form.

And it is not needed there, because the input parameters are always price characteristics - they are in all elements, it does not use an "arbitrary" array filled only from begin.
 

not everything is considered, but in general it is still interesting =)

and specifically such a thing as optimisation of technical indicators call is not considered.

I think this topic is quite relevant.

 

more precisely, how to initialise the technical indicator better

in general the function of data checking is implemented

but the example of initialisation is not exactly considered

as far as it is known from the help

Нельзя обратиться к данным индикатора сразу после его создания, так как на расчет значений индикатора требуется некоторое время, и поэтому создавать хэндлы индикаторов лучше всего в OnInit(). Функция iCustom() создает соответствующий пользовательский индикатор и при успешном создании возвращает его хэндл. Пользовательские индикаторы могут содержать до 512 индикаторных буферов, содержимое которых также можно получать при помощи функции CopyBuffer(), используя полученный хэндл.

how best to bypass this feature....

 

I'm always wondering the same thing.

   if (Handle == INVALID_HANDLE)  Print(" Failed to get SMA indicator handle");

if this condition works, what do I do? Let's say it's the championship, that's it... init won't run anymore.

 
Prival:

I've been wondering the same thing all along.

if this condition works, what do I do? Let's say it's the championship, that's it... the init won't run anymore.

Yes! It's an undocumented fact, I didn't know that either! We should definitely look into it! But it's easier for me, I'll pack all the turkeys into the Expert Advisor itself and that's it, so that the Expert Advisor runs like a sprinter on marathon distances and doesn't stumble anywhere and never!

 
Prival:

I'm always wondering the same thing.

If this condition works, what should I do? Let's say it's a championship, that's it ... the init won't run anymore.

First of all, get the error code and output it to the log. And try to access it again in OnTick() or OnCalculate(). If you fail to get the indicator handle, most likely there is no such indicator or there is not enough memory. In this case, the Expert Advisor has no right to trade.
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений
  • www.mql5.com
Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений - Документация по MQL5
 
Rosh:
First of all, get the error code and output it to the log. And try to access it again in OnTick() or OnCalculate(). If you fail to get the indicator handle, most likely there is no such indicator or it lacks memory. In this case, the Expert Advisor has no right to trade.

Well, here we are! We can do it ourselves! In such a situation, if we could make the OnInit() function return minus one to call OnInit() again and so on until the handle appears! But now it's clear that if you don't overstress your computer, there will be no reason for not getting the handle. But I've seen this once when updating a build, it can be cured by recompiling the indicator!

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - Документация по MQL5
 
Minus one can be returned, but it does not bode well for the EA/indicator.
 
Fortunately, the error of indicator creation due to the fault of the terminal practically does not occur.