Tip 1: How to write an indicator
Download, install and run the MetaTrader trading terminal. To launch the editor of advisory programs, run the “Create” command of the “Navigator-Customindicators ". Other ways to run the editor:
- execute the “Service Editor of MetaQuotes Language” command;
- press the F4 button;
- click the corresponding MetaEditor button on the “Standard” panel. The above actions will automatically lead to the opening of the program editor.
On the toolbar of the program editor, click the Create button, which will lead to the opening of the wizard for creating expert advisors. For the type of program being created, select “Custom Indicator”.
Fill in the fields by entering the required data: the name of the indicator, the name of the author, the website address of the developer or his email address.
Adjust the parameters of the future indicator. To add a new parameter, click the Add button, to delete an unnecessary parameter, click the Delete button.
Next, specify whether you want your custom indicators to be created in a separate window, and also specify the border around the gauge. Specify the number and characteristics of arrays of indicator (these are used to display lines on the chart of the exchange rate). After completion of these steps in the program editor window opens a new indicator with the required parameters.
Proceed directly to writing the custom indicator program code.
After writing the text of the program (in accordance with your strategy) compile the indicator. To do this, press the F9 button on the editor toolbar, or run menu "File-Compile". If there are no errors after the compiler creates the executable file format *.EX4. The list you have created custom indicators is displayed in the window "Navigator-Custom indicators »Trading terminal.
To overlay the indicator on the chart of the exchange rate, double-click on it with the “mouse” in the “Navigator-Customindicators And click “OK”.
The FOREX currency market operates with trillions of dollars, but anyone with a computer and Internet access can work on it. To facilitate decision making during trading, many traders useadvisors - special programs working on a specific algorithm.
The most common trading platform forForex is terminal mt4. Accordingly, it is for him that most advisers are written. If you do not already have a terminal, download it from the site of the dealing center with which you work.
Launch the terminal. Open the MetaEditor by pressing F4. In the appeared editor window in the File tab, select New, open the Expert Advisor Wizard ("Wizard adviser"). Choose the type of EA — Expert Advisor. Click "Next". In the next window, enter the name of the EA and data of the author (if you want).
In the same window there is a table "Parameters" – press the right Add button. A new option appears Extparam1. Using parameters, you can "teach" the EA to perform the desired actions. For example, change the name of the parameter Extparam1 on StopLoss, double-clicking the line with the mouse and entering a new name. The parameter type is set as double. The value of the parameter (Initial value) set equal to the amount allowable to you for the loss – for example, 20 points.
Likewise, you can enter a value for profit and other parameters. Anything is possible at this stage, do not enter and enter the desired value manually directly in the code. Click "finish" you will see a window with the underlying code of the EA.
Pay attention to the functions init, deinit, start. The first performs the operations associated with initializing the EA after its launch. The second turns off the EA when it is disconnected or closing the terminal. The most important is the function start, as it handles all the details that come with each new tick (price change).
How does the counselor? In his code you need to write lines that allow it to open or close warrant according to current situation inherent in the logic of the EA conditions. For example, a simple EA can be built on the account of the indicator Moving Average is a moving average. Built two medium with different period – for example, 5 and 15. If the fast line crosses the slow from the bottom up, open a buy order. Positions are closed when reaching the desired profit or when crossing fast line to slow down.
Exactly the same is the opening and closing of the sell orders. To reduce the number of false alarms can introduce a rule that a warrant will only be open after the fast line goes from slow at some distance – for example, 10 points. Specific settings you can set, to determine the most successful options.
How to write a specific line of code? For this you need to master the basics of mql4. Many useful materials, including textbooks, you can find here: http://forum.mql4.com/ru/ Not always hold for the creation of complex expert Advisor – give him the simplest functions first, and then gradually complicate. When you do this, be sure to keep the basic version – they will come in handy if I have to go back to past options.