ZigZag again

As one of the amazing abilities of man, we can highlight the ability to To see the inner beauty of another person behind external unsightliness or even ugliness. In such cases, we speak of the "beauty of the soul. This ability is not peculiar to all people, but nevertheless finds its expression in life everywhere.

I think many people know the feeling that makes you take home a scruffy, unkempt kitten that passersby chased away from the entranceway all day long, but it still clung to people, blindly continuing to believe in their kindness. Such persistence in preserving light feelings under unfavorable circumstances draws attention to itself, attracts the eye, and forces to make a reciprocal step.

Ugly Duckling

Strange as it may seem, such reasoning applies not only to various creatures, but also to all kinds of objects. After all, not all useful things are aesthetically beautiful, and conversely, not all beautiful things can do any good other than demonstrate their perfection to the world.

A stately swan slumbers in our ugly duckling, who will also become a guinea pig. It's an advisor with a silent name. "TL_v3" from Valery (valerasva). Program code expert The result of the program also leaves much to be desired, as the algorithm does not take into account even a fraction of the huge number of possible errors that can occur as a result of the trading functions. The result of the program also leaves much to be desired, as the algorithm does not take into account even a hundredth part of the huge number of possible errors that appear as a result of the trading functions.

As a result, even a simple system check in the strategy tester leads to a lot of problems. The tester's log is flooded with a flood of error messages, which makes it impossible to evaluate tactics based on a long historical period.

Such an ugly duckling dropped in for a peek. The answer to the reader's silent question, "Why waste time on such nonsense?" is the original thought that formed the basis of trading robotthat is, the trading system itself, which never found an acceptable embodiment. Let us consider it (see Fig. 1).

Idea

The following is used as a basic indicator ZigZagThe following table describes the labels in this manual. Idea is to construct rays that form the two sides of the triangle. The reference points for each of the rays are the last two maxima and minima zigzag. That is, the upper ray is built on the highs, and the lower ray - on the lows. The signal for the transaction is the crossing of one of the sides of the triangle. In this part, the system almost completely copies the DeMark strategy, only there fractals were used as reference points.

The case shown in Figure 1 describes only one of the six possible variants of the triangle. This is converging triangle, верхняя граница которого нисходящая, а нижняя – восходящая. Оставшиеся пять вариантов схематично можно изобразить так (см. рис. 2 — 6).

The situations shown in Figures 1, 2, and 3 represent converging triangle. Following DeMark's system, in each case we should have traded on a breakout of any triangle boundary. But situation 1 describes a flat, while situations 2 and 3 describe a downtrend and an uptrend, respectively. While in the flat it is still possible to talk about a high probability of price movements towards a breakout of one of the figure's borders, it is more difficult with a trend, because trends often abound in corrections. Therefore, the best way out would be to ignore cases 2 and 3 without making any trading decisions.

Figures 4, 5, and 6 describe situations with divergent triangles. These are moments of the market going in a wide flat, each of the phases of which can be identified as a small trend.

Figure 4 illustrates a triangle diverging in different directionswhich makes it impossible to determine the prevailing direction of price movement. Therefore, this situation, along with situations 2 and 3, will be ignored. But the cases shown in Figures 5 and 6 allow us to clearly determine the trend. That is why in situation 5 we should move upwards with the market, buying, and in situation 6 we should move downwards, selling.

Trading signals

Thus, the resulting trading system will consist of three signals:

Expert and Testing

The described system is implemented in the Expert Advisor TriangleByZigZag. Тестирование эксперта проведем на таймфрейме Н1 и историческом диапазоне 01.01.2009 – 01.01.2010. Для валютных пар с базовой валютой доллар США (EURUSD и GBPUSD) взяты параметры зигзага – 3, 5, 3. Для валютных пар с другой базовой валютой (USDJPY и USDCHF) применены параметры зигзага – 4, 5, 3. Во всем остальном параметры эксперта установлены по умолчанию (см. рис. 7 — 10).

Positive results were obtained only on two pairs - GBPUSD and USDJPY. But we cannot call them acceptable, because in both cases the net profit does not exceed the maximum drawdown. Проведя анализ результатов тестирования, приходим к выводу, что многие сделки по сигналам 2 и 3 (см. перечень сигналов, а не ситуаций, показанных на рисунках 1 — 6) совершались в конце трендов, когда уже можно было нащупать сигналы разворота тренда.

Problem Solution

The solution to the problem could be filtering of received signals using some trend indicator or oscillator. For example, the MACD oscillator "feels the trend" very well. We add it to conditions 2 and 3. Confirmation of signal 2 (purchase) will be to find the signal line MACD below the histogram. Accordingly, the MACD signal line above the histogram will confirm signal 3 (sell).

The result is the second version of the expert TriangleByZigZag_V2. Ее тестирование проведем на тех же условиях, которые были приняты для первой версии эксперта (см. рис. 11 — 14).

MACD Oscillator has said its weighty word, but has not become a miraculous balm for all ills. In all cases, the maximum drawdown has significantly decreased and the net profit has increased, which can already be considered an achievement. Let's take a closer look at two successful currency pairs.

GBPUSD. It has the most pronounced ascending balance curve, though far from ideal. Achieved net profit $1,141 with a maximum drawdown of $670. And this is a recovery factor close to two (1.7). The line between profitable and losing trades is very thin - 53.96% versus 46.04%, but even this is enough to achieve profit. If we consider the possibility of using the strategy in real trading, the minimum capital can be called a figure of 2010 dollars (triple margin of drawdown). In this case the expected profit will be slightly more than 50% annual.

USDJPY. The sharp rise of the balance curve at the beginning of testing did not find support in the subsequent history. But a significant part of the achieved positions was nevertheless retained. Net profit $744.5 with a maximum drawdown of $648.18. In this case the line between profit and loss is very thin. Therefore one should not seriously speculate on the real use of the strategy on USDJPY.

Conclusion

If we proceed only from the test results, the beautiful swan from the ugly duckling could not grow, but the duckling is not so ugly now. In this case, it is worth discounting the fully automatic mode of transactions, which is not ideal in the analysis of geometric shapes. The skillful trader's hand will be able to increase the profit and decrease the drawdown, working in tandem with the Expert Advisor TriangleByZigZag_V2.

To download

Test.zip - detailed results of testing the Expert Advisors.
TL_v3.mq4 - The original version of the advisor.
ZZtl.mq4 - indicator displaying the triangle lines on the zigzag tops.
TriangleByZigZag.mq4 - The first version of the strategy with streamlined trading rules.
TriangleByZigZag_V2.mq4 - The second version of the strategy with trade filtering based on MACD.

Leave a Reply

Back to top button