Since we finally have an OOP indicator, what is the point of calling it from the Expert Advisor (iCustom), when we can create a calculated indicator object in the Expert Advisor itself and access the vertices via a certain operator []? It should be faster that way.
There are not enough ticks in the source data. Probably, all articles now (with the appearance of a fast and not buggy implementation of CopyTicks) should take this fact into account. We cannot pretend that we have only bars.
For the article Thank you. For beginners it is probably the best.
1. Since we finally have an OOP indicator, what is the point of calling it from the Expert Advisor (iCustom), when we can create a calculated indicator object in the Expert Advisor itself and access the vertices via a certain operator []? It should be faster that way.
2. There are not enough ticks in the source data. Probably, all articles now (with the appearance of a fast and not buggy implementation of CopyTicks) should take this fact into account. We cannot pretend that we have only bars.
3. For the article Thanks. For beginners, it's probably a good one.
1. This is a wrong idea. The indicator works using indicator buffers and parameters rates_total and prev_calculate. The point of the indicator is in using buffers. There are no indicator buffers in the Expert Advisor, as well as rates_total and prev_calculate.
2. I disagree. It is a personal matter. And in general, the point is only that we should recalculate ticks on each bar.
3. A philosophical question arises - who is a beginner?
1. this is a wrong idea. The indicator works using indicator buffers and parameters rates_total and prev_calculate. The point of the indicator is in using buffers. There are no indicator buffers in the Expert Advisor, as well as there are no rates_total and prev_calculate.
Why can't the ZZ object be a full-fledged data source for the Expert Advisor? To create different entities (different programs) and then connect them via iCustom - it is easier to create an object directly in the Expert Advisor. The fewer "details", the more reliable the "mechanism".
But this is probably an eternal argument. OOP only tilts it to one side even more.
2. I disagree. It's a personal matter. And anyway, the point is just that ticks should be recalculated on every bar.
Gave ticks to be ignored.
3. A philosophical question arises - who is a beginner?
1. Why can't the ZZ object be a full-fledged data source for the Expert Advisor? To create different entities (different programs) and then connect them via iCustom - it is easier to create an object directly in the Expert Advisor. The less "details", the more reliable the "mechanism".
2. But this is probably an eternal dispute. OOP only tilts it to one side even more.
3. Gave ticks to ignore.
Who might benefit from this article.1. OOP has nothing to do with solving this problem. Besides, the most complete source of data for the Expert Advisor is the indicator. The Expert Advisor does not provide the functional capabilities for processing time series that the indicator does.
2. The problem of OOP is that many adult programmers did not study it as children and therefore have difficulties in understanding and applying it.
3. Where is the tick chart? There must be a tick chart. If there is no tick chart, creating indicators on tick charts is an artisanal process.
4. Can be useful for everyone. This is the quintessence of the zigzag :) In my opinion, the value of the article is not in the fact that OOP is applied in it. The part with OOP is a routine part with no special value in my opinion. But the beginning of the article, where the creation of an indicator by hi-lo and by cloze is considered, is worth reading for everyone (with rare exceptions).
1. OOP has nothing to do with the solution of this problem. Besides, the most complete source of data for the Expert Advisor is the indicator. The Expert Advisor does not provide the functional capabilities to process time series, which the indicator provides.
At least one argument. The only thing they like to repeat is the guaranteed preparation of timeseries in indicators when entering OnCalculate. And OnTick does not have such a guarantee. It is only 99.99999999% in OnTick, not 100%.
2. The problem of OOP is that many adult programmers didn't study it as children and therefore have difficulties in understanding and applying it.
An indicator is an object. OOP also allows you to create objects. But only not to create additional entities in the form of separate programmes.
3. Where is the tick chart? There must be a tick chart. If there is no tick chart, creating indicators on tick charts is an artisanal process.
What does a tick chart and initial data in the form of ticks have to do with it? An Expert Advisor doesn't care whether there are charts or not. And if an indicator is able to analyse the history of ticks, it means that it is built on ticks. And the lack of visualisation is a hello to VPS. I.e. it is not needed in some situations.
4. It can be useful for everyone. This is the quintessence of a zigzag :) In my opinion, the value of the article is not in the fact that OOP is applied in it. The part with OOP is a routine part with no special value in my opinion. But the beginning of the article, where the creation of an indicator by hi-lo and by cloze is considered, is worth reading for everyone (with rare exceptions).
At least one argument. The only thing they like to repeat is guaranteed preparation of time series in indicators when entering OnCalculate. And there is no such guarantee in OnTick. It is only 99.99999999% in OnTick, not 100%.
An indicator is an object. OOP also allows you to create objects. But do not create additional entities in the form of separate programs.
What does a tick chart and initial data in the form of ticks have to do with it? The Expert Advisor doesn't care whether there are charts or not. And if an indicator is able to analyse the history of ticks, it means that it is based on ticks. And the lack of visualisation is a hello to VPS. I.e. it is not needed in some situations.
I said it right away - for beginners.The most difficult thing is to write an article for beginners. Not everyone can do it.
It is even more difficult to write an article that will be useful for both beginners and experts.
It would be good to write in each article for whom the article is intended. Which sections are for beginners, which ones are for specialists, which ones complement the documentation, cross-references to already existing publications on this topic and so on.
If the article is for beginners, it is usually written whether the material is sufficient for understanding -- and if there may be difficulties in understanding the material, what material is better to get acquainted with before reading.
p.s. Of all the technical literature, it is the textbooks for beginners that become bestsellers.
1. this is a wrong idea. The indicator works using indicator buffers and parameters rates_total and prev_calculate. The point of the indicator is in using buffers. There are no indicator buffers in the Expert Advisor, as well as rates_total and prev_calculate.
Dmitry, you are wrong here. The idea of working with Zig Zag through a class, bypassing iCustom, is very correct. In fact, a zig zag is a list of lines, each of which has a lot of properties:
- Line direction (up/down)
- Index of the bar where the line starts;
- Index of the bar where the line ends;
- The price of the beginning of the line;
- The price at which the line ends;
- Line Start Time;
- Line end time;
- ...
Instead of working with two-bit information through the buffer: there is a line/no line, we need to create a class in which all possible information is calculated automatically and fed conveniently directly into the Expert Advisor or directly into the indicator. At the same time, one single class should be able to work with different types of data, for example, with bars, closing prices or tick stream.
To summarise: it is useful for beginners. But using OOP will still scare them off.
p.s. Of all technical literature, it is textbooks for beginners that become bestsellers.
No work for specialists can become a bestseller by definition - there are few specialists.
Just in case, I do not include myself to them. The article is for guys who have just started to master or are about to. It's good.
To be properly understood, I will give links to two articles.

- 2016.10.06
- //www.mql5.com/en/users/marketeer">
- www.mql5.com
Dmitry, you are wrong here. The idea of working with Zig Zag through a class, bypassing iCustom, is very correct. In essence, a zig zag is a list of lines, each of which has a lot of properties:
- Line direction (up/down)
- Index of the bar where the line starts;
- Index of the bar where the line ends;
- The price of the beginning of the line;
- Price of the line ending;
- Line Start Time;
- Line end time;
- ...
1. Instead of working with two-bit information through a buffer: there is a line/no line, it is necessary to create a class in which all possible information is calculated automatically and fed conveniently directly into the Expert Advisor or directly into the indicator. At the same time, one single class should be able to work with different types of data, for example, with bars, closing prices or tick stream.
2. To summarise: it is useful for beginners. But using OOP will still scare them off.
1. No. It's just a small modification to the indicator. It's just that the article is huge enough as it is. I had an idea to write another article, just to make such an addition and consider a class for solving formulas (you would get a zigzag with the function of recognising patterns, the formula of which would be written in the properties window). But Rashid was not interested in the topic. And it is impossible to cram everything into one article. If anyone has noticed, I had one more variant of the zigzag (based on pullbacks from the last maximum/minimum), but there was nothing about it in the article.
Besides, the article still deals with the method of direct access to vertex values. OOP in general is very indirectly related to this issue, it's a matter of taste what to wrap it in, and it is solved without OOP, just as vertices appear, put them in an additional buffer in order, and at the beginning of the buffer write their number. In this case, access to any vertex is done in two steps - getting the number of vertices, getting a given vertex from the end. There is a little difficulty with zigzag like on close (because of cancellation of a new ray), but it is solvable. But what does OOP have to do with it?
2. In case OOP will scare someone off, the article is made of two parts, before OOP (creation of two indicators) - it is enough to understand how to write a zigzag.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Universal ZigZag has been published:
ZigZag is one of the most popular indicators among the MetaTrader 5 users. The article analyzes the possibilities for creating various versions of the ZigZag. The result is a universal indicator with ample opportunities to extend its functionality, which is useful in the development of trading experts and other indicators.
For clarity, let us create an indicator that draws arrows when the indicator line changes direction (changes in the value of the DirectionBuffer buffer) and which places dots on the bars where the new High/Lows of the ZigZag had been registered (changes in the values of the LastHighBarBuffer and LastLowBarBuffer buffers). The code of this indicator will not be discussed in details, it can be found under the name of "iUniZigZagSWEvents" in the attachments. The indicator appearance is shown in the Fig. 8.
Fig. 8. The iUniZigZagSWEvents indicator
Author: Dmitry Fedoseev