Tester script for extending the standard MetaTrader 5 optimization functionality - script for MetaTrader 5
This code is a custom optimization function for the MetaTrader 5 strategy tester. It is not an Expert Advisor, indicator or script in the traditional sense, but a special script used to analyze test results.
Get transaction history from tester
Check minimum requirements (minimum 50 transactions)
Determine initial deposit and time period
Divide the transaction into two periods:
In-sample (IS) - first 70% of the test period
Out of sample (OOS) - last 30% of the period, 1 day apart
Calculate a set of indicators for two periods:
Profitability and drawdowns
Sharpe ratio and Sortino ratio
Profit Factor and Probability of Profitable Trades
Statistical indicators (skewness, kurtosis)
Special indicators (quietness ratio)
Compare IS and OOS distributions using the Kolmogorov-Smirnov test
Check the normality of the distribution using the Jarque-Bera test
Create a comprehensive strategic assessment that takes into account:
Profitability (30%)
Consistency of results (30%)
Risk-adjusted performance (25%)
Statistical quality (15%)
Place the code in the MQL5/Scripts/ folder.
In the strategy tester, select "Custom optimization criteria"
Use this script to evaluate optimization results
Used to verify the stability of the strategy
Analyze the differences between IS and OOS periods
Identify over-optimized strategies
Objectively compare different strategies
Rank strategies based on comprehensive criteria
Minimize over-optimization with data partitioning
Comprehensive evaluation considers multiple aspects of performance
Statistical verification of the robustness of the results
Automatically filter out unfeasible strategies
Requires a large number of transactions (at least 50)
It takes enough historical period to split into IS/OOS
For policies that fail the minimum requirements, the code returns -DBL_MAX
This approach is particularly useful for traders and developers who want to carefully test and optimize trading strategies, minimizing the risk of fitting historical data.
Show different methods of Aron value calculation
This MQL5 indicator identifies upward (bullish) and downward (bearish) Pinbars and displays them with customizable arrows (gray for upwards, red for downwards). It allows fine-tuning of detection parameters such as tail body proportion and protrusion. Pop-up and push notification alerts signal new pinbars. Ideal for traders looking for precise reversal pattern detection.
Balance of Power (BOP) is an indicator originally developed by Igor Livshin in 2001 that measures the balance of power between buyers and sellers during each candle.
PriceVar% is an indicator designed to measure the percentage difference between price and a moving average, highlighting the strength of market movements relative to a reference value.
Attachment download
📎 World-Class_Parameter_Validation_Function.mq5 (13.54 KB)
Source: MQL5 #63121
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •