An advisor without an indicator. Is this possible? - page 3

 
Алексей Тарабанов:

A dangerous misconception.

What is the misconception?
If you need a history array, do it. If you don't need it, don't do it.
Personally, I mostly do an array, as I often use internal tests etc.. But my array is rarely equal to the number of bars in the chart. Sometimes less, sometimes more.
Take a common zigzag for example. There are less than 10% of informative array elements and the rest are empty, but the entire array is enumerated. So? Is it efficient? Obviously, it is more correct to use a shorter array of structures with value and index.
 

But my array rarely equals the number of bars in the chart. Sometimes less, sometimes more.

What worries me is that it could be bigger.

 
Nikolai Semko:
First, who prevents you from having an internal data array, the same as the indicator buffer, and fill it in the same way.
Secondly, why would an advisor need all the history. As a rule, the last and maybe the penultimate value. And we don't need all these indicator stuff.

And what is more reasonable in terms of resources, to calculate in an indicator or to calculate the same in the Expert Advisor, which is faster?

 
Алексей Тарабанов:

But my array rarely equals the number of bars in the chart. Sometimes less, sometimes more.

What worries me is that it might be bigger.

You're worrying in vain, Alexey.
There may be situations where this is necessary, gugilen.
For example.
I mostly use minute bar data or ticks, regardless of the TF.
It's very wrong and wasteful when your Expert Advisor has to recalculate all buffer indicators every time you change TF. I don't have that happening to me.
Therefore, if I'm on a weekly timeframe, my array will obviously be much larger than the number of bars in the chart.
And I'm not even speaking about ticks.
As a rule, I have several arrays of structures and index arrays to increase productivity and save memory. Their dimensions may be different.
Generally speaking, when you use indicators via iCustom, you are very limited in many things.
You are rigidly bound to the array size equal to the number of bars in the chart. What if you have unlimited standing there?
You are only bound to one type of double. And you cannot even dream of having an array of structures.
It's even ridiculous with color indicators. 8 bytes per bar is obviously too much.
Indicator buffers are very wasteful in terms of memory consumption.
Moreover, you have access to the buffers only through CopyBuffer, even if you need only one last bar. In any case, this operation is much slower than simple array element access.

Of course, if you're using standard built-in indicators like iMA, you don't have to bother. But nevertheless I think we are talking about custom indicators here. I don't think that pros use built-in indicators for real trading.


 
VVT:

And what is more expedient in terms of saving resources, counting in an indicator or counting the same in an EA, which is faster?

I partially answered in the previous post.
This is a very long question and it's better to ask developers, especially those who are responsible for multithreading.

I am not a specialist in this question. But I can share my thoughts. If I'm mistaken about something, please correct me if you know correctly.
As you know, every Expert Advisor works in a separate thread, while all the indicators of one symbol (even in different charts) work in one common thread.
Therefore, we can assume that if the symbol is not overloaded with indicators, the work of the Expert Advisor and indicator buffer calculation will run in parallel and even in different CPU cores, if the OS scheduler is lucky to find a separate processor core for your indicator thread. It is quite possible that you will get more efficient results in such scheme. I do not know how much probability to get a separate core for an indicator thread is, but I think it is not very high.
But there are such notions as thread context switching speed and many other subtleties of interaction of multiple threads. I know that the speed of context switching of threads is very high in comparison with the processes, but it is not free.
Moreover, as I said before access to the indicator buffer element through CopyBuffer will be more expensive than access to an array element by its index.
Also the ability to optimizeunnecessary calculations, the size of internal arrays and their indexinginside the Expert Advisor provides great potential for reducing the resource consumption.
Of course, you will need experiments and proper tests to give you the full answer to your question. But I am still more inclined to believe that the average performance is better - all in one Expert Advisor thread.

 
Dmitry Fedoseev:

And run every time in a cycle? The EMA would be even more interesting.

Use the single-pass algorithm for calculating theexponentially weighted average

ma = (1 - a) * price + a * ma

 
Dmitry Fedoseev:

A normal indicator counts all the bars only at the start, and then it counts 1 bar afterwards. In the indicator it is easy to make SMA in such a way, that even at the calculation of 1 bar there is no need to cycle through the whole period of MA.

Of course, we can create array buffers in the Expert Advisor. But what for, if there is a specially designed element - indicators?

So what is the problem? A new bar appeared - we considered it.

 
anim:
I want the Expert Advisor not to be tied to an indicator. Itwould calculate the bars and take buy/sell signals internally. Is it possible?
Of course it is possible, if you implement the formula of the indicator into the Expert Advisor!
 
Vladimir Mikhailov:

Use the one-pass algorithm to calculate anexponentially weighted average

ma = (1 - a) * price + a * ma

This is not correct!

Correct is:

ma[i] = (1 - a) * price + a * ma[i+1]

i.e. we need an array whose necessary depth depends on parameter a.

Otherwise it will be a total nonsense, at least as long as the transition process lasts, which can take quite a long time, depending on the parameter a.

It is easy to check all this by comparing the indicator readings with the corresponding calculations in the EA.
 
Dmitry Fedoseev:

Of course, it is possible to make buffers from an array in the Expert Advisor as well... But why, when there is a specially designed element - indicators?

I have a problem with skipping signals from an indicator, no one gave a recommendation

https://www.mql5.com/ru/forum/365021

the prints show that the event comes from the indicator, checks for a new bar, and there is the data from the previous bar, not the new one

i have tested in 3 terminals at the same time, both omissions were in one of the three terminals, may be it is random

В моих ТС пропуск сигнала
В моих ТС пропуск сигнала
  • 2021.03.16
  • www.mql5.com
Не люблю создавать новые темы, Небольшие исходные данные: Советник работает в OnChatEvent, 7 символов, циклов нет, прямая передача номера за минусо...
Reason: