Tip 1: How to write the indicator
Download, install and launch the trading terminal MetaTrader. To run the editor programs-counselors run the command "Create" menu window "Navigator-Custom indicators ". Other ways to launch the editor:
— run command "Tools-MetaQuotes Language Editor"
— press F4
— press the appropriate button on the MetaEditor toolbar "Standard".These actions will automatically result in opening the program editor.
On the toolbar the program editor press the "Create" button that will lead to the discovery wizard programs expert advisors. As the type of program specify "Custom indicator".
Complete the fields by entering the required data: the indicator name, author name, address of developer's website or his email address.
Configure the parameters of the future indicator. To add a new parameter, click "Add" to delete a parameter, click "Remove".
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 coding a 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 "the trading terminal.
To superimpose the indicator on a chart of the exchange rate, double-click "mouse" in the window "Navigator-Custom indicators "and hit "OK".
FOREX market deals with trillions of dollars, but working on it can any person with a computer and Internet access. To facilitate decision-making while trading many traders use advisors – special programs that run according to a specific algorithm.
The most common trading platform Forex is the mt4 terminal. Accordingly, under it is written the majority of councillors. If you do not have a terminal, download it from the website 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.