MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal

Automated Trading, Strategy Testing and Optimization Articles

Buy Expert Advisors in MetaTrader Market and Let Them Trade For You
To post a new article, please log in or register

AutoElliottWaveMaker - MetaTrader 5 Tool for Semi-Automatic Analysis of Elliott Waves

| 2 May, 2012 | Views: 7654 | English Russian Chinese Spanish Portuguese


Introduction

The article "The Implementation of Automatic Analysis of the Elliott Waves in MQL5" dealt with the Elliott Wave automatic wave labeling algorithm that suffered from a few imperfections, one of which being its slowness. Realizing that, and the fact that automatic analysis on its own is not really suitable for practical use, it was decided to develop a semi-automatic wave labeling tool that would offer a number of advantages:

  • Human-controlled labeling;
  • High speed of the analysis due to the fact that only the user-specified part of the chart is analyzed.

This program was called AutoElliottWaveMaker and will be introduced in this article.  AutoElliottWaveMaker is a logical development of the manual wave labeling tool which can currently be bought in the Market.


1. Program Objects

The main objects of the program are labels and the labels panel (Fig. 1).

Labels panel

Fig. 1. The labels panel

The labels panel represents a sequence of labels of one wave level situated in the top left part of the chart. The position of the panel and the distance between the labels are customized by the user in the program input parameters (Fig. 2):

  • interval - the distance between the labels on the labels panel;
  • x_distance - the position of the labels panel along the X-axis relative to the top left corner of the chart;
  • y_distance - the position of the labels panel along the Y-axis relative to the top left corner of the chart.

Input parameters

Fig. 2. Input parameters of the program

The labels panel also displays the name of the current wave level (Fig. 1).

You can hide/show the labels panel by pressing the Esc key. To display the labels of the preceding or the following wave level on the labels panel, press Q or W, respectively.

Labels can be moved from the labels panel using the drag and drop method. Upon the move of a label, the labels panel is restored to its initial state. The panel is not restored after a label is removed from the labels panel. In order to restore it, you have to go to another wave level and then back.

The number and style of wave levels and labels is set in the Levels.txt file automatically generated when you first start the program. The Levels.txt file is located in the Files folder of the MetaTrader 5 terminal data directory. By editing the file, the user can change the style of wave levels (Fig. 3).

Description of levels

Fig. 3. Levels.txt content

Let us take the fourth line of the file as an example and have a look at it:

  • SubMinuette - name of the wave level;
  • i, ii, iii, iv, v, a, b, c, d, e, w, x, y, xx, z - wave tops;
  • Times New Roman - font;
  • 8 - font size;
  • 15 - font height in pixels;
  • 255, 140, 0 - color in RGB format.

When editing the file, the following constraints should be set:

  • the number of wave tops shall be 15;
  • notations for every wave top shall be different.

Further, to ensure the proper operation of the program, it is necessary to set "Unlimited" as the "Max bars in chart" value in the MetaTrader 5 terminal settings (Main Menu-Tools-Options-Charts).


2. Wave Labeling Process

Elliott Waves are labeled in the manual and/or automatic mode.

The manual mode, in its turn, presupposes two ways of labeling:

  1. By dragging the labels from the labels panel;
  2. By clicking near the bars on the chart.

The automatic mode suggests that the chart is labeled based on the program's algorithm. That said, the analysis can cover the entire chart or any part thereof (from one label to another), as specified by the user.


2.1. Manual mode

In the manual labeling mode, the labels appear above or below the bars by themselves and are adjusted automatically when the chart scale or size changes. The labels are placed in the order of precedence of wave levels. Thus, if there are two or more wave labels above or below the same bar, the label of the senior wave level will be placed respectively higher or lower than the label of the junior wave level (Fig. 4 and Fig. 5).

Position of labels before labeling

Fig. 4. Position of labels before labeling

Position of labels after labeling

Fig. 5. Position of labels after labeling


Fig. 4 shows that there is a label (A) of the SubMicro wave level above the bar. Label 5 was placed above the same bar on a lower level - SuperMicro. Since the SuperMicro level is lower than SubMicro, label 5 appears under the label (A) (Fig. 5).

Consideration must also be given to the fact that when labeling manually, wave labels are placed above/below the nearest bar whose high/low is higher/lower than those of the neighboring bars. This specific feature allows to position labels in the chart more accurately.

As mentioned above, labeling in the manual mode can be done in two ways. And while the drag-and-drop procedure is more or less clear, the click-based labeling has its peculiarities.

When labeling using the mouse clicks, you should select a label on the labels panel. It can also be done by pressing the Z key in succession (in which case you can switch between the labels on the panel as you cycle through). The labeling of the current wave level is then done by clicking the mouse at required bars on the chart. To complete the labeling process, click on any label or press the X key.

The labeling continues for as long as there is a selected label on the labels panel. Every mouse click selects the successive label. The last label completes the click-based labeling process.


2.2. Automatic mode

Automatic labeling of the chart is done using control keys. There are three automatic labeling variants:

  1. Chart analysis up to selected label;
  2. Chart analysis after selected label;
  3. Analysis of the entire chart if no label is selected.

The first variant of automatic labeling is performed upon pressing 1. The chart will in this case be analyzed from its beginning up to the selected label, if there is no other label on its left. Otherwise the analysis will be performed from the nearest label on the left up to the selected label.

Fig. 6 shows two labels in the chart. The second label is selected. After pressing 1, the part of the chart between the labels will be analyzed. The result of the analysis is shown in Fig. 7.

Prior to analysis 1

Fig. 6. Initial state of the chart prior to pressing 1


After analysis 1

Fig. 7. Result of the automatic analysis of the part of the chart between the labels

The second variant of labeling is activated by pressing 2. The chart will in this case be analyzed from the selected label up to the end of the chart, if there is no other label on its right. Otherwise the analysis will be performed from the selected label up to the nearest label on the right.

Fig. 8 displays one label in the chart. This label is selected. After pressing 2, the analysis will be performed for the part of the chart from the label up to the end of the chart. The result of the analysis is shown in Fig. 9.

Prior to analysis 2

Fig. 8. Initial state of the chart prior to pressing 2

After analysis 2

Fig. 9. Result of the automatic analysis of the part of the chart from the label up to the end of the chart


The third variant of the analysis will start after pressing 1 or 2. All the chart labels in this case will first be removed.

Immediately following the automatic analysis of Elliott Waves, the variants of labeling will be available for viewing.

There are 3 options available to view the analysis results:

  1. Viewing the labeling variants of the selected wave;
  2. Viewing the labeling variants of the wave following the selected wave;
  3. Viewing the labeling variants of the analyzed section of the chart if no wave label is selected.

You can navigate through the labeling variants using the following keys: 3 (view the previous variant) and 4 (view the next variant) for the first viewing option, 5 (view the previous variant) and 6 (view the next variant) for the second viewing option, and any of the above keys for the third viewing option.

Fig. 10 demonstrates the next labeling variant for the wave that was previously automatically labeled and showed in Fig. 7.

The next labeling variant

Fig. 10. The next labeling variant for the selected wave

As can be seen in Fig. 7, 9 and 10, some labels are displayed in gray which is the color labels take before the start of the automatic labeling. These are labels that were present in the chart before the analysis. And they are not available for mouse selection. All of this is necessary to distinguish between the manual and automatic labeling.

To convert automatic labeling into manual, you need to press the V key whereupon all the labels in the chart will take their former color and will be available for selection. However once the V key has been pressed, viewing of the labeling variants becomes impossible.

Information on the name of any wave obtained after the automatic analysis is also available to the user. This information is displayed in the top part of the chart (Fig. 11) immediately following the analysis, after a label is selected or control keys for viewing the labeling variants are pressed.

Information on the wave type

Fig. 11. Information on the selected wave type

It should be noted that automatic analysis is performed on the basis of certain wave rules. Wave identification rules are stored in the Rules.txt file generated when you first start the program. This file is located in the Files folder of the MetaTrader 5 terminal data directory.


3. Extra Features

Any label in the chart can be included into a certain group of labels that can be selected. A group of labels is selected by selecting any label in the chart and pressing the Tab key. Selection covers all labels forming the same group with the selected label. To deselect, press the Tab key one more time.

Labels can be added to a group by selecting any label and then creating new labels. New labels are added to the group to which the selected label belongs.

Every selected label in the chart can be manipulated as follows:

  • Deleted using the Del key;
  • The wave level can be decreased or increased using the A or S keys, respectively.

Further, the program algorithm features an automatic mechanism determining the number of displayed wave levels on the current time frame. The algorithm is based on the following principle: labels with different coordinates along the time axis cannot be placed on the same bar. The number of wave levels can also be controlled manually using the E and R keys that allow to decrease and increase wave levels, respectively.


4. List of Keyboard Commands

Fig. 12 shows all applicable keyboard commands and their descriptions.

Keyboard commands

Fig. 12. Keyboard commands


Conclusion

The article has introduced the first development for semi-automatic analysis of Elliott Waves in MetaTrader 5. This program has a number of unique features:

  • Automatic binding of wave top labels at the bars in charts of all time periods;
  • Labeling of wave tops by both dragging labels from the labels panel and clicking the mouse in succession;
  • Automatic labeling of wave tops in the order of precedence of wave levels in charts of all time periods;
  • Automatic and manual control over the number of wave levels displayed in the chart;
  • Creating custom styles for labeling wave levels;
  • Automatic analysis of Elliott Waves covering the entire chart as well as a part thereof (from one label to another);
  • Viewing the variants of automatic labeling;
  • Ability to edit wave rules;
  • Control over the labeling process using the mouse and keyboard.

This development demonstrates great resources of the MQL5 language and will hopefully encourage developers to create complicated and interesting programs.


Translated from Russian by MetaQuotes Software Corp.
Original article: http://www.mql5.com/ru/articles/378

Last comments | Go to discussion (2)
Sergey Golubev
newdigital | 13 Mar 2014 at 09:40

Forum on trading, automated trading systems and testing trading strategies

Discussion of article "The Implementation of Automatic Analysis of the Elliott Waves in MQL5"

newdigital, 2014.03.13 09:39

Keys to Investor Success - Elliott Wave Theory (based on thetechnicaltraders article)

Elliott Wave Theory - Plenty of people will freely offer you advice on how to spend or invest your money. “Buy low and sell high,” they’ll tell you, “that’s really all there is to it!” And while there is a core truth to the statement, the real secret is in knowing how to spot the highs and lows, and thus, when to do your buying and selling. Sadly, that’s the part of the equation that most of the advice givers you’ll run across are content to leave you in the dark about.

The reality is that no matter how many times you are told differently, there is no ‘magic bullet.’ There is no plan, no series of steps you can follow that will, with absolute certainty, bring you wealth. If you happen across anyone who says otherwise, you can rely on the fact that he or she has an agenda, and that at least part of that agenda involves convincing you to open your wallet.

In the place of a surefire way to make profits, what is there? Where can you turn, and what kinds of things should you be looking for?

The answers to those questions aren’t as glamorous sounding as the promises made by those who just want to take your money, but they are much more effective. Things like careful, meticulous research. Market trend analysis. Paying close attention to extrinsic factors that could impact whatever industry you’re planning to invest in, and of course, Elliott wave theory. If you’ve never heard of the Elliott wave, you owe it to yourself to learn more about it.

Postulated by Ralph Nelson Elliott in the late 1930’s, it is essentially a psychological approach to investing that identifies specific stimuli that large groups tend to respond to in the same way. By identifying these stimuli, it then becomes possible to predict which direction the market will likely move, and as he outlined in his book “The Wave Principle,” market prices tend to unfold in specific patterns or ‘waves.’

The fact that many of the most successful Wall Street investors and portfolio managers use this type of trend analysis in their own decision making process should be compelling evidence that you should consider doing the same. No, it’s not perfect, and it is certainly not a guarantee, but it provides a strong framework of probability that, when combined with other research and analysis, can lead to consistently good decisions, and at the end of the day, that’s what investing is all about. Consistently good decision making.

We can use Elliott Wave Theory in real time by looking at the larger patterns of the SP 500 index for example. We can deploy Fibonacci math analysis to prior up and down legs in the markets to determine where we are in an Elliott Wave pattern. This will help us decide if to be aggressive when the markets correct, go short the market, or to do nothing for example. It also prevents from making panic type decisions, whether that be in chasing a hot stock too higher or selling something too low before a reversal. We also can use Elliott Wave Theory to determine when to be aggressive in selling or buying, on either side of a trade.


For many, its not practical to employ Elliott Wave analysis with individual stocks and trading, but it can be done with experience.

Knowing when to enter and exit a position whether your time frame is short, intermediate, or longer… can often be identified with good Elliott Wave Theory practices. Your results and your portfolio will appreciate it


Sergey Golubev
newdigital | 13 Mar 2014 at 09:41

Forum on trading, automated trading systems and testing trading strategies

Something Interesting to Read March 2014

newdigital, 2014.03.13 09:30

The Wave Principle

by Ralph Nelson Elliott



The Elliott Wave Principle is a form of technical analysis that some traders use to analyze financial market cycles and forecast market trends by identifying extremes in investor psychology, highs and lows in prices, and other collective factors. Ralph Nelson Elliott, a professional accountant, discovered the underlying social principles and developed the analytical tools. He proposed that market prices unfold in specific patterns, which practitioners today call Elliott waves, or simply waves. Elliott published his theory of market behavior in this book "The Wave Principle". Elliott stated that "because man is subject to rhythmical procedure, calculations having to do with his activities can be projected far into the future with a justification and certainty heretofore unattainable."


Who Is Who in MQL5.community? Who Is Who in MQL5.community?

The MQL5.com website remembers all of you quite well! How many of your threads are epic, how popular your articles are and how often your programs in the Code Base are downloaded – this is only a small part of what is remembered at MQL5.com. Your achievements are available in your profile, but what about the overall picture? In this article we will show the general picture of all MQL5.community members achievements.

The Simple Example of Creating an Indicator Using Fuzzy Logic The Simple Example of Creating an Indicator Using Fuzzy Logic

The article is devoted to the practical application of the fuzzy logic concept for financial markets analysis. We propose the example of the indicator generating signals based on two fuzzy rules based on Envelopes indicator. The developed indicator uses several indicator buffers: 7 buffers for calculations, 5 buffers for the charts display and 2 color buffers.