MetaTrader 5 (MT5) Quantitative Trading Documentation
website·Indexed 30 days ago
https://www.mt5.me/team-doc/A comprehensive resource for quantitative trading using MetaTrader 5, featuring MQL5 programming fundamentals, object-oriented programming, and Expert Advisor (EA) development. The documentation includes detailed backtest reports for various strategies—such as trend-following, Martingale, and price action—across currency pairs (EURUSD, GBPJPY) and futures contracts, as well as guides on Walk-Forward Analysis (WFA) and risk control mechanisms.
What's inside MT5
- The Small Swing Quantitative Trading Strategy focuses on medium-to-short-term trend fluctuations, aiming to capture inflection points (buying at callback lows and selling at rebound highs) without trading against the primary trend. The typical holding period ranges from a few days to several weeks, targeting per-swing returns of 5% to 20%. The strategy is designed to be more stable than high-frequency trading and less risky than long-term investing by avoiding trend reversals.
Overview of JavaScript's language influences
JavaScript's design is a hybrid of functional and object-oriented programming, drawing from several other languages:
- Basic Syntax: C and Java
- Data Types/Structures: Java (distinction between primitive values and objects)
- Functions: Scheme and Awk (functions as first-class citizens, introduction of closures)
- Prototype-based Inheritance: Self (a Smalltalk variant)
- Regular Expressions: Perl
- String and Array Handling: Python
Overview of Market Depth (Order Book) in MQL5
Market Depth is an array of records containing volume information for buy and sell orders around the current market price. Unlike standard quotes (Bid/Ask), the order book provides volume at multiple price levels. The maximum size of the order book (number of price levels) is defined by the
SYMBOL_TICKS_BOOKDEPTHsymbol property.Key characteristics:
- Market depth changes more frequently than quotes because it includes changes in limit orders, not just executed trades.
- Data is broadcast online and is not stored in the terminal's history; therefore, it is not available in the Strategy Tester unless the developer collects and reads historical depth data from a custom source.
- Market depth is typically available for exchange-traded symbols, though some brokers may provide it for OTC symbols.
Overview of MetaGPT Memory Module Architecture
MetaGPT implements a memory mechanism to manage dialogue history and knowledge across multiple collaborating Agents, overcoming LLM context length limitations. The memory module is organized within thememoryfolder and consists of several key components: base memory classes, long-term memory, memory storage repositories, and the 'memory brain'.Overview of the Trend Breakout Dynamic Trailing Stop Strategy
This quantitative trading strategy is designed for markets with clear trends (e.g., futures or stocks in major waves). It avoids small profits in sideways markets and focuses on capturing medium-to-long-term trend gains. The core logic consists of: using moving averages to determine direction, confirming breakouts with multiple conditions, and employing dynamic stops to protect profits while allowing winning trades to run.Overview of Sass
Sass (Syntactically Awesome Stylesheets) is a professional-grade CSS extension language designed to simplify CSS workflows and improve maintainability. It introduces programming features to CSS, such as custom variables, if-statements, and nesting.Overview of SQLite integration in MetaEditor
MetaEditor integrates the SQLite engine, allowing developers to manage databases stored as single files on the local PC. This is primarily used in algorithmic trading for analyzing trade history, saving optimization/test results, exchanging data with other analysis suites, and storing MQL5 program states.Overview of the Three-Horse (三马) Trading Strategy
The Three-Horse strategy is a multi-strategy fusion all-weather trading system that diversifies risk across different market styles (trend, reversal, value, and growth). It consists of four core sub-strategies with the following capital allocations:
- Small Cap Strategy: 35%
- ETF Rebound Strategy: 10%
- ETF Rotation Strategy: 35%
- Blue-Chip Offense/Defense Strategy: 20%
Overview of MetaEditor for Algorithmic Trading
MetaEditor is an integrated development environment (IDE) built into the MetaTrader platform. It is used to develop algorithmic trading programs using the MQL4 and MQL5 languages. Supported program types include:
- Trading robots (Expert Advisors)
- Technical indicators
- Scripts
- Graphical control panels
Overview of MQL5 Graphical Objects
MQL5 allows developers to programmatically create, edit, and delete graphical objects (e.g., trend lines, labels, buttons) on MetaTrader 5 charts. These objects are useful for displaying data in sub-windows, creating semi-automatic trading markers, or building custom graphical user interfaces (GUIs).
Key architectural constraints:
- Chart Context: Every object exists within a specific chart; functions managing objects always require a chart ID as the first parameter.
- Unique Naming: Each object must have a unique name within a chart (including all sub-windows). Renaming an object is equivalent to deleting the old one and creating a new one.
- Asynchronous Updates: Functions like
ObjectCreateandObjectMovesend asynchronous commands to the chart's event queue. Visual changes may have a slight delay. - Redrawing: To force a visual update after creating or modifying many objects, use the
ChartRedraw()function.
Introduction to MetaEditor Quantitative Trading Tools
MetaEditor provides a high-performance financial quantitative trading environment driven by native C/C++ for fast backtesting and strategy execution. It supports a wide range of financial products including stocks, futures, forex, cryptocurrencies, and bonds. Key features include 360-degree strategy validation (Net Value, Profit/Loss Ratio, Win Rate, Maximum Drawdown, and Sharpe Ratio) and support for multi-condition resonance across different timeframes, symbols, and indicators.Overview of MQL5 Built-in Data Types
MQL5 provides a set of built-in data types to handle different kinds of information efficiently. These include numeric types (integers and floating-point), character types, strings, boolean logic, and specialized types for time and color. The choice of type affects memory usage and processing speed; for example, integers are generally processed faster than floating-point numbers.