---
title: "Backtesting and Optimization - Examples - MCP and AI - MetaTrader 5 Hilfe"
description: "External exit overlay: Cross-symbol backtest: Loss conditions: Latency sensitivity: Testing-mode comparison: Capital... - Backtesting and Optimization - Examples - MCP and AI"
image: "https://www.metatrader5.com/i/logo_metatrader5.png"
url: "https://www.metatrader5.com/de/terminal/help/practical_examples/backtesting_optimization"
---

[MetaTrader 5 Hilfe](https://www.metatrader5.com/de/terminal/help) → [MCP and AI](https://www.metatrader5.com/de/terminal/help/mcp_and_ai) → [Examples](https://www.metatrader5.com/de/terminal/help/mcp_and_ai/practical_examples) → Backtesting and Optimization

# Backtesting and Optimization Using AI with MetaTrader

> Adapt the symbols, periods, position sizes, risk limits, and any criteria to your approach or preferences. Carefully study every prompt before using it and review any proposed action before executing it.
>
> You are solely responsible for AI-generated content, AI-assisted actions, trading decisions, trading results, and any resulting losses.

External exit overlay:

Run a six-month backtest of this EA, then review its losing trades. Compare the original exits with simple protective exits based on price, time, or volatility, without modifying the EA, and report the effect on loss and drawdown.

Cross-symbol backtest:

Run six-month H1 backtests of this EA on USDJPY, EURUSD, GBPUSD, and XAUUSD with 1 lot. Compare trade count, profit, drawdown, win rate, and the conditions in which results differ.

Loss conditions:

Run a six-month backtest of this EA and review losing trades with H1 data from the hour before entry. Compare trend, volatility, structure, and session conditions to identify recurring situations in which the EA should not run.

Latency sensitivity:

Run six-month backtests of this EA with 0 ms, 100 ms, 250 ms, and 500 ms execution delay. Compare fills, trade count, profit, drawdown, and missed or changed opportunities to assess latency sensitivity.

Testing-mode comparison:

Run a six-month backtest of this EA with real ticks, generated ticks, M1 OHLC, and open prices where supported. Compare trade sequences and results, identify where they diverge, and state which faster modes remain reliable.

Capital requirements:

Run six-month backtests of this EA with my intended leverage and three progressively smaller initial deposits. Identify where margin constraints change trade execution or make drawdowns operationally uncomfortable.

Challenge-rule compliance:

Run a six-month backtest using my current balance. Compare the equity curve with my maximum daily loss, total drawdown, and capital limits, and identify every breach.

EA preset library:

Find this EA's parameter-set files, identify duplicates, and organize the remaining files by symbol, risk level, and purpose.

Forward-test split comparison:

For LondonBreakout_v4 presets LB4_01.set through LB4_06.set on EURUSD H1, compare six-month tests using 1/2, 1/3, and 1/4 forward-test splits. Identify which split produces parameters that survive the forward section most reliably.

Robust parameter sets:

Test LondonBreakout_v4 presets LB4_01.set through LB4_06.set on EURUSD H1 over the latest six months. Exclude any preset with drawdown above 12%, fewer than 40 trades, recovery factor below 1.5, or profit factor below 1.2.

Reusable tester configurations:

Create tester configurations for a quick test, real-tick validation, six-month test, forward test, high-cost stress test, and visual inspection. Keep the EA inputs consistent and change only the tester assumptions for each configuration.

EA-loss investigation:

For losing deal #4087 in the XAUUSD GoldMeanReverter GMR_04.set tester report, retrieve M15 and H1 data from the two hours before entry through exit. Summarize trend, volatility, nearby levels, and price behavior around the loss.

Deflated Sharpe Ratio:

Using the latest tester reports for LondonBreakout_v4 presets LB4_01.set through LB4_12.set over the same six-month EURUSD period, collect their daily returns and identify the selected winner. Compute its Deflated Sharpe Ratio from the 12-trial count, cross-variant dependence, skewness, and kurtosis, and reject it unless the probability of genuine skill exceeds 95%.

Probability of backtest overfitting:

For GoldMeanReverter presets GMR_01.set through GMR_08.set tested on XAUUSD over the same six-month period, divide returns into six equal chronological blocks and evaluate the 20 combinations that use three in-sample blocks. Select the in-sample winner for each split and report its Probability of Backtest Overfitting and median out-of-sample rank.

White's Reality Check:

Use the EURBreakout_01 through EURBreakout_10 tester reports in the LondonBreakout_v4 research folder and their EURUSD returns over the common six-month period. Apply 200 stationary-bootstrap samples for White's Reality Check against the no-trade benchmark and report whether the best rule remains significant after accounting for the 10-variant search.

Purged and embargoed validation:

For LondonBreakout_v4 trades with magic number 41027 over the latest six months, create five chronological validation folds. Purge training observations that overlap each test trade and use an embargo equal to the EA's median holding time, then compare the resulting score with ordinary five-fold validation and quantify leakage inflation.

Adversarial distribution-shift test:

For LondonBreakout_v4 on EURUSD H1, use return, ATR, spread, tick volume, hour, and distance from the 20-bar high to train one logistic classifier that distinguishes its three-month development period from the following one-month deployment period. If cross-validated accuracy exceeds 70%, identify the three most shifted features and recalculate the existing backtest metrics on the development observations most similar to deployment.

Signal-placebo test:

From the three-month EURUSD H1 backtest of LondonBreakout_v4 preset LB4_07.set, preserve holding periods, position sizes, and trade count but randomly relocate entry signals within the same sessions 200 times. Compare the original net result with this placebo distribution to determine whether its timing beats exposure and market drift.

Leakage canary:

On a disposable copy of the three-month EURUSD H1 LondonBreakout_v4 configuration LB4_07.set, add one deliberately impossible feature derived from the next bar and rerun the existing validation once. Confirm that the canary produces conspicuously inflated performance and that the original pipeline contains no access to that future value; inspect only the source files referenced by LondonBreakout_v4.mq5.

Block-bootstrap fragility:

From the latest 200 trades in the six-month XAUUSD H1 GoldMeanReverter backtest GMR_04.set, create 100 samples by resampling contiguous blocks of five trade returns and 100 samples by independently shuffling those returns. Report the two distributions of profit and maximum drawdown and explain the effect of preserving loss clusters.

Ablation and interaction audit:

In LondonBreakout_v4, test the volatility filter, session filter, and trailing-stop module. Create three single-component ablations and one ablation removing both filters, compile them, and run the same three-month EURUSD H1 configuration for these four variants plus the original. Compare net profit and drawdown and flag components that add complexity without consistent value.

Nonlinear capacity stress:

Using the latest 100 deals from the six-month XAUUSD H1 GoldMeanReverter backtest GMR_04.set, reprice them at volume multipliers of 0.5, 1, 2, 3, and 5. Apply one quadratic cost adjustment based on each deal's observed spread percentile and local tick frequency, then report the first multiplier at which marginal profit turns negative.

## In this section

- [Quick Analysis for Market Entry](https://www.metatrader5.com/de/terminal/help/practical_examples/market_entry_analysis)
- [Risk Management Operations](https://www.metatrader5.com/de/terminal/help/practical_examples/risk_management_operations)
- [Account and Behavioral Analysis](https://www.metatrader5.com/de/terminal/help/practical_examples/account_behavioral_analysis)
- [Quick Workspace Preparation](https://www.metatrader5.com/de/terminal/help/practical_examples/workspace_preparation)
- Backtesting and Optimization
- [Reverse Engineering of Strategy](https://www.metatrader5.com/de/terminal/help/practical_examples/strategy_reverse_engineering)
- [Strategy Discovery and New Edge Research](https://www.metatrader5.com/de/terminal/help/practical_examples/strategy_discovery)
- [Scenario Planning and What-If Analysis](https://www.metatrader5.com/de/terminal/help/practical_examples/scenario_planning)

```json
{"@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [ {"@type": "ListItem", "position": 1, "item": {"@id": "https://www.metatrader5.com/de/terminal/help", "name": "MetaTrader 5 Hilfe"}}, {"@type": "ListItem", "position": 2, "item": {"@id": "https://www.metatrader5.com/de/terminal/help/mcp_and_ai", "name": "MCP and AI"}}, {"@type": "ListItem", "position": 3, "item": {"@id": "https://www.metatrader5.com/de/terminal/help/mcp_and_ai/practical_examples", "name": "Examples"}}, {"@type": "ListItem", "position": 4, "item": {"@id": "https://www.metatrader5.com/de/terminal/help/practical_examples/backtesting_optimization", "name": "Backtesting and Optimization"}} ]}
{ "@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{ "@type": "Question", "name": "MetaTrader 5: Backtesting and Optimization", "acceptedAnswer": { "@type": "Answer", "text": "External exit overlay: Cross-symbol backtest: Loss conditions: Latency sensitivity: Testing-mode comparison: Capital requirements: Challenge-rule..." } }] }
```
