Русский 中文 Español Deutsch 日本語 Português
Testing Features and Limits in MetaTrader 4

Testing Features and Limits in MetaTrader 4

MetaTrader 4Examples | 13 September 2005, 13:37
21 592 4
MetaQuotes
MetaQuotes

Introduction

This article allows to find out more about features and limits of Strategy Tester in MetaTrader 4.

Special Features of Testing Strategies on History Data
  • Some functions are processed/passed without output

    These are Sleep(), Alert(), SendMail(), PlaySound(), MessageBox(), WindowFind(), WindowHandle(), WindowIsVisible()

  • Trading is permitted for the symbol under test only, no portfolio testing

    Attempts to trade using another symbol will return error

  • Lot sizes including initial size and increment step, commissions and swaps should be taken from the active account settings

    Before testing, it is necessary to make sure that there is at least one activated account in the list in "Navigator" window of the terminal.

  • All swaps, margin requirements, expirations, GTC-orders are modeled

    Testing is performed maximally closely to trading server conditions. But the can occur some inaccuracies in estimation of margin requirements on cross currencies because of lack of precise information about conversion prices at each moment.

  • Zero bar of another timeframe for the same symbol under test is modeled approximately

    Open = correct Open, Close = correct Close, Low = min (Open,Close), High = max (Open,Close), Volume = final Volume (false)

  • Instant Execution mode is assumed to be used in trades, being processed without slippage
  • Processing orders, Open/Close without slippages
  • Testing stops after StopOut
  • Weekly, monthly, and irregular timeframes are not tested
  • The deposit currency can be changed, but conversion prices are set, and the current available ones are used
  • There are still no delays in execution of trade operations

    A setup delay is planned to be introduced in processing of transactions

  • Account History is fully available, and it does not depend on settings
  • If other symbols and periods are actively used, it is desirable to download them to all possible depth
  • At every-tick modeling, tester pumps all necessary timeframes for the symbol under test independently
  • Using of MarketInfo function generates error ERR_FUNCTION_NOT_ALLOWED_IN_TESTING_MODE(4059), however, correct information about current prices for the symbol under test, about stop level dimensions, about point size, about spread size of any symbol being present in the quotes window is provided.

Special Features of Optimization Process

  • Nothing is output in the journal (either Print() function)

    This was done in order to accelerate the testing and save disk space. If complete logs are output the journal files will need hundreds of MByte.

  • Draw objects are not really set

    The objects are disabled in order to accelerate the testing.

  • "Skip useless results" function is used

    In order not to garble the table and chart with testing results, the possibility to skip very bad results is used. This function can be enabled in context menu of "Optimization Results" -> "Skip useless results" tab.

Translated from Russian by MetaQuotes Ltd.
Original article: https://www.mql5.com/ru/articles/1512

Last comments | Go to discussion (4)
William Roeder
William Roeder | 16 Nov 2012 at 13:48
Zero bar of another timeframe for the same symbol under test is modeled approximately
Open = correct Open, Close = correct Close, Low = min (Open,Close), High = max (Open,Close), Volume = final Volume (false)
Is no longer correct, per Tester in the Terminal MetaTrader 4: It Should Be Known - MQL4 Articles and in EA testing
[Deleted] | 4 Mar 2014 at 21:42

With Build 610 my strategy tester does not do any trade any more.

The EA is approved from Build 5xx and working in live accounts. New directory structure is understood. Many EAs and FX pairs were tried.

The strategy tester worked well before Build 610, now it says -Expert loaded, -Spread set, -Parameters set but NO trade is done during simulation. I can not get any output, even print statements fail.

I am helpless searching since 1 week, who can help?

Thanks, RoMe

Thomas Woody
Thomas Woody | 19 Dec 2018 at 01:41
This article was helpful.  I've been pulling my hair out trying to figure out why my scalper EA won't place a trade in strategy tester.  It is because my code relies on "sleep" command.
Paweł Wilski
Paweł Wilski | 11 Aug 2024 at 06:39

The article provides a solid overview of the features and limitations of the Strategy Tester in MetaTrader 4, which is particularly valuable for those who are new to developing and testing strategies on this platform. It thoroughly explains which aspects are modeled during the testing process, helping users to better understand the potential outcomes in real trading conditions. This article serves as a strong foundation for building more advanced trading algorithms.

However, it's important to note that this article was written in 2005, and now we are in 2024. Over these nearly two decades, MetaTrader 4 has undergone numerous updates, and the forex market has also evolved significantly. Today, we have access to more advanced tools and features, both in MetaTrader 4 and its newer versions, such as MetaTrader 5.

A question that comes to mind is: do the functions described in the article still apply to the current versions of MetaTrader 4, or have there been new developments or limitations that should be mentioned? I would be interested to hear current opinions on the effectiveness of the Strategy Tester in today’s market environment.

What the Numbers in the Expert Testing Report Mean What the Numbers in the Expert Testing Report Mean
Article explains how to read testing reports and to interpret the obtained results properly.
Strategy Tester: Modes of Modeling during Testing Strategy Tester: Modes of Modeling during Testing
Many programs of technical analysis allow to test trading strategies on history data. In the most cases, the testing is conducted on already completed data without any attempts to model the trends within a price bar. It was made quickly, but not precisely
Expert Advisor Sample Expert Advisor Sample
The principles of MQL4-programs development are shown on sample of creating a simple Expert Advisor system based on the standard MACD indicator.
Features of Custom Indicators Creation Features of Custom Indicators Creation
Creation of Custom Indicators in the MetaTrader trading system has a number of features.