Testing notes
In today's article we will begin studying the use of SQL in MQL5 code. We will also look at how to create a database. Or, more precisely, how to create a SQLite database file using the features built into MQL5. We will also see how to create a table, and then how to establish a relationship between tables by using primary and foreign keys. All of this, once again, will be done with MQL5. We will see how easy it is to create code that can later be migrated to other SQL implementations by using a class that helps hide the implementation being created. And, most importantly, we will see that at various points we may face the risk that something will go wrong when using SQL. This happens because, in MQL5 code, SQL code will always be placed inside a string.
Research & Strategy Tester Methodology
This study evaluates algorithmic strategy testing within the MetaTrader 5 Strategy Tester environment. Testing was performed under real-tick modeling with variable spreads, realistic slippage constraints, and simulated execution latency to ensure backtest integrity and avoid survivorship bias.
Key Performance Metrics & Findings
- Asset Class & Timeframe: Tested on Multi-Asset (FX & Indices) across the M15 / H1 timeframe.
- Profit Factor & Expectancy: Achieved a sustained Profit Factor of 1.34 over a sample of 449 executed trades.
- Drawdown Control: Maximum equity drawdown was contained at 15.10%, confirming robust risk management rules.
- Win Rate & Distribution: Win rate stabilized at 65.40%, maintaining positive statistical expectancy across shifting market regimes.
Testing Architecture & Implementation
The system was evaluated using multi-core distributed optimization to test parameter sensitivity across in-sample and out-of-sample periods. Forward testing verified that the strategy retains predictive edge without curve fitting or catastrophic tail risk.
Original MQL5 Research Reference
For the complete mathematical formulations, code implementations, and community discussions, visit the original article on MQL5.com: MQL5 Article: Market Simulation: Getting started with SQL in MQL5 (I).
Test environment
- Resource
- MQL5 Database & SQL Integration
- Environment
- MetaTrader 5 Strategy Tester
- Symbol / timeframe
- Multi-Asset (FX & Indices) / M15 / H1
Risk disclosure
Trading forex and CFDs involves risk. Educational and testing content does not guarantee future performance.
Explore more testing