Showing posts with label MT5 Documentation. Show all posts
Showing posts with label MT5 Documentation. Show all posts

A few months ago MetaQuotes released the beta version of the MetaTrader 5 Strategy Tester - Metatester 5. In this article i will do a quick review of it's options and features. Note that Metatester 5 in still in development, so new options and features can be added to it later (for example, visual backtesting and the option to display your backtested trades on the chart are missing).

There is no separate download file for the Metatester 5, the tester is one of components of the client terminal so it's distributed along with the MetaTrader 5 setup file. To open the tester press CTRL+R or click on its icon. The main window is not so different from MT4 tester. The "expert properties" button from the old tester is gone ( along with "symbol properties", "open chart" and "modify expert") the options are now present under the inputs tab and optimization properties below in the main window:

MetaTrader 5 Strategy Tester image
During the testing process, history for the selected currency will be automatically downloaded from the MetaQuotes servers ( around 10-15MB for one symbol). The history is stored in M1 format from 1999, before only in D1 format ( tick data or xx seconds bars are not available ). For the demo-account, the history is stored in C:\Program Files\MetaTrader 5\Bases\MetaQuotes-Demo\history\"symbol"\ folder and has the .hcc (uncompressed) format, per symbol it takes around 180MB of hdd space. Currently, there is no easy option to use separate external history like in MT4 (there is no mql5 DDE server), but according to MetaQuotes, the option to edit history and view history like in MT4 will be probably added later ( it was also recently confirmed by MetaQuotes staff on the MQL5 forums ).

MetaTrader 5 Strategy Tester image

MetaTrader 5 Strategy Tester image
Settings in Metatester 5:

1. Optimization

MetaTrader 5 Strategy Tester image
Optimization ( Testing of the EA on history data with different sets of parameters, aimed at finding their best combination. During multiple runs, different combinations of the input parameters of the EA are tried and the best ones are selected. Note that an EA must have some input parameters that can be optimized like take profit, trailing or technical parameters like period etc. ). If optimization is disabled, the EA is tested with default input parameters.

- Fast Genetic Based Algorithm is based on the genetic algorithm of searching the best values of input parameters. This type is much faster than the slow complete algorithm and is almost of the same quality.

- Slow Complete Algorithm: runs are performed for all possible combinations of values of the input variables selected for optimization. This method is the most precise one, but also takes much more time.

From the MQL5 documentation: Genetic optimization is based on the constant selection of the most "adapted" parameters (values that give the best result). From the total number of all possible combinations of parameters, two populations (sets) are selected by a random sample. After that, both sets are tested and the one with the best results (according to the optimization criterion) is left. The set members are randomly crossed with one another, undergoing random mutations and inversions of parameters. The descendants are sorted out by the best results, and crossing repeats.

Operations of sorting and crossing repeat until there is improvement of results (the best result among descendants is better than the best one among the parents). The completion of optimization requires absence of improvement of the optimization criterion during several crossings (generations). During a genetic optimization, the number of testing runs is much lower, which provides such a quickness of optimization.
- All Symbols Selected in Market Watch: unlike the above described optimization types, this one allows to test an EA with the same input parameters but using different symbols. Only the main symbol of testing is changed in each pass, i.e. the symbol of chart the EA would be attached to. The optimization is performed only with symbols that are currently chosen in the "Market Watch" window. So, by selecting the various symbols, you can manage the optimization.

2. Optimization Criterion

MetaTrader 5 Strategy Tester image
The optimization criterion is a certain factor, whose value defines the quality of a tested set of parameters. The higher the value of the optimization criterion is, the better the is testing result with the given set of parameters:

Balance max — the highest balance;
Balance + max Profit Factor — balance and profit factor;
Balance + max Expected Payoff — balance and expected payoff;
Balance + min Drawdown — balance and lowest drawdown; ( recommended )
Balance + max Recovery Factor — balance and the recovery factor;
Balance + max Sharpe Ratio — balance and the Sharpe ratio;
Custom max — the optimization criterion here is the value of the OnTester() function in the EA. This parameter allows using any custom value for the optimization of the EA.

3. Forward Mode

This option allows checking optimization results to eliminate fitting on certain time periods. During the forward optimization, the period set in the "Date" field is divided into two parts in accordance with the selected forward period (half, one third, a fourth or a custom period, when the start date of the forward testing is set). On the first part, the EA optimization is conducted. After that the best passes are selected (10% at the full parameters fitting, or 25% at a genetic algorithm), and only they are started on the forward period. The results of the best passes in the optimization on both periods can then be compared on the "Optimization Results" tab.

Tick Generation Mode

- Every tick: the most accurate mode but also the slowest one. All ticks are modeled in it;
- 1 Minute OHLC: only 4 prices (Open, High, Low and Close) of each minute bar are modeled;
- Open prices only — OHLC prices are modeled, however only the open price is used for testing/optimization.

4. Input Parameters

MetaTrader 5 Strategy Tester image
This options tab allows managing the Expert Advisor's input parameters. An EA must have at least 1 input parameter that can be optimized. Select the input parameters that must be optimized, select a start and stop value ( for example, take profit from 50 to 200 ) and a step value ( step of trying of the parameter values ). If there are to many steps, the optimization process will take a very long time. So the best strategy is to use a big step value, and then after some optimization rounds reduce it to smaller values:

MetaTrader 5 Strategy Tester image
If you right click on the Input Parameters window, a context menu window will appear where you can load or save your input parameters or select the default options:

MetaTrader 5 Strategy Tester image
Agents:

The process of testing and optimization of Expert Advisors is performed using "agents". The number of available local agents (started on the computer where the terminal is installed) is equal to the number of logical cores of the processor. Agents are created automatically. MetaTrader 5 Strategy Tester allows working with the unlimited number of external (remote) agents using all available computation powers. I will write about it in the next article.

MetaTrader 5 Strategy Tester image
Optimization results:

MetaTrader 5 Strategy Tester image

MetaTrader 5 Strategy Tester image
Results of the EA's optimization are displayed on the Optimization results tab. You can sort the optimization results by data such as Result (the resulting value of the parameter that is the optimization criterion used for selecting the best runs), profit factor etc. There is also a context menu ( via right click ) where you can execute commands like "Run Single Test" (start testing of the EA with the parameters of the selected run), etc. You can also view the Optimization Graph, a visual representation of the optimization process in the Optimization Graph Tab.
From the MQL5 documentation:
- Pass — pass number;
- Result — the resulting value of the parameter that is the optimization criterion used for selecting the best runs;
- Profit — obtained profit/loss for this run;
- Total trades — total number of trades executed for the run;
- Profit factor — ration of the total profit to the total loss in percents. One means that the total of profits is equal to the total of losses;
- Expected payoff — this is a statistically calculated value that reflects the average profitability/loss of one trade;
- Drawdown — the relative drawdown of equity, the largest loss in percents from the maximal value of equity;
- Recovery factor — this value reflects the riskiness of the strategy - the amount of money risked by the Expert Advisor to make the profit it obtained. It is calculated as the ratio of a profit obtained to the maximal drawdown;
- Sharpe Ratio — this ratio characterizes efficiency and stability of a strategy. It reflects the ratio of the arithmetical mean profit for the position holding time to the standard deviation from it. Plus to that, it accounts for the risk-free rate which is the profit on a certain deposited amount of money;
- Optimized inputs — in addition to the common statistical values, values of input parameters set for this run are shown here.
Strategy testing results:

MetaTrader 5 Strategy Tester image
Results of an EA testing are displayed in the Results tab. You can view the trading history of the EA for the period of testing and different statistical results.
From the MQL5 documentation:
- Initial Deposit — the initial deposit for testing;
- Bars — number of bars generated for the symbol the testing is conducted on;
- Ticks — number of ticks during testing;
- Gross Profit — sum of all profitable trades in monetary units;
- Gross Loss — sum of all losing trades in monetary units;
- Total Net profit — the financial result of all trades. This values is the difference between the Gross Profit and Gross Loss;
- Profit Factor — ratio of the gross profit to the gross loss in percents. One means that the sum of profits is equal to the sum of losses;
- Expected Payoff — this is a statistically calculated value showing the average profitability/loss of one deal. This value can also be considered as a forecasted profitability/loss of the next deal;
- Recovery Factor — this value reflects the riskiness of the strategy - the amount of money risked by the Expert Advisor to make the profit it obtained. It is calculated as the ratio of a profit obtained to the maximal drawdown;
- Sharpe Ratio — this ratio characterizes efficiency and stability of a strategy. It reflects the ratio of the arithmetical mean profit for the position holding time to the standard deviation from it. Plus to that, it accounts for the risk-free rate which is the profit on a certain deposited amount of money;
- Balance Drawdown Absolute — the maximal loss on the balance below the initial deposit;
- Balance Drawdown Maximal — the maximal loss from the local maximum in the deposit currency and as percent from the deposit;
- Balance Drawdown Relative — the maximal drawdown from the highest balance value in percents, and the appropriate money value;
- Equity Drawdown Absolute — the largest loss on assets below the initial deposit;
- Equity Drawdown Maximal — the largest loss from the local maximum in the deposit currency and as percent from the deposit;
- Equity Drawdown Relative — the largest loss in percents from the maximal value of assets, and the appropriate money value;
- Total trades — the total number of executed trades;
- Short Positions (won %) — number of short positions and percent of winning short positions;
- Long Positions (won %) — number of long positions and percent of winning long positions;
- Profit Trades (% of total) — number of winning trades and their percentage in the total number of trades;
- Loss trades (% of total) — number of losing trades and their percentage in the total number of trades;
- Largest profit trade — the largest profit among all winning trades;
- Largest loss trade — the largest loss among all losing trades;
- Average profit trade — the average profit value per a trade (the total of profits divided by the number of winning trades);
- Average loss trade — the average loss value per a trade (the total of losses divided by the number of losing trades);
- Maximum consecutive wins ($) — the longest series of winning trades and their total profit;
- Maximum consecutive losses ($) — the longest series of losing trades and their total loss;
- Maximal consecutive profit (count) — the maximal profit for one series of winning trades and the number of winning trades in it;
- Maximal consecutive loss (count) — the maximal loss for one series of losing trades and the number of losing trades in it;
- Average consecutive wins — the average number of winning trades in winning series;
- Average consecutive losses — the average number of losing trades in losing series.
Via the context menu ( right click ) you can export the report as a html/xml file.

MetaTrader 5 Strategy Tester image
In the Graph tab, the results of the EA testing are represented in a graphical form with the balance curve (blue line) and the equity curve (green). The margin level is displayed the bottom (histogram of margin level in percents). Via the context menu ( right click you can export the graph to other programs like MS Excel or save the image to clipboard.

Log

MetaTrader 5 Strategy Tester image
In the Log tab you can find a record of the actions, performed by the tester during the EA's testing and optimization and warning/error messages. The log file is automatically saved to the C:\Program Files\MetaTrader 5\Tester\... folder. ( *.log files ).




Read more about the MetaTrader 5 Strategy Tester here: The Algorithm of Ticks’ Generation within the Strategy Tester of the MetaTrader 5 Terminal: http://www.mql5.com/en/articles/75 and here ( at the end of the article, the optimization process is shown) - An Example of a Trading System Based on a Heiken-Ashi Indicator: http://www.mql5.com/en/articles/91

You can leave feedback, suggestions and bug reports in the Metatester 5 thread on the MQL5 website: http://www.mql5.com/en/forum/851

MetaTester 5
MetaQuotes is about to release the MetaTrader 5 trading strategy tester ( MetaTester 5 ). One of the big improvements of the new tester is the possibility to create individual calculation frameworks ( agents ) to increase the speed of trading strategies optimization / calculation. On the local computer, each agent represent 1 logical processor core, so for example if you have a quad-core cpu, you can have 4 agents running. The agents can be also installed on remote computers in your local network or other Internet-connected computers around the world. This means that you can create a distributed computing (grid computing) project with as much cpu power as you want. This concept is similar to the popular SETI@home or Folding@Home projects.

MetaTester 5
The installation of (remote) agents is very simple, according to information from MetaQuotes, all you need is to use MetaTester.exe (a single file, nothing else is required) and install agents as services according to the number of cores or one by one. A separate access password is set for each agent, to ensure that only authorized users connect to it. The client terminal on the central computer plays a manager role and coordinates all the (remote) agents. Each agent opens one local TCP port and waits for connection from the manager client terminal. You can configure all the connections in your router/firewall if it's necessary. The connections will be encrypted and protected by password to ensure maximum security. Once you have everything configured, the entire system will operate in automatic mode. If an agent will interrupt his work, his task will be transferred to the next available agent.

MetaTester 5
The new Metatrader 5 strategy tester will be much faster than in MT4 because the tester will function as a standalone application. Also, there will be a x64 version of the Metatrader 5 terminal & tester and the MQL5 code will be automatically compiled to native x64 code with access to all available memory. This means that you can use computers with dozens of gigabytes of memory. However, the strategy tester does not support Nvidia CUDA platforms because they are slow in processing of general purpose algorithms, and this is any program on MQL5. Instead of CUDA, every cpu that uses SSE2 (Pentium 4 or higher) is supported.

MetaQuotes will also launch a service on the MQL5 community website where computer power for remote agents will be sold. Everyone will be able to sell it, for example, you can sell your quad core cpu power from 1 to 6 AM. You can also buy the computer power direct form the MQL5 website. For it's services, MetaQuotes will take a small fee from the money which go to the seller.

Of course, the security measures will be also great:

* Fully encrypted compressed traffic network protocol between the client terminal and the agent;
* Access by password;
* Ability to specify a list of the IP addresses allowed to connect to the client terminal;
* Only local agents can use the DLL libraries with the appropriate authorization in the terminal;
* The EA's code wich is passed to the remote agent is never stored on the HDD of the agent and is passed in a modified form, it is impossible to dump;
* A remote agent does not know the name of the EA and does not save the results of calculated data to it's HDD;
* The agent program is also good protected from disassembly or modification.

According to MetaQuotes, the Metatrader 5 strategy tester will be soon available. Probably March/April 2010.

Read more about Metatrader 5 Agents

This is the first article in a 5-part series about the Metatrader 5 Fibonacci Tools:

Fibonacci retracement is a very popular and extremely useful for setting the stop-loss and take-profit levels and strategic places for transactions. The notion of retracement is used in many technical indicators such as Gartley patterns, Tirone levels, Elliott Wave theory etc. Many traders use Fibonacci retracement indicators in their daily or long-term Forex trading. These methods are good known in the Forex community and have a lot of literature en resources about them. Fibonacci retracement is created by taking two extreme points (local top and bottom) and dividing the vertical distance by the key Fibonacci ratios as showed on the picture below. The horizontal lines are used to identify possible support and resistance levels.

In this article we are going to customize the Fibonacci settings within Metatrader 5 so that it can plot both retracements & extensions simultaneously.

Metatrader 5 Fibonacci Tools 1

In Metatrader 5 you can find the tool under the menu Insert >> Objects >> Fibonacci >> Fibonacci Retracement. On the chart simply do a random placement, place it anywhere on the chart, does not matter:

Metatrader 5 Fibonacci Tools 2

Then, Right-click anywhere on your chart where there is open space. Select Objects List from the pop-up menu ( or press Ctrl + B on the keyboard ) and left-click. Within the Objects window, select Fibo and then click on the Edit button. You should see this:

Metatrader 5 Fibonacci Tools 3

On the Fibo properties screen, use the Delete button to remove all existing levels. After that use the Add button to add the following values as shown below and click OK.

Metatrader 5 Fibonacci Tools 3

Main Fibonacci Retracements Levels:

Level
0
0.146
0.236
0.382
0.5
0.618
0.786
0.86
0.942
1
-0.18
-0.27
-0.382
-0.618
-1
-1.618
-3.236
Description
0.0 - %$
14.6 - %$
23.6 - %$
38.2 - %$
50.0 - %$
61.8 - %$
78.6 - %$
86.0 - %$
94.2 - %$
100.0 - %$
118.0 - %$
127.0 - %$
138.2 - %$
161.8 - %$
200.0 - %$
261.8 - %$
423.6 - %$


After that you should see the following prices and percentages appearing on the Fibonacci line labels:

Metatrader 5 Fibonacci Tools 5

As described above, a Fibonacci Retracement is created by taking a local top and bottom and dividing them with the vertical distance line:

Metatrader 5 Fibonacci Tools 6

Here are the C-to-D rules:

23.6% >> 118% | 127%
38.2% >> 138.2%
50% | 61.8% >> 161.8%
78.6% >> 0% | 161.%
86.0 >> 0%
100.0+ >> Reversal ( thanks to Black_Knight for the C-to-D rules)

In the future, i will write more about the trading techniques with Metatrader 5 Fibonacci Retracements. For example, you can draw the Fibonacci Retracement at the beginning of the day to know the direction of the movement expected and it is important to have two points of view, one large view, where the Fibonacci Retracement is located on the historical high and one other small view with the last daily high. Try to compare the moment position to these two Fibonacci levels and the daily pivot levels so you can locate the important support and resistance levels.

You can also read more about the trading here.

Some time ago, Paul (phampton) wrote on his blog about the creation of extended documentation for the MQL5 code using some free tools like Doxygen and HTML Help. This extended documentation in the form of a a compiled HTML help file, includes class hierarchies and methods for all the code distributed under the MQL5 folder, like the MQL 5 indicators or the MQH include files.

Each MQL5 file has a reference list with all functions and variables and everything is cross-linked. There is also an alphabetical index for it. This way it can help you a lot to learn the new Metatrader 5 MQL5 programming language. You can also add custom made indicators and other MQL5 files to the documentation. Below are some screenshots illustrating the documentation file:

mql5 metatrader 5 extended documentation

mql5 metatrader 5 extended documentation

mql5 metatrader 5 extended documentation

mql5 metatrader 5 extended documentation

Paul has already compiled the documentation file, and you can download it here.
If you want to learn how you can create such a documentation file yourself, read the post on Paul's Blog.

metatrader 5 user guide

Here are the user guides for MetaTrader 5, MetaEditor 5 and MQL5. You can find there many useful information regarding all features and possibilities of the new MT5 Platform. Topics like user interface, working with charts, analytics, market watch and trading, etc. are covered. It is now the best source of documentation to read. ;)

The MQL 5 User guide is not yet available in English so it was translated via Google Translate.

You can find the MetaTrader 5 and MetaEditor 5 user guides in your \MetaTrader 5\Help\ folder. But if you didn't install the MT5 beta, you can download the user guides below.

Download:

MQL 5 User Guide

Metatrader 5 Terminal User Guide

Metaeditor 5 User Guide

Here i will post all information about the Metatrader 5 documentation and tutorials. This post will be regularly updated with links to new content.



- Multi-Currency Strategy Testing with MetaTrader 5
- MetaTrader 5 Strategy Tester Overview
- Auto-generated MQL5 documentation
- Moving from MQL4 to MQL5
- History in Metatrader 5
- MT5, Metaeditor 5 and MQL5 User guides
- MQL5: No graphical objects in indicators
- Analytics in MetaTrader 5
- Review of the Metatrader 5 Beta
- MetaTrader 5 Trading System
- Metatrader 5 development environment: MQL4 vs MQL5
- MT5 order management and trading system
- MetaTrader 5 Client Terminal - first screenshots and information
- Depth of Market feature of MT5
- Interview with Stanislav Starikov, leading programmer of MQL5 about the development of Metatrader 5 and MQL5
- Impressions from the MetaQuotes workshop entitled "MetaTrader 5 - Next Generation Trading Platform
- Suggestions for Metatrader 5
- Metatrader 5 and MQL 5 Development - questions and answers