Pages

Can"t find it? Try searching the entire web with:

Google
 

Sunday, November 18, 2007

History Center
Technical analysis is the market movements research made in order to forecast future price movements. the market is often analyzed using charts. So it is very important to have available historical data for all symbols and timeframes used. Historical data are constantly formed and stored on the server. Connecting to it, the client terminal downloads all necessary data. They will be then used for drawing of charts,testing and optimization of Expert Advisors. To control historical data, the terminal has a special window named "History Center". This window can be opened by executing the command "Tools — History Center" or by pressing F2.

After the terminal has been shut down, all accumulated historical data will be stored in the "History Center". Sizes of files containing historical quotes do not exceed values defined in settings. If the amount of historical data accumulated exceeeds the value set in the field of " Max. bars in history:", the oldest bars will be deleted when storing. For each timeframe, a separate history file is formed named as SSSSSSPP.hst (where SSSSSS - symbol name, PP - timeframe in minutes) and saved in the /HISTORY. Later on, the saved data will be used to draw charts, as well as for testing of trading strategies.

In the "History Center" window, the available data can be changed. For this, it is necessary to select the desired symbol and timeframe in the left part of the window.The corresponding data will be loaded in form of a table. To add a record about a new bar, it is necessary to press the button of the same name, fill out all necessary fields in the new window and press "OK". After that, the new bar will appear in the history. One can modify the bar by selecting the corresponding record and pressing the "Modify" button. To delete a bar, it is necessary to select it and press the button of the same name.

Load of Historical Data
It is possible to load quotes for basic currency pairs starting with year 1999 from the historical data server. To do it, it is necessary to select the desired symbol and press "Download".

Attention: The loaded data can differ from historical data stored on the broker's trade server.
Upon pressing the button, data of M1 timeframe will be loaded. Other timeframes will be automatically recalculated from М1. At that, the time of the downloaded data will be automatically recalculated according to the active account time zone.

When downloading historical data, it is recommended to control amount of bars in history and in charts.

Attention: The deeper is the history used, the more PC resources are needed.
Quotes are weekly updated on the server of historical data. Further, at restarts, only updated quotes will be downloaded.

Exports and Imports of Historical Data
Historical data can be exported into files formatted as CSV, PRN and HTM. For this, it is necessary to select the desired symbol in the left part of the "History Center" window and press "Export". Then it is necessary to select on of three file formats and specify the path of location on the hard disk.

Historical data as CSV, PRN, TXT, HTM and HST can also be imported into terminal.

Historical data in the file can be represented as follows (any other separator can be used instead of space):

YYYY.MM.DD HH:MM O H L C V

YYYY-MM-DD HH:MM O H L C V

YYYY/MM/DD HH:MM O H L C V

DD.MM.YYYY HH:MM O H L C V

DD-MM-YYYY HH:MM O H L C V

DD/MM/YYYY HH:MM O H L C V

First of all, it is necessary to select a symbol and a timeframe, for which the import will be performed, in the left part of the "History Center" window. Then it is necessary to set up import parameters by pressing "Import":

Separator — data separator in the file to be imported. Comma, semicolon, space or tabulation character can be used as separators;

Skip columns — skip columns when importing. This can be helpful when the imported file contains more data types than necessary;

Skip lines — skip rows (lines) when importing;

Time shift — shift data by several hours in time;

Selected only — import only selected data. Data are selected by lines using "Ctrl" and "Shift";

Volumes — enable/disable importing of volumes.

After historical data have been imported, they can be used to show charts and test Expert Advisors.

Historical File Format (HST Files)
The database header is the first

struct HistoryHeader
{
int version; // database version
char copyright[64]; // copyright info
char symbol[12]; // symbol name
int period; // symbol timeframe
int digits; // the amount of digits after decimal point in the symbol
time_t timesign; // timesign of the database creation
time_t last_sync; // the last synchronization time
int unused[13]; // to be used in future
};
then goes the bars array (single-byte justification)

#pragma pack(push,1)
//---- standard representation of the quote in the database
struct RateInfo
{
time_t ctm; // current time in seconds
double open;
double low;
double high;
double close;
double vol;
};
#pragma pack(pop)
READMORE -
Configuration at Startup
The client terminal can be launched with some predefined settings. For this purpose, the configuration file name will be passed to the client terminal as a parameter.

For example:

terminal.exe config\start.ini
terminal.exe test1.txt
terminal.exe "C:\Program Files\MetaTrader 4\config\settings25.ini"
If the full path to the file (Drive:\SubDirectory\FileName) is not given, the file will be searched for in the client terminal directory. The configuration file contains lines of the following appearance:
[Parameter] = [Value]

Comments start with a semicolon (;) and are not processed.

The configuration file parameters can be divided into several groups: common settings, proxy server settings (the "Server" tab in the terminal settings), FTP settings (the "Publisher" tab in the server settings), EA settings (the "Expert Advisors" tab in the server settings), the expert or script single-launch settings, settings of the Strategy Tester launch.

Common Settings
Profile - the subdirectory name in the /profiles directory. The charts will be opened in the client terminal according to the given profile. If this parameter is not specified, the current profile will be opened.

MarketWatch - file name (the \symbolsets directory) that contains the symbol list to be shown in the Market Watch window. A file like this can be obtained using the window context menu command of the "Market Watch - Sets - Save As...".

Login - the number of the account to connect to at startup. If this parameter is not specified, the current login will be used.

Password - the password that allows entering the system. This parameter will be ignored if the client terminal stores personal data on the disk and the account to be connected is in the list.

Server - the name of the trade server to be connected to. The server name is the same as the name of the corresponding .srv file stored in the /config directory. This patameter will be ignored if the information about the account to be connected was stored on the disk.

AutoConfiguration - "true" or "false" depending on whether the autoconfiguration setting should be enabled or not. If this parameter is not specified, the value from the current server settings will be used.

DataServer - address of the data center. This record can be ignored if the server autoconfiguration s enabled. If this parameter is not specified, the value from the current server settings will be used.

EnableDDE - "true" or "false" depending on whether DDE server should be enabled or not. If this parameter is not specified, the value from the current server settings will be used.

EnableNews - "true" or "false" depending on whether receiving of news should be allowed or not. If this parameter is not specified, the value from the current server settings will be used.

Example:

; common settings
Profile=test 3
MarketWatch=set2.set
Login=12345
Password=xxxxxx
Server=MetaQuotes-demo
AutoConfiguration=false
DataServer=192.168.0.1:443
EnableDDE=true
EnableNews=false

Proxy Server Settings
ProxyEnable - "true" or "false" depending on whether or not a proxy server should be used for connection to the trade server.

ProxyServer - proxy server address.

ProxyType - proxy server type.It can be "HTTP", "SOCKS4", or "SOCKS5".

ProxyLogin - login to be authorized on proxy server.

ProxyPassword - password to access to proxy server.

If any of the above parameters are not specified, the current settings of the client terminal are used (proxy settings in the "Server" tab of the client temrinal settings).

Example:

; proxy settings
ProxyEnable=true
ProxyServer=proxy.company.com:3128
ProxyType=HTTP
ProxyLogin=user45
ProxyPassword=xxx

FTP Settings
FTPEnable - enable/disable publishing. The possible values are "true" or "false".

FTPPassiveMode - enable/disable the passive mode of data transfer. The possible values are "true" or "false".

FTPAccount - the number of the account the state of which to be sent to the FTP.

FTPServer - FTP server address.

FTPLogin - the login for authorization on the FTP server.

FTPPassword - the password to access to the FTP server.

FTPPath - the name of the FTP server directory in which the report is placed.

FTPPeriod - the periodicity, in minutes, of the reporting to the FTP server.

If any of the above-listed parameters are not specified, the current client terminal settings are used (the "Publisher" tab in the server settings).

Example:

; ftp settings
FTPEnable=true
FTPPassiveMode=false
FTPAccount=12345
FTPServer=ftp.company.com
FTPLogin=admin
FTPPassword=pAssWOrd123
FTPPath=/inetpub
FTPPeriod=10

EA Settings
ExpertsEnable - enable/disable experts.

ExpertsDllImport - enable/disable DLL imports.

ExpertsDllConfirm - enable/disable manual confirmation of DLL-functions calling.

ExpertsExpImport - enable/disable import of functions from external experts or MQL4 libraries.

ExpertsTrades - enable/disable the experts trading.

ExpertsTradesConfirm - enable/disable manual confirmation of the trade operation performed by the expert.

Attention: All parameters of an experts group can take values of either "true" or "false".
If any of the above-listed parameters is not specified, the current client terminal settings will be used (the "Expert Advisors" in the server settings).

Example:

; experts settings
ExpertsEnable=true
ExpertsDllImport=true
ExpertsDllConfirm=true
ExpertsExpImport=true
ExpertsTrades=true
ExpertsTradesConfirm=false

The Expert and/or Script Single-Launch Settings
Symbol - the symbol of the security the chart of which should be opened immediately after the terminal startup. After the client terminal has been closed, the information about this extra chart is not saved. At the terminal restart, without the configuraiton file, this chart will not be opened. If this parameter is not specified, no extra chart will be opened.

Period - the chart timeframe (M1, M5, M15, M30, H1, H4, D1, W1, MN). If this parameter is not specified, H1 is used.

Template - the name of the templatre file (the \templates directory), which should be applied to the chart.

Expert - the name of the expert that should be launched after the client terminal has started. The expert is launched in the chart, which has been opened according to the data specified in Symbol and Period. If the Symbol parameter has not been not specified, no extra chart opens, and the expert will be launched in the first chart of the current profile. If there are no charts in the current profile, the expert will not be launched. If this parameter has not been specified, no expert is launched.

ExpertParameters - the name of the file containing the expert parameters (the \experts\presets directory). This file can be created in the expert properties window by pressing of the "Inputs - Save" button. It is normally used to save the inputs other than the default ones. If this parameter has not been specified, the default inputs are used.

Script - the name of the script, which must be launched after the client terminal startup. The script is launched according to the same rules that are eligible for the expert (described above).

ScriptParameters - the name of the file containing the script parameters (the \experts\presets directory). This file is made in the same way as that for the expert.

Example:

; open chart and run expert and/or script
Symbol=EURUSD
Period=H4
Template=popular.tpl
Expert=MACD Sample
ExpertParameters=macd.set
Script=period_converter
ScriptParameters=

Settings of the Strategy Tester Launch
TestExpert - the name of the expert to be launched for testing. If this parameter has not been specified, no testing is launched.

TestExpertParameters - the name of the file containing parameters (the \tester directory). The file can be created in the Properties window of the expert under test by clicking the "Inputs - Save" button. It is normally used to save parameters other than the default ones. Other parameters of the expert under test in the "Testing" and "Optimization" tabs (as well as in the "Inputs" tab if this parameter has not been specified) are filled up with the values automatically saved in the \tester\[the expert name].ini file after the latest test.

TestSymbol - the name of the symbol used for the expert testing. If this parameter has not been specified, the latest value used in the tester is used.

TestPeriod - the chart period (M1, M5, M15, M30, H1, H4, D1, W1, MN). If this parameter has not been specified, H1 is used.

TestModel - 0, 1, or 2, depending on the testing model (Every tick, Control points, Open prices only). If this parameter has not been specified, 0 is used (Every tick).

TestRecalculate - enable/disable the "Recalculate" flag. The values that can be taken are "true" or "false". If this parameter had not been specified, the "false" value is used.

TestOptimization - enable/disable optimization. The values that can be taken are "true" or "false". If this parameter had not been specified, the "false" value is used.

TestDateEnable - enable/disable the "Use date" flag. The values that can be taken are "true" or "false". If this parameter had not been specified, the "false" value is used.

TestFromDate - the date, from which to start testing, appeared as YYYY.MM.DD. If this parameter has not been specified, this date is 1970.01.01.

TestToDate - the date, on which to finish testing, appeared as YYYY.MM.DD. If this parameter has not been specified, this date is 1970.01.01.

TestReport - the name of the test report file. Th efile will be created in the client terminal directory. A relative path can be specified, for example: tester\MovingAverageReport". If the extension has not been specified in the file name, the ".htm" will be set automatically. If this parameter has not been specified, the test report will not be formed.

TestReplaceReport - enable/disable the repeated report file record. The values that can be taken are "true" or "false". If the "false" value is specified and a report file named in the same way exists already, the number in square brackets will be added to the file name. For example, "MovingAverageReport[1].htm". If this parameter had not been specified, the "false" value is used.

TestShutdownTerminal - enable/disable shutdown of the terminal after the testing has been finished. The values that can be taken are "true" or "false". If this parameter had not been specified, the "false" value is used. If the user has pressed the "Stop" button, the value of this parameter will be flushed to "false" since the control has been given to the user.

Example:

; start strategy tester
TestExpert=Moving Average
TestExpertParameters=ma0.set
TestSymbol=EURUSD
TestPeriod=H1
TestModel=2
TestRecalculate=false
TestOptimization=false
TestDateEnable=true
TestFromDate=1970.01.01
TestToDate=2006.06.06
TestReport=MovingAverageReport
TestReplaceReport=false
TestShutdownTerminal=true
READMORE -
Removing of a Custom Indicator from the Chart
To shut down an indicator, one has to remove it from the chart. At that, its drawing and recalculation of its values will stop. To remove an indicator from the chart, one has to execute its context menu commands of "Delete Indicator" or "Delete Indicator Window", or the chart context menu command of "Indicators List — Delete".

Attention: Removing of a custom indicator from the "Navigator" window will not shut down the indicator of the same name imposed in the chart.
READMORE -
How to Attach Custom Indicators to a Chart
After general setup has been completed, one can attach custom indicators to the chart. A custom indicator can be imposed into the active chart by a double click with the left mouse button on it in the "Navigator — Custom Indicators" window or by execution of the context menu command "Attach to a chart". The "Drag'n'Drop" technique allows to impose the analytical tool into any chart. At that, the setup window will appear automatically that has several tabs:

Common
Import from DLLs and MQL4 can be managed in the "Common" tab. Besides, if indicator is drawn in a separate window, one can set up its range from here. To do so, one has to flag the corresponding options and set the desired values in the fields.

Inputs
External variables that can be managed directly from the terminal are grouped in the "Inputs" tab. To modify the desired variable, one has to double-click on its value in the table and write a new one.

Colors
The "Colors" tab is intended for managing of the indicator elements to be shown in the screen. Besides colors, one can also modify thickness and style of lines.

Levels
Horizontal lines at any level can be set from the "Levels" tab in the indicator window. To create a new level, one has to press the "Add" button, and to delete it, one has to press the "Delete" button. Colors, thickness and style of levels can also be changed from this tab.

Attention: This tab is not available for indicators drawn directly in the price chart.
Visualization
One can limit the use of an indicator by timeframes in the "Visualization" tab. This can be useful if the same indicator must have different settings for different timeframes. One can, for example, impose two copies of the same indicator with different settings into the same chart and limit their use by timeframes: the first indicator will work only for smaller timeframes, and the second one will do for larger timeframes. The "Show in the Data Window" option allows to hide/show data about the given indicator in the Data Window.

Immediately after that, recalculation if the indicator values and drawing thereof in the chart will start. Custom indicators, like technical ones, can be drawn in a separate indicator window with its own vertical scale (for example, MACD) or imposed directly into the price chart (for example, Moving Average).
READMORE -
Custom Indicators Setup
Indicators must have been set up before they are used. Working parameters common for all custom indicators (and experts) are set up in the client terminal settings. The corresponding window can be opened by the "Tools — Options" menu command or by pressing of accelerating keys of Ctrl+O. To set up working parameters of indicators, one has to select the "Expert Advisors" tab. Only two options influence working of custom indicators:

Allow DLL imports
Custom indicators can use DLLs to enlarge their functionalities. If this option is enabled, the libraries can be used without any limitations. Disabling of the option results in that no MQL4 program can use any external DLLs.

Allow external experts imports
If there is a need to export functions from other experts or MQL4 libraries during the indicators work, this option must be enabled. If it is disabled, no launched indicator will be able to request for functions from other MQL4 programs.
READMORE -
Creation of Custom Indicators
To create custom indicators, one has to use MetaQuotes Language 4 (MQL 4) and MetaEditor. To launch the editor, one has to execute the "Create" command of the "Navigator — Custom Indicators" window context menu, or the "Tools — MetaQuotes Language Editor" menu command, or press F4 or the button of the "Standard" toolbar. At creation of the MQL4 program, the Experts Wizard that allows to create new MQL4 programs will open automatically. "Custom Indicator" must be selected in it as the object to be created, and the necessary fields must be filled out:

Name — indicator name;

Developer — developer's name;

Link — the developer's web site;

Inputs — the list of indicator inputs. To add a new parameter, one has to press the "Add" button, and for deletion, one has to press the "Delete".

Then it is necessary to decide whether the new indicator will be created in a separate sub-window and what range it will have. Besides, it is necessary to define the amount and parameters of the indicator arrays. Values of their elements are used to draw lines in the chart. In other words, when indicator arrays are defined, the lines of the future indicator are defined, too. After that, the window of the new indicator with the defined settings will open. A file with the source code (*.MQ4) of the indicator will be placed into the /EXPERTS/INDICATORS folder of the client terminal automatically. From this point onwards, one can start to write the text of the custom indicator.

After the indicator has been developed, it must be compiled. To do so, one has to execute the "File — Compile" editor menu command, press F9 or the button of the toolbar. After the indicator has been successfully compiled, an executable program file with *.EX4 extension will be created to be automatically placed into the /EXPERTS/INDICATORS folder. The list of custom indicators can be viewed in the "Navigator — Custom Indicators" window of the client terminal.

Modifying of Custom Indicators
To start modifying of the existing indicator from terminal, one has to execute the "Modify" command of the "Navigator — Custom Indicator" window context menu. At that, the MetaEditor will open where the selected indicator source code has already been downloaded. After this code has been changed, one will have to recompile it and get a new executable EX4 file. Otherwise, the previous, non-modified version of the indicator will be used in the terminal.

Attention: If the indicator has been compiled with errors, it is impossible to attach it to the chart. At that, the indicator properties window will not appear, and a record about impossibility to open a file with an executable code will appear in the experts journal.
READMORE -
Custom Indicators
Custom indicator is a program independently developed in MetaQuotes Language 4 by the user and functioning as a technical indicator. Technical indicator is a mathematical transformation of security price and/or volume in order to forecast future price changes. The use of indicators allows to answer the question about whether the current trend will remain the same and where it will turn. Indicators are intended for relative simplifying of the complicated process of trading decision making. Algorithms of indicators are also used for development of trading tactics and expert advisors.

Attention: Custom indicators are intended only for analyzing of symbol price changes, but not for trading itself.
Working with custom indicators means:

Creation of an Indicator
To create and compile custom indicators, one has to use the built-in "MetaEditor". It is a constituent of the client terminal and represents a convenient development environment of MQL4 programs.

Indicator Setup
Before using of custom indicators, one has to set them up first. Working parameters common for all indicators are defined in the window of client terminal settings. Besides, every indicator can have its own settings.

Imposing of an Indicator
Parameters of the indicator are calculated and the indicator itself is drawn when imposed into the chart.

Deletion of an Indicator
If there is no need of an indicator anymore, the indicator can be deleted from the chart.
READMORE -
Optimization Results
After optimization has been completed, its results can be viewed in the tabs of "Optimization Results" and "Optimization Graph".

Optimization Results
Unlike testing, optimization is supposed to perform many passes of the mechanical trading system (MTS) with different inputs. This is aimed at determining of such expert parameters at which its efficiency will be the highest. To optimize an expert, one has to flag "Optimization" in the testing settings tab and press "Start". After that, two new tabs will appear in the window: "Optimization Results" and "Optimization Graph".

There are not all operations listed in the tab of "Optimization Results", unlike that of testing results, but only final reports about each pass. The entire information is represented as a table with the following fields:

Pass — the pass number;

Profit — the pure profit (gross profit minus gross loss);

Total trades — the total amount of open trade positions;

Profit factor — ratio between gross profit and gross loss in per cents. One means that these values are equal;

Expected payoff — mathematical expectation of win. This value to be calculated statistically represents the average profit/loss factor of one trade. It can also be considered to represent the expected profit/loss factor of the next trade;

Drawdown $ — the largest drawdown related to the initial deposit, in the deposit currency;

Drawdown % — the largest drawdown related to the initial deposit, in per cents;

Inputs — changeable values of inputs at each pass.

Having clicked with the left mouse button on any column header, one can sort out all records in the table in increasing or decreasing order. At execution of the "Set Input Parameters" context menu command, the data of the selected pass will be written as the expert basic inputs (expert properties window, "Inputs" tab). At that, it will be switched to the "Settings" tab, and the optimization will be disabled. Having pressed the "Start" button, one can start to test the expert with the selected inputs. Double click with the left mouse button on the pass line in the Optimization Results tab allows to do the same. Using the "Copy" context menu command or accelerating keys of Ctrl+C, one can copy the selected results lines to the clipboard for further use in other applications. If no line has been selected, the entire table will be copied to the clipboard. To do the same, one can also execute the "Copy All" command. The report about optimization results can be saved on the hard disk as an HTML file. To do so, one has to execute the "Copy As Report" context menu command. Other context menu commands allow to set up representation of results:

Skip Useless Results — show/hide the results of unprofitable passes;

Show Input Parameters — show/hide the "Inputs" column;

Auto Arrange — arrange the column sizes automatically when the window size has been changed.
The same action can be done by pressing of A;

Grid — show/hide grid to separate the columns.
The same actions can be done by pressing of G.

Optimization Graph
The graph of profit of all passes is drawn automatically in the "Optimization Graph" tab. The graph allows to estimate the profitability of the use of different inputs combinations visually. The graph representing the amount of profitable (green color) and unprofitable (red color) trades at each pass is given in the bottom of the window, as well.

Double click with the left mouse button on any point of the graph switches to the "Optimization Results" tab and selects the corresponding pass. Using the "Copy" context menu command or accelerating keys of Ctrl+C, one can copy the graph to the clipboard to be used in other applications. The graph can also be stored on the hard disk as a GIF file. To do so, one has to execute the "Save as Picture" context menu command or press accelerating keys of Ctrl+S.
READMORE -
Optimization Setup
Optimization represents consecutive passes of the same expert with different inputs on the same data. At that, such parameters can be taken that make the expert efficiency maximal. The terminal possesses in-built means that allow to automate this process. Before beginning to optimize expert parameters, one has to set them up. It means that one has to:

select an expert and its inputs

select a symbol and its timeframe

select one of three bar modeling methods

set up the time span for optimization (optional)

A special window named "Tester" is used for testing and optimization of experts in the terminal. All settings listed above can be made in the "Settings" tab of this window.

Expert Advisor and Its Parameters
One has to select expert the parameters of which should be optimized in the "Tester — Experts" window. Not any expert file can be selected in this field, but only those that are available in the client terminal. For this, they must be compiled and placed in the /EXPERTS folder.

After the expert has been selected, one has to make an additional setup and set the inputs. This can be done by pressing of the "Expert properties" button. At that, a new window containing the following three tabs will appear:

Testing — general optimization parameters are set in this tab. They include the initial deposit volume and currency to be specified in the corresponding fields. It is this deposit that will be operated by the expert during optimization. Types of positions to be opened are selected in this tab, as well: Only Long, Only Short, or Long and Short. Whatever expert algorithm is used, it will open positions only in the directions defined here; One can include an optimization genetic algorithm and select a parameter to be optimized (maximization by the balance value, the profit factor, expected payoff, or minimization by the maximal drawdown value or drawdown percent.

Inputs — all inputs are listed here as a table. Inputs are variables that influence the expert operation and can be changed directly from the client terminal. For these parameters to be changed, there is no need to change the expert code. The amount of inputs can vary depending of experts. At optimization, the expert inputs are set in the fields of "Start", "Step", and "Stop". Initial values, change interval, and final values of external variables will be set in these fields, respectively. There are checkboxes to the left of variable names that include the parameter into optimization process. If a variable is not checked in this checkbox, it will not be involved into optimization. Its value will not be changed within the optimization process, and the parameter given in the "Value" field will be written here. The amount of expert passes depends on these parameters directly. Data written in the "Value" field do not influence the expert optimization and are necessary only for its testing.

The set of inputs already saved before (including those given in the fields of "Start", "Step", and "Stop") can be downloaded. This can be done by pressing of the "Load" button and having selected the preliminarily saved set of parameters. The current set of external variables can be saved by pressing of the corresponding button.

Optimization — this tab allows to manage limitations during optimization. If any of conditions is met during a separate pass, this pass of the expert will be interrupted. Limiting parameters are:

Balance minimum — the smallest balance value in the deposit currency;

Profit maximum — the largest profit in the deposit currency;

Minimal margin level % — the lowest margin level in per cents;

Maximal drawdown % — the largest drowdown in per cents;

Consecutive loss — the largest loss within a series. Loss series is a number of consecutive loss trades;

Consecutive loss trades — the largest amount of loss trades within a series;

Consecutive win — the largest total profit within a series. Profitable series is a number of consecutive profitable trades;

Consecutive win trades — the largest amount of profitable trades within a series.

To enable a limit in condition, one has to flag it in the checkbox to the left of it. Double click with the left mouse button in the "Value" field can be used to change the existing parameter.

Symbol and Its Period
It is not enough just to select an expert and set it up to start optimization: a symbol and its period (timeframe) must be selected for tests. These are the data on which all tests will be made. A symbol available in the terminal or an external data file can be used for tests. History data files in *.FXT format to be stored in the /TESTER directory are used in tests. These files are created at tests automatically if the corresponding symbol available in the terminal was selected. If external data are used, one has to place the corresponding data file into the /TESTER directory manually and disable the "Recalculate" option in order not to overwrite this testing succession.

Symbol is defined in the "Symbol" field, and timeframe is in the "Period". If there is no data file for this symbol, period, and modeling method, it will be created automatically. If the necessary file has already been created and the "Recalculate" option has been enabled, the data file will be generated again at optimization. If there are no history data for the symbol and period, the tester will download 512 latest history bars automatically.

Attention: If there are any data outside the latest 512 bars for a symbol, the data will be downloaded automatically up to the last available bar. This can cause sharp increase of incoming traffic.
Modeling methods
History data are saved in the terminal only as bars and represent records appearing as TOHLCV (HST format). These data can be used for modeling of price changes at testing of experts. In some cases, such information is not enough for testing. For example, for the daily timeframe, price changes within a bar can result in triggering of the expert. At the same time, no triggering can occur at testing. In other words, testing of an expert based on only bars can be inaccurate and give a false idea about the expert efficiency.

Terminal allows to test experts by various methods of history data modeling. Using history data from smaller periods, it is possible to see price fluctuations within bars, i.e., price changes will be emulated more precisely. For example, when an expert is tested on one-hour data, price changes for a bar can be modeled on one-minute data. Thus, modeling brings history data near the real price fluctuations and makes expert testing more authentic.

One of three history data modeling methods can be chosen for testing:

Open prices only (fastest method to analyze the bar just completed)
Some mechanical trading systems do not depend on properties of modeling within a bar, they trade on completed bars. The bar is completed if the next one has appeared. These are such experts for which this modeling method was developed.



In this mode, the bar opening is modeled first (Open = High = Low = Close, Volume=1) what allows the expert to identify the completion of the preceding bar precisely. It is this incipient bar that is used to start testing of the expert. At the next step, the fully completed current bar will be given, but no testing is performed on it!

Control points (based on the nearest less timeframe with fractal interpolation of 12 control points)
The control points modeling method is intended for a crude estimate of experts efficiency that trade within the bar. The history data of the nearest less timeframe must be available to apply this method. In the most cases, the available data of the less timeframe do not completely cover the time range of the timeframe under test. If the data of the less timeframe are missing, the further bar development will be generated on close prices of 12 preceding bars. It means that the changes within the bar are the same as those of price within the last 12 periods. It is fractal interpolation.

As soon as history data of the less timeframe appear, fractal interpolation will be applied to these new data. But there will be used not 12, but just 6 preceding bars. It means that really existing Open, High, Low, Close prices are reproduced, and two generated prices more. Values and locations of these two generated prices depend on that on 6 preceding bars.

Every tick (based on all available least timeframes with fractal interpolation of every tick) This is the most accurate method of modeling prices within a bar. Unlike that of "control points", this method uses for generation not only data of the nearest less timeframe, but also those of all available nearest timeframes. At that, if there are data of more than one period for the same timeframe at the same time, the data of the least timeframe will be used for modeling. Like in the preceding method, control points are generated by fractal interpolation. It is also used for modeling of price changes between control points. It is possible that several similar ticks are modeled one after another. In this case, the doubled quotes will be filtered out, and the volume of the last of them will be fixed.



One has to consider the possible large amount of tick data modeled. This can influence the consumed resources of the operation system and testing speed.

Attention:
it is not recommended to launch testing on every tick if there are no available less timeframes that completely cover the period under test, otherwise, the results will not be accurate;
modeling on control points is basically used at optimization of experts, and all ticks modeling is for a close testing.
After modeling parameters have been changed, the data file must be created afresh. To do so, one has to flag the "Recalculate". If the above setting were not changed, there is no need to recalculate. In this case, it is recommended to disable the above option in order to reduce the testing time.

Time Range
The range of dates allows to test experts not on all available data, but within a certain time space only. This can be useful if there is a need to test a certain part of history data. Date range can be used not only for expert testing, but also for modeling of the testing succession of bars (file of data modeled to be used for testing). It is often no need to model data of the entire history, especially for every-tick modeling where the amount of unused data can be very large. That is why, if data range was allowed to be set at the initial modeling of testing succession, bars that are beyond this range will not be modeled, but just transcribed into the output succession. The data will not be excluded from the succession in order the correct calculation of indicators on the entire received history to be possible. It must be noted that the first 100 bars will not be modeled either. This limitation does not depend on the date range defined.

To enable date range limitation, one has to flag "Use date" and specify the necessary values in the fields of "From" and "To". After all settings have been made, one can press the "Start" button and start testing. After testing has started, the approximate time of completing of this process can be viewed in the lower part of the window.

Attention:
If "Optimization" is disabled, the expert will be tested, not optimized at pressing of the "Start" button;
at optimization, like at testing, one can use one's own history files.
READMORE -
Optimization of Experts
Optimization represents successive passes of the same expert advisor with different inputs on the same data. At that, such parameters can be sorted out at which the expert efficiency will be maximal. Terminal possesses some built-in means that allow to automate this process. To optimize an expert, one has to flag the option of the same name in the "Tester" window and press the "Start" button.
READMORE -
History Files in FXT Format
In its operation, tester uses an *.FXT file with generated succession of bars. Each record of the generated succession represents the bar status at either moment within one bar. When modeling bars, tester takes other bars from this file and updates the current bar or adds another one if it has just begun to be formed.

One may refuse to apply the standard bar modeling, but use one's own data file for testing/optimization. To do so, one has to disable "Recalculate" and place the desired FXT file into the /TESTER/HISTORY folder. The file name must appear as "[symbol name][period in minutes]_[type of modeling (0 — every tick, 1 — control points, 2 — open prices)].FXT" (without spaces). For example, it can be "EURUSD1440_1.FXT" where "EURUSD" is the security symbol, "1440" is period of D1 (1440 minutes, 24 hours), and "1" means modeling by control points.

A short description of the format is given below. It begins with the header:

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
struct TestHistoryHeader
{
int version; // 404
char copyright[64]; // copyright
char symbol[12];
int period;
int model; // for what modeling type was the ticks sequence generated
int bars; // amount of bars in history
time_t fromdate; // ticks generated from this date
time_t todate; // ticks generating stopped at this date
double modelquality; // modeling quality
//---- general parameters
char currency[12]; // currency base
int spread;
int digits;
double point;
int lot_min; // minimum lot size
int lot_max; // maximum lot size
int lot_step;
int stops_level; // stops level value
int gtc_pendings; // instruction to close pending orders at the end of day
//---- profit calculation parameters
double contract_size; // contract size
double tick_value; // value of one tick
double tick_size; // size of one tick
int profit_mode; // profit calculation mode { PROFIT_CALC_FOREX, PROFIT_CALC_CFD, PROFIT_CALC_FUTURES }
//---- swap calculation
int swap_enable; // enable swap
int swap_type; // type of swap { SWAP_BY_POINTS, SWAP_BY_DOLLARS, SWAP_BY_INTEREST }
double swap_long;
double swap_short; // swap overnight value
int swap_rollover3days; // three-days swap rollover
//---- margin calculation
int leverage; // leverage
int free_margin_mode; // free margin calculation mode { MARGIN_DONT_USE, MARGIN_USE_ALL, MARGIN_USE_PROFIT, MARGIN_USE_LOSS }
int margin_mode; // margin calculation mode { MARGIN_CALC_FOREX,MARGIN_CALC_CFD,MARGIN_CALC_FUTURES,MARGIN_CALC_CFDINDEX };
int margin_stopout; // margin stopout level
int margin_stopout_mode;// stop out check mode { MARGIN_TYPE_PERCENT, MARGIN_TYPE_CURRENCY }
double margin_initial; // margin requirements
double margin_maintenance; // margin maintenance requirements
double margin_hedged; // margin requirements for hedged positions
double margin_divider; // margin divider
char margin_currency[12];// margin currency
//---- commission calculation
double comm_base; // basic commission
int comm_type; // basic commission type { COMM_TYPE_MONEY, COMM_TYPE_PIPS, COMM_TYPE_PERCENT }
int comm_lots; // commission per lot or per deal { COMMISSION_PER_LOT, COMMISSION_PER_DEAL }
//---- for internal use
int from_bar; // fromdate bar number
int to_bar; // todate bar number
int start_period[6]; // number of bar at which the smaller period modeling started
int set_from; // begin date from tester settings
int set_to; // end date from tester settings
//----
int freeze_level; // order's freeze level in points
//----
int reserved[61];
};

Then, the array of modeled bars follows:

#pragma pack(push,1)
struct TestHistory
{
time_t otm; // bar time
double open; // OHLCV values
double low;
double high;
double close;
double volume;
time_t ctm; // the current time within a bar
int flag; // flag to launch an expert (0 - bar will be modified, but the expert will not be launched)
};
#pragma pack(pop)
READMORE -
Testing Results
After the testing has been completed, one can see the results thereof in the tabs of "Results", "Graph", "Report", and "Journal".

Results
Information about all trade operations performed is given in this tab as a table:

# — the trade operation sequence number;

Time — time at which the operation was performed;

Type — type of the operation (sell, buy, s/l, t/p, modify, close at stop, etc.);

Order — ticket number of trade position or pending order (not to be mixed up with the trade operation sequence number described above);

Lots — amount of lots traded;

Price — symbol price during operation;

S/L — the Stop Loss order value. No entries in this field mean that the order was not placed;

T/P — the Take Profit order value. No entries in this field mean that the order was not placed;

Profit — profit/loss. The profit/loss value is entered only at closing of positions;

Balance — balance value. The balance value is recorded only at closing of positions.

Having clicked with the left mouse button on any column header, onl can sort out all entries in the table in increasing or decreasing order. Using the "Copy" context menu command or accelerating keys of Ctrl+C, one can copy the selected lines of results to the clipboard for further use in other applications. If no line has been selected, the entire table will be copied to the clipboard. As well, to copy the entire table to the clipboard, one can execute the "Copy All" command. The report of results can be saved in the hard disk as an HTML file. To do so, one has to execute the "Save as Report" context menu command. The commands of "Set Date "From"" and "Set Date "To"" allow to set the time span for testing. At that, the selected operations dates will be written in the fields of "Use date from:" and "Use date to:" in the testing settings. This can be useful if there is a need to test an expert closely or to optimize its parameters within this range of dates.

Graph
The graph representing the account balance (the blue line is "Balance") and general account status considering open positions (the green line is "Lots") is drawn in the "Graph" tab automatically. If only balance line is displayed in the graph, it means that the lines of "Balance" and "Lots" coincide during the entire testing period. Graph allows changes in trading results during testing even more visualized. If lot sizes were changed during testing, the chart of lot size changes will be shown in the bottom of the graph.

A double click with the left mouse button on any point in the graph will switch to the "Results" button, the corresponding line being selected. Using the "Copy" context menu command or accelerating keys of Ctrl+C, one can copy the graph to the clipboard to be used in other applications. A graph can also be saved in the hard disk as a GIF file. To do so, one has to execute the "Save as Picture" context menu command or press the accelerating keys of Ctrl+S. The commands of "Set Date "From"" and "Set Date "To"" allow to set the time span for testing. At that, the selected operations dates will be written in the fields of "Use date from:" and "Use date to:" in the testing settings. This can be useful if there is a need to test an expert closely or to optimize its parameters within this range of dates.

Report
Generalized results of the expert testing and some key data are represented in the "Report" tab. Such reports allow to quickly compare various experts to each other. The following data are published in reports:

Bars in test — the amount of history data modeled in bars;

Ticks modeled — the amount of ticks modeled;

Modeling quality — the quality of ticks modeled during testing, in per cents. Modeling is shown elementarily as a band in the next line of the report. The band can be of one of three colors:

Gray — this part of available data was not involved into testing. Gray color can appear if there was a date range specified in the testing settings;

Red — modeling was not performed in this space because of missing available data of a less timeframe. At that, only data of the timeframe selected in the testing settings were used;

Green — modeling was performed in this space. And the brighter is the color, the higher modeling quality was. For example, at testing on the H1 period, the deep-green band means that data of M30 period were used for testing, and the brightest one does that M1 data were used;

Attention: If the fastest method ("Open prices only") was selected in the testing settings, the entire band will be red. At that, "n/a" (no modeling was performed) will be written in the "Modeling quality" field;
Initial deposit — the amount of initial deposit;

Total net profit —financial result of all trades. This parameter represents the difference between "Gross profit" and "Gross loss";

Gross profit — the sum of all profitable trades in monetary units;

Gross loss — the sum of all unprofitable trades in monetary units;

Profit factor — the ratio between the gross profit and the gross loss in per cents. One means that these sums are equal;

Expected payoff — mathematical expectation of win. This parameter to be calculated statistically represents average profit/loss factor of one trade. It can also be considered as showing the expected profitability/unprofitability of the next trade;

Absolute drawdown — the largest loss is below initial deposit value;

Maximal drawdown — the largest loss of the local maximum in the deposit currency and in per cents of the deposit;

Total trades — total amount of trade positions;

Short positions (won %) — amount of short positions and the profit percentage thereof;

Long positions (won %) — amount of long positions and the profit percentage thereof;

Profit trades (% of total) — the amount of profitable trade positions and their part in the total trades, in per cents;

Loss trades (% of total) — the amount of unprofitable trade positions and their part in the total trades, in per cents;

Largest profit trade — the largest profit among all profitable positions;

Largest loss trade — the largest loss among all unprofitable positions;

Average profit trade — average profit value within a trade (sum of profits divided into the amount of profitable trades);

Average loss trade — average loss value within a trade (sum of losses divided into the amount of unprofitable trades);

Maximum consecutive wins (profit in money) — the longest series of profitable trade positions and sum of their wins;

Maximum consecutive losses (loss in money) — the longest series of unprofitable trade positions and sum of their losses;

Maximal consecutive profit (count of wins) — the maximal profit within one series of profitable trades and the corresponding amount of profitable trades;

Maximal consecutive loss (count of losses) — the maximal loss within one series of unprofitable trades and the corresponding amount of unprofitable trades;

Average consecutive wins — average amount of profitable positions in consecutive profitable series;

Average consecutive loss — average amount of unprofitable positions in consecutive unprofitable series.

The report can be copied to the clipboard or saved in the hard disk as an HTML file. To do so, one has to execute the context menu commands of "Copy" and "Copy as Report", respectively. The report can also be copied to the clipboard by pressing of accelerating keys of Ctrl+C.

"Journal" Tab
Information about testing process with all trade operations is automatically published in the "Journal" tab. This journal is the same as that of the "Terminal — Experts" window, except for that messages published in the tester window inform about testing of the expert, but not about its operation at the market. After testing has been completed, these data will be output in a separate directory named /TESTER/LOGS. The testing journal files are stored in the /EXPERTS/LOGS directory, file names corresponding with the data of journal — YYYYMMDD.LOG. To view the journals stored, one has to execute the "Open" context menu command and select the desired file. To copy the message to the clipboard, one has to execute the corresponding command of the context menu. The "Clear All Journals" command allows to remove all journals from the directory and clears the tab. This can be useful to clear the hard disk of too many files.
READMORE -
Setup of Testing Parameters
Before starting to test expert advisors, one has to perform the setup. This means that one has to:

select an expert and set up its inputs

select a symbol and its period

select one of three modeling methods

set the testing time range (optional)

To test and optimize experts, a special "Tester" window is used in the terminal. All above parameters are set in the "Settings" tab of this window.

An Expert Advisor and Its Parameters
One has to select an expert to be tested in the "Tester — Expert Advisor" field. One cannot select any expert file in this field. Only those experts that are available in the client terminal can be selected here. To be selected, they must be compiled and located in the /EXPERTS folder.

After an expert has been selected, one has to perform additional setting of testing parameters and inputs. This can be done by pressing of the "Expert properties" button. A new window with three tabs will appear then:

Testing — general testing parameters are set in this tab. These are volume and currency of the initial deposit to be given in the corresponding fields. It is this deposit that will be operated by the expert during testing. Types of positions to be opened at testing are defined here, as well: Only Long — open only long positions; Only Short — open only short ones; Long and Short — open both long and short positions. Whatever expert algorithm is, it will open positions only in the defined directions. One can include an optimization genetic algorithm and select a parameter to be optimized (maximization by the balance value, the profit factor, expected payoff, or minimization by the maximal drawdown value or drawdown percent.

Inputs — the list of all inputs is given here as a table. Inputs are variables that influence the expert operation and can be changed directly from the client terminal. There is no need to change the expert code in order to change these parameters. The amount of input variables can change depending on the expert. At testing, the expert inputs are defined in the "Value" field. Data written in the fields of "Start", "Step", and "Stop" do not influence expert testing and are necessary just for optimization of its parameters. How to work with these parameters is described in the "Optimization Setup" section.

Optimization — settings in this tab allow to limit testing passes at optimization. Changing of parameters in this tab does not influence single testing passes of the expert.

Symbol and Its Period
To start testing, it is not enough just to select an expert and set it up. One has to select a symbol and a period (timeframe) for testing. These are data that will be used for testing. At testing, one can select an available in terminal symbol or use an external data file. History data files of *.FXT format stored in the /TESTER directory are used in testing. These file are created automatically at testing if an available in the terminal symbol was selected. If external data are used, one has to save the corresponding file in the /TESTER directory manually and disable "Recalculate" in order not to overwrite this testing succession.

The symbol is defined in the field of the same name, and timeframe is in the "Period" field. If no data file for this symbol, period and modeling method does not exist yet, it will be created automatically. If the necessary file has already been created and the "Recalculate" option is enabled, the data file will be generated again. If there are no history data for the symbol or period, the tester will download the last 512 history bars automatically.

Attention: If there are some data outside the latest 512 bars for the symbol, the history data will be downloaded automatically, up to the last available one. This can cause sharp increase of the incoming traffic.
Methods of Modeling
Historical data are saved in the terminal only as bars and represent records appearing as TOHLCV (HST format). These data can be used for modeling of price changes at testing of experts. In some cases, such information is not enough for testing. For example, for the daily timeframe, price changes within a bar can result in triggering of the expert. At the same time, no triggering can occur at testing. In other words, testing of an expert based on only bars can be inaccurate and give a false idea about the expert efficiency.

The trading terminal allows to test experts by various methods of historical data modeling. Using historical data from smaller periods, it is possible to see price fluctuations within bars, i.e., price changes will be emulated more precisely. For example, when an expert is tested on one-hour data, price changes for a bar can be modeled on one-minute data. Thus, modeling brings historical data near the real price fluctuations and makes expert testing more authentic.

One of three methods of historical data modeling can be chosen for testing:

Open prices only (fastest method to analyze the bar just completed)
Some automated trading systems do not depend on properties of modeling within a bar, they trade on completed bars. The bar is completed if the next one has appeared. These are such experts for that this modeling method was developed.



In this mode, the bar opening is modeled first (Open = High = Low = Close, Volume=1) what allows the expert to identify the completion of the preceding bar precisely. It is this incipient bar that is used to start testing of the expert. At the next step, the fully completed current bar will be given, but no testing is performed on it!

Control points (the nearest less timeframe is used)
The control points modeling method is intended for a crude estimate of experts efficiency that trade within the bar. The historical data of the nearest less timeframe must be available to apply this method. In some cases, the available data of the less timeframe do not completely cover the time range of the timeframe under test. If the data of the less timeframe are missing, the bar evolution is generated on the basis of predefined wave templates as it was in the preceding, third version of MetaTrader 3 Client Terminal.

As soon as historical data of the less timeframe appear, these new data will be interpolated. However, the really existing OHLC prices appear as control points. In the most cases, the results of testing experts by method of control points can also be considered as estimated ones, not as final ones. Such results are of intermediate, estimated nature.

Every tick (based on all available least timeframes) This is the most accurate method of modeling prices within a bar. Unlike that of "control points", this method uses for generation not only data of the nearest less timeframe, but also those of all available nearest timeframes. At that, if there are data of more than one period for the same timeframe at the same time, the data of the least timeframe will be used for modeling. Like in the preceding method, control points are generated on the basis of OHLC data of the least available timeframe. To generate price movements between control points, interpolation based on predefined templates is also used, so one-minute data are highly desirable to be available that would cover the entire testing range. It is possible that several similar ticks are modeled one after another. In this case, the doubled quotes will be filtered out, and the volume of the last of them will be fixed.



One has to consider the possible large amount of tick data modeled. This can influence the consumed resources of the operation system and testing speed.

Attention:
it is not recommended to launch testing on every tick if there are no available less timeframes that completely cover the period under test, otherwise, the results will not be accurate;
modeling on control points is basically used at optimization of experts, and all ticks modeling is for a close testing.
The modeling quality can be checked in the "Report" window. The "Modeling quality" field and a colored band are intended for this. The band is a scheme of the modeling process. It can be of three colors:

Gray — this part of available data did not participate in testing. Gray color can appear if the date range was specified for testing (described below);

Red — modeling was not performed in this space because of missing data of a less timeframe. At that, only data of the timeframe selected for testing were used;

Green — modeling was performed in this space. And the brighter is the color, the higher the modeling quality was. For example, at testing on H1 period, the deep-green band can mean that data of M30 period were used for testing, and the brightest one does that M1-period data are used.

After modeling parameters and date range (described below) have been changed, the data file must be created afresh. To do so, one has to flag the "Recalculate". If the above setting were not changed, there is no need to recalculate. In this case, it is recommended to disable the above option in order to reduce the testing time.

Time Range
The range of dates allows to test experts not on all available data, but within a certain time space only. This can be useful if there is a need to test a certain part of history data. Date range can be used not only for expert testing, but also for modeling of the testing succession of bars (file of data modeled to be used for testing). It is often no need to model data of the entire history, especially for every-tick modeling where the amount of unused data can be very large. That is why, if data range was allowed to be set at the initial modeling of testing succession, bars that are beyond this range will not be modeled, but just transcribed into the output succession. The data will not be excluded from the succession in order the correct calculation of indicators on the entire received history to be possible. It must be noted that the first 100 bars will not be modeled either. This limitation does not depend on the date range defined.

To enable date range limitation, one has to flag "Use date" and specify the necessary values in the fields of "From" and "To". After all settings have been made, one can press the "Start" button and start testing. After testing has started, the approximate time of completing of this process can be viewed in the lower part of the window.

Testing Visualization
If the ""Visualization"is flagged, after the "Start" button has been clicked, the chart will be opened automatically, on which the modeled tick sequence will be played. The playback speed can be regulated. The playback can be suspended by clicking the "||" button. The repeated click on this button resumes the income of the modeled ticks. Pressing of F12 causes immediate appearance of the next tick even in the suspension mode. Visualization can be skipped up to a certain date. After the desired date is set and the "Skip to" button is clicked, visualizing will stop and then resumed after the tester reaches the defined date.

Attention: If "Optimization" is enabled, expert parameters will be optimized, not tested, after the "Start" button has been pressed.
READMORE -
Strategy Testing
The terminal allows not only write expert advisors, but also test them before using. This useful function allows to check operativeness and efficiency of the trading system on history data. Testing allows to start automated trading with the full knowledge about expert conduct under different market conditions. The special "Tester" window was built into the terminal for this purpose. Using this window, one can optimize expert inputs, as well.
READMORE -
Expert Shutdown
To shut down an expert, one has to remove it from the chart. Expert must have been deinitialized before it is shut down. To remove an expert from the chart, one has to execute the chart context menu "Expert Advisors — Delete" command or attach another expert to the same chart. Besides, the expert can be removed from the chart at profile or template change.

Attention:
at client terminal shutdown, all experts are shut down, too;
at chart closing, the expert attached to this chart will be shut down;
at imposing of another expert, the previous one will be removed after confirmation;
deletion of the expert from the "Navigator" window does not shut down the expert of the same name imposed in the chart;
disabling of experts in the client terminal settings does not provide complete disabling of experts. This option stops launching of the start() function of each expert, but the init() will continue to execute.
READMORE -
Launch of an Expert Advisor
After general parameters have been set up, experts can be launched. To do so, it is enough just to attach the expert to the chart. The "Attach to a chart" command of the "Navigator — Expert Advisors" window context menu or double click with the left mouse button on the selected expert in the same window allows to impose it into the active chart. "Drag'n'Drop" technique allows to impose the expert into any chart. At that, the window of the expert special settings will appear. In its "Common" tab, it is possible:

positions — select the direction of position opening:

Long&Short — in both directions;

Only Long — only for buying;

Only Short — only for selling.

Enable alerts — enable/disable the expert to alert;

Disable alert once hit — disable alerts after the first alert has been given;

Allow live trading — enable/disable live trading;

Ask manual confirmation — request for manual confirmation of position opening when trading;

Allow DLL imports — enable/disable imports of functions from DLL files;

Confirm DLL function calls — request for confirmations at each function call from DLL files;

Allow import of external experts — enable/disable calling of functions from external experts.

External variables of the expert can be changed in the "Inputs" tab. these are variables of extern class. To save an input, one has to double-click with the left mouse button on its value and write the new one. At that, one can change the value of each variable or download the set of inputs already saved (the "Load" button). One can save the current set of external variables using the button of the same name.

The "Reset" button returns all default settings. Parameters defined in the terminal settings are given in the "Common" tab. And parameters defined in the program source code are set as inputs. To attach the expert with the new parameters to a chart, one has to press "OK". To cancel the expert imposing, one has to press the button of the same name.

Attention: Only attached experts can be set up individually. However, while current executing, the window of the expert properties cannot be opened. This can be done only during intervals between calls of the start() function. At that, the expert will not be launched until its properties window is closed. If the expert inputs were changed, the expert will be re-initialized with its new inputs at pressing of "OK".
After an expert has been set up, it will be initialized and, as soon as a new tick incomes, execute. Expert is attached if its name and a smiley can be seen in the upper right corner of the chart. If live trading is disabled in the expert settings, a L will appear instead of the smiley. A dagger (û) means that all experts are disabled.

Attention: Only one expert can be attached to a chart. If another expert is imposed, the previous one will be deleted from the chart.
READMORE -
Expert Setup
Before using of experts, one has to set them up first. Working parameters common for all experts are defined in the client terminal settings window. This window can be opened by the "Tools — Options" menu command or by pressing of accelerating keys of Ctrl+O. To set up expert parameters, one has to select the "Expert Advisors" tab. The following settings are available in it:

Enable Expert Advisors
This option allows to enable or disable the use of all experts. If it is disabled, the start() function will stop execute for all experts when a new tick incomes. At that, the smileys at the expert names in the upper right corners of charts will be replaced with daggers. To enable experts, one has to flag this option and press "OK". They will start functioning when a new tick incomes, and daggers in the upper right corners will be replaced with smileys again.

Attention:
the expert will start function when a new tick incomes, and it often completes its work before the next tick incomes. Disabling of experts does not interrupt working of those that are active already;
this option covers only expert advisors and does not allow to disable custom indicators and scripts automatically.
Disable experts when the account has been changed
This option represents a safety tool that disables experts when the account has been changed. It can be useful, for example, when one switches from a demo account to a real one. To enable it, one has to flag it and press "OK".

Disable experts when the profile has been changed
A large amount of information about the current settings of all charts of the workspace is saved in profiles. Particularly, information about the attached experts is saved in profiles. Experts included into a profile will start working when a new tick incomes. Having enabled this option, one can disable launching of experts when the profile has been changed.

Allow live trading
Experts can work automatically, without trader's participation. They can both analyze price changes and trade. This option is intended for limiting of trading functions of experts. These limitations can be useful for testing of analytical capacities of an expert in the real-time mode (not to be mixed up with testing of an expert on history data).

Ask manual confirmation
This option will only be enabled if experts are allowed to trade. If this option is enabled and the expert tries to trade, one will be able to confirm the trade or interrupt it manually. In other words, trading activities of experts can be managed through this manual confirmation option. This can be useful for testing of trading functions of an expert in the real-time mode (not to be mixed up with testing of an expert on history data)..

Allow DLL imports
Experts can use DLLs to enlarge their functionalities. If this option is enabled, the libraries can be used without any limitations. Disabling of the option results in that no expert can use any external DLLs. It is recommended not to allow DLL imports when working with unknown experts.

Confirm DLL function calls
This option will only be enabled if DLL imports are allowed. It allows to control over execution of each called function manually. If it is disabled, the imports from external libraries will not be controlled. This option is recommended to be enabled when working with unknown experts.

Allow external experts imports
If there is a need to export functions from other experts or MQL4 libraries during the expert functioning, one has to enable this option. If it is disabled, no expert already launched will be able to call functions from other MQL4 programs. This option is recommended to be disabled when working with unknown experts.
READMORE -
Creation of an Expert
To create experts, one has to use MetaQuotes Language 4 (MQL 4) and MetaEditor. To launch the expert editing program, one has to execute the "Create" command of the "Navigator — Expert Advisors" window context menu, or the "Tools — MetaQuotes Language Editor" menu command, or press F4 or the button of the "Standard" toolbar. After that, the Expert Creation Wizard will be opened automatically that allows to immediately start working at a new MQL4 program. One has to flag the "Expert Advisor" as a type of object to be created and fill out the following fields:

Name — expert name;

Developer — the developer's name;

Link — link to the developer's site;

Inputs — the list of expert inputs. To add a new parameter, one has to press the "Add" button or the "Delete" button to delete a parameter.

After that the new expert window with the defined inputs will open in editor. The source file (*.MQ4) of the expert will be saved in the /EXPERTS folder of the client terminal automatically. At this moment, one can start to write the expert code.

After the expert development has been completed, it must be compiled. To do so, one has to execute the "File — Compile" command in the expert editor, or press F5 or the button of the toolbar. As a result of successful compilation an executable program file with *.EX4 extension will be created and saved in the /EXPERTS folder automatically. The list of compiled experts can be viewed in the "Navigator — Expert Advisors" window in the client terminal. If the expert has not been compiled successfully, its icon will be gray. This means that this expert cannot be used.

Editing of Experts
To start editing of the existing expert from the terminal, one has to execute the "Modify" command of the "Navigator — Expert Advisors" window context menu. At that, the experts editor will open where the source code of the selected expert. After the expert source code has been modified, one has to recompile it and get a new executable EX4 file. Otherwise, terminal will use the previous version of the expert, the non-modified one.

Attention: If the expert has not been compiled successfully, its icon will be gray. This means that this expert cannot be used.
READMORE -
Expert Advisors
Expert Advisors (experts) are programs in the terminal that have been developed in MetaQuotes Language 4 (MQL 4) and used for automation of analytical and trading processes. They allow to perform prompt technical analysis of price data and manage trading activities on basis of signals received. The entire routine work of technical analysis and trading can be given to experts. An expert can perform analytical and trading operations for any symbols or periods independent on whether the corresponding chart was opened or not.

Working with experts means:

Creation of an Expert
To create and compile an expert, one has to use the built-in "MetaEditor". It is a constituent of the client terminal and represents a convenient development environment of MQL4 programs.

Expert Setup
Before using of experts, one has to set up them first. Working parameters common for all experts are set in the client terminal settings. Besides, each expert can have its own settings.

Launch of an Expert
To launch an expert, one has to impose it into the chart. As soon as a new tick incomes, the expert will start executing.

Expert Shutdown
An expert advisor is shut down after it has been removed from the chart.
READMORE -
MetaEditor
MetaEditor is a constituent of the client terminal. It is intended for creation, editing, and compilation of program source codes written in MetaQuotes Language 4 (MQL4). It can be used in developing of experts, custom indicators, scripts and DLL's.

Expert Advisors Wizard is built in the editor to assist in fast creation of new MQL4 programs. The new file will be saved in the corresponding folder of the client terminal automatically. Templates can be used in creation of an MQL4 program, as well. After that, one can start writing of the program text. The supplemental information can be found in MQL4 Dictionary. The full description of the language with examples of how to use it is given there. After the program has been written, one has to compile it in MetaEditor. As a result of successful compiling, the executable program code will be created that can be launched or tested in the terminal.

A detailed description of MetaEditor can be found in its Help Files.
READMORE -
MetaQuotes Language 4
MetaQuotes Language 4 (MQL 4) is the language for programming of trade strategies built in the client terminal. It allows to write custom expert advisors that automate trade processes and ideally suit for implementation of traders' own strategies. Moreover, traders' own custom indicators, scripts and DLL's can be created in MQL 4.

Syntax of MQL 4 is quite similar to that of C language. A large amount of functions necessary to analyze quotes, manage positions, call technical indicators, and others, are included in MQL 4. The MetaEditor, an editor for expert advisors, is used for writing the source code of programs. The MetaQuotes Language Dictionary that contains descriptions of all language constructions and functions is built in the editor.

Programs written in MQL 4 are different in tasks and properties:

Expert Advisor is a mechanical trading system (MTS) to be run when a new tick incomes. It can work not only in the mode alerts, but also perform trade operations independently. Terminal allows to test trading strategies on history data in order to detect the expert features under different market conditions;

Custom Indicator is a technical indicator written individually. Custom indicators are used only for analyzing of price changes;

Script is a program that is intended for a single execution of some actions. Unlike experts, scripts are launched not tick by tick, but on a command.
READMORE -
Auto Trading
To work at financial markets more effectively, one can develop one's own successful system of trading. It is very difficult to act within a chosen system of trading in the manual mode due to significant influence of normal human emotions. Mechanical trading systems do not suffer from this disadvantage.

Client Terminal gives a large range of means for development and use of mechanical trading systems (MTS, experts, advisors). The development environment allows to create, debug, and test expert advisors. Experts are able not only alert about recommendation trading signals, but undertake the complete control over trading activities online.

MetaQuotes Language 4, MetaEditor and strategy testing tools are built in the terminal. One can create the following using these means:

Expert Advisors — mechanical trading systems that allow complete automation of analytical and trading activities;

Custom Indicators — independently written technical indicators intended for analyzing of price changes;

Scripts — programs to be executed only once, on request.
READMORE -
Deletion of a Pending Order
If market situation has been changed, there can occur a necessity to delete a pending order. To do so, one has to execute the "Modify or Delete Order" pending order context menu command or double-click with the left mouse button on the status bar of the pending order in the "Terminal — Trade" window. The window that manages orders will open. To delete an order, the button of the same name must be pressed in it. Pending orders can also be deleted automatically at the time that has been given in the "Expiry" field. When a pending order has been deleted, the corresponding record will appear in the "Terminal — Account History" window.
READMORE -
Modifying of Pending Orders
When working at the market, one often needs to modify or delete the placed pending order. To do so, one has to execute the pending order context menu command of "Modify or Delete Order" or double-click with the left mouse button on the pending order status bar in the "Terminal — Trade" window. The window for order managing will open. New price of the pending order triggering, new levels of Stop Loss and Take Profit, as well as expiry time of the order can be set in this window. After the order has been modified, one has to press the "Modify" button.

Attention: Setting of zero values for Stop Loss and Take Profit equals to disabling of these orders.
If the pending order has been successfully modified, the values of the corresponding fields in the "Terminal — Trade" window will be changed. If the "Show trade levels" option in the terminal settings has been enabled, the pending order levels and those of Stop Loss and Take Profit attached to it will be shifted correspondingly in the chart, as well.
READMORE -
Placing of Pending Orders
To place a pending order, one has to open the "Order" window. This can be done by the "Tools — New Order" menu command, the button of the "Standard" toolbar, by pressing of F9, by the "New Order" command of the "Market Watch" and "Terminal — Trade" window context menus, as well as by double-clicking on the symbol name in the "Market Watch" window. "Pending Order" must be selected in the "Type" field of this window.

Further, a security (symbol) must be selected, the volume and values of Stop Loss and Take Profit orders must be specified. If necessary, a comment can be written in the field of the same name. In the "Pending Order" fields one has to:

Type — select a type of pending order: Buy Limit, Buy Stop, Sell Limit, or Sell Stop;

at price — set the price level at which the order must trigger;

Expiry — set the expiry time of the order. If the order has not triggered by this time, it will be deleted automatically.

Attention: Order may not expire earlier than in 10 minutes!
The "Place" button will send the order to be executed what is performed in two stages. First, the brokerage company places the order after it has been sent. At that, a line containing the number and status of the pending order will appear in the "Terminal — Trade" tab. If the "Show trade levels" option is enabled, levels of the placed pending order (including levels of Stop Loss and Take Profit) will be shown in the chart. At the second stage, if prices correspond with the order provisions, it will be deleted and a trade position will be opened instead of it. The trade position ticket will coincide with the pending order ticket. These changes will be shown in the "Terminal — Trade" window.

Attention: Stop Loss and Take Profit orders trigger only at open positions, but not at pending orders.
READMORE -
Position Close
Buying or selling of a security opens a trade position. Then, in order to gain profit of the bid-and-ask price differences, one has to close the position. The latter trade operation is reverse towards to former one. For example, if the former operation consisted in buying of one lot of GOLD, then one lot of the same symbol must be sold to close the position. Positions can be closed differently in the client terminal: It can be closing of a single position, closing of a position by an opposite position, and multiple close by several positions.

Single Position Closing
A single open trade position will be closed automatically if prices equal to values of Stop Loss or Take Profit.

Attention: When a long position is being closed, the Bid price must equal to the value of Stop Loss or Take Profit, and Ask price must do for short positions.
To close a position manually, one has to execute the opened position context menu command of the "Terminal — Trade" window or double-click with the left mouse button on this position. If trade operations for a certain symbol are executed on request, one has first to receive quotes by pressing of the "Request" button. This activates the button that allows to close position.

Attention:
in the "Execution on request" mode, the offered quotes will be active for just a few seconds. If no decision has been made within these seconds, the "Close... " button will be locked again;
client terminal allows to close positions partially. To do so, one has to specify the amount of lots less than that given for the opened position in the "Volume" field before pressing of the "Close... " button;
broker can close positions, as well. For example, it can be done when prices reach the "Stop Out" level that was set by the broker;
history charts are drawn only on BID prices in the terminal. At that, a part of orders shown in charts is drawn on ASK prices. To get ASK price of the latest bar shown, one has to flag "Show Ask line" option in the terminal settings.
Close by Opposite Positions
Opposite position towards the given one is a reverse position for the same symbol. If there is one or more opposite positions among the open positions, one can close the selected position by and together with an opposite one. To do so, one has first to open the "Order" window (as described above). Then, the "Close by the opposite" must be selected in the "Type" field. After that, the list of all opposite positions will appear in the lower part of the window. One has to select an opposite position in this list, and after that the "Close... " button will be activated. It allows to close two positions at the same time. Only one of two opposite positions with different amounts of lots to be traded will remain. The volume (amount of lots) of this position will equal to the difference between lots of the two closed positions, and its direction and open price (short or long) will correspond with those of the larger (in volume) of two closed positions.

Multiple Close by Opposite Positions
Multiple close of several opposite positions allows to close more than two opposite positions at the same time. To preform this operation, one has also to open the "Order" window (as described above). Then the "Multiple close by" must be selected in the "Type" window. At that, the list of all opposite positions will appear in the lower part of the window, and the "Multiple close by... " button will be active. It allows to close opposite positions. Positions will be closed in pairs, according to the open time, and they will be closed as described above for two opposite positions. If the difference between the sums of volumes is not zero, a new position will be opened as a result of the operation, the volume being equal to this difference. The newly opened position will participate in the multiple close process, but according to its open time, and so on until all positions are closed or the last resulting position is opened.

Attention: After opposite positions have been closed, the corresponding records will be made in the "Terminal — Account History" window. At that, overhead information about closing of opposite positions will be entered in the "Comment" field.
READMORE -
Modifying of Positions
Modifying of the current position consists in setting of new levels of Stop Loss or Take Profit attached to it. To modify a position, one has to execute the "Modify or Delete Order" command of the opened position context menu or doulbe-click with the left mouse button in the fields of "Stop Loss" or "Take Profit" of the opened position line in the "Terminal" window. Then, one has to set new values of Stop Loss or Take Profit and press the "Modify" button.

To change the Stop Loss or Take Profit values, one has to enter the new values in the corresponding fields. To place the order in points from the current price, one has to set the desired value in the "Level" field and press the "Copy as" button. If values of these fields are zero, the minimum permissible deviation is used to be set by broker.

If Stop Loss or Take Profit level is too close to the current price, the "Modify" button will be locked. It is necessary to shift levels from the current price and re-request for position modifying. A trade position will be modified after the brokerage company has set a new value for Stop Loss or Take Profit, or both. Values in the fields of "S/L" and "T/P" will be changed in the opened position status bar in the "Terminal — Trade" tab. At that, levels of the modified orders will be changed if the "Show trade levels" option is enabled.

Attention: Zero values in the fields of "Stop Loss" and "Take Profit" mean that these orders were not placed.
READMORE -
Open Positions
Opening of a position, or entering the market, is the first buying or selling of a certain amount of the security traded. Position can be opened either by execution of a market order or by automatic triggering of a pending order.

Market Order
To open a position using a market order, one has to execute the "Tools — New Order" menu command, press the button of the "Standard" toolbar, press F9, or double-click on the symbol name in the "Market Watch" window. One can also execute the "New Order" context menu command of the windows of "Market Watch" and "Terminal — Trade". At that, the "Order" window will open that is used for managing of trade positions. When opening a position, one has to:

Symbol — select a security symbol for which the position is to be opened;

Volume — specify the trade volume (amount of lots);

Stop Loss — set the Stop Loss level (optionally);

Take Profit — set the Take Profit level (optionally);

Attention: Zero values of Stop Loss/Take Profit orders mean that the orders have not been placed at all.
Comment — write a comment (optionally). The comment length may not exceed 25 characters. The brokerage company may add a comment not above 6 characters long, or it can completely replace the existing one. After a position has been opened, the comment cannot be changed;

Enable maximum deviation from quoted price — enable/disable the use of deviation. If a broker requotes the price of order execution, the deviation of the new price from the quoted before will be calculated. At that, if the deviation is below or equal to the specified parameter, the order will be excuted at the new price without any additional notifying. Otherwise, the broker returns new prices at which the order can be executed;

Maximum deviation: — the value of maximum permissible deviation in pips.

Attention: Price deviation at placing of orders is used only in the instant execution mode.
After all necessary data have been specified, one has to press the "Sell" or "Buy" button. At that, the order for opening of a short or long position, respectively, will be sent to the broker.

Attention: If orders for a given symbol are executed at request, it is necessary to press the "Request" button to receive quotes first. Quotes offered after requesting will be active for just a few seconds. If no decision is made within these seconds, "Sell" and "Buy" buttons will be locked again.
If the Stop Loss or Take Profit level is too close to the current price at opening of a position, the message of "Invalid S/L or T/P" will appear. It is necessary to shift levels from the current price and re-request for placing of the order. A trade position will be opened after the brokerage company has made a trade and set Stop Loss and Take Profit. At that, the status bar of the opened position will appear in the "Terminal — Trade" tab, and open price, Stop Loss and Take Profit levels will be shown in the chart (if the "Show trade levels" option is enabled).

Pending Orders
To open a position with a pending order, one has to place it first as described in the "Placing of Pending Order" section. If the current prices meet its provisions, the pending order will be executed automatically, i.e., a new trade position will be opened. At that, the status bar of the pending order will be deleted in the "Terminal — Trade" tab, and the newly opened position status bar will appear. If Stop Loss and Take Profit orders were attached to the pending order, they will be attached to the new position automatically.
READMORE -
Trade Positions
The fundamental and simple rule of profitable trading at financial markets is to buy cheaper and sell dearer. Thus, the entire trading activities at financial markets come to the successive operations performed to sell or buy securities. To do so, one has to open, modify, and close trade positions. Trade position is a market commitment (order), the number of bought or sold contracts for which no set-off transactions have been made. The entire trading in the terminal is implemented through trade positions. Client Terminal gives a large amount of opportunities in controlling and managing of trade positions. Trader gives instructions (orders), and brokerage company opens or closes a position. Managing of trade positions consists in:

opening of a position — buying or selling of a security as a result of a market or a pending order execution;

modifying of a position — changing of the Stop Loss and Take Profit levels attached to the open position;

placing of pending orders — placing of pending orders like Buy Limit, Buy Stop, Sell Limit, or Sell Stop;

modifying and deletion of pending orders — modifying or deletion of pending orders that did not trigger;

closing of a position — buying or selling a security in order to close the existing open position.
READMORE -
Types of Execution
There are three order execution modes in the client terminal:

Instant Execution
In this mode, the order is executed at the price offered to the broker. At sending the order to be executed, terminal sets the current prices in the order. If broker accepts the prices, the order will be executed. If not, the so-called "Requote" will occur: Broker returns prices at which the order can be executed.

Execution on Request
In this mode, the market order is executed at the price previously received from the broker. Prices for a certain market order are requested from the broker before the order is sent. After the prices have income, order execution at the given price can be either confirmed or rejected.

Execution by Market
In this order execution mode, broker makes a decision about the order execution price without any additional discussion with the trader. Sending of the order in such a mode means advance consent to its execution at this price.

Attention: Execution mode for each security is defined by the brokerage company.
READMORE -