Tip 1: How to write an indicator
Download, install and run the MetaTrader trading terminal. To launch the Expert Advisor Editor, use the "New" command of the "Navigator-User"indicators ". Other ways to start the editor:
- execute the command "Service-Editor MetaQuotes Language";
- Press the F4 button;
- click the corresponding MetaEditor button in the "Standard" panel. The specified actions will automatically lead to the opening of the program editor.
On the program editor's toolbar, click the New button, which opens the New Expert Advisor wizard. For the type of the program being created, specify the "Custom indicator".
Fill in the fields by typing the required data: the name of the indicator, the author's name, the address of the developer's site or his e-mail address.
Configure the parameters of the future indicator. To add a new parameter, click the "Add" button, to delete an unnecessary parameter - 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 program code of the custom indicator.
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 exchange rate chart, double click on it with the mouse in the "Navigator-User" windowindicators "And click" OK ".
The FOREX currency market operates trillions of dollars, but anyone who has a computer and Internet access can work on it. To facilitate decision making in the course of trading, many traders useadvisers - special programs that work according to a certain algorithm.
The most common trading platform forForex is the 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 are working.
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.