---
title: "Reverse Engineering of Strategy - Examples - MCP and AI - MetaTrader 5帮助"
description: "Entry-rule discovery: Exit-rule discovery: Strategy reconstruction: Prototype EA: Best and worst conditions: Inverse policy... - Reverse Engineering of Strategy - Examples - MCP and AI"
image: "https://www.metatrader5.com/i/logo_metatrader5.png"
url: "https://www.metatrader5.com/zh/terminal/help/practical_examples/strategy_reverse_engineering"
---

[MetaTrader 5帮助](https://www.metatrader5.com/zh/terminal/help) → [MCP and AI](https://www.metatrader5.com/zh/terminal/help/mcp_and_ai) → [Examples](https://www.metatrader5.com/zh/terminal/help/mcp_and_ai/practical_examples) → Reverse Engineering of Strategy

# Reverse Engineering of Strategy 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.

Entry-rule discovery:

Use positions from the last six months and H1 market data before entry. Compare trend, momentum, volatility, recent returns, swing-level distance, structure, session, and trade direction with non-entry periods. Identify the smallest recurring set of conditions that explains entries.

Exit-rule discovery:

Use positions from the last six months and M15 data from entry to exit. Compare exits with stops, targets, structure, volatility, session boundaries, time in trade, MAE, and MFE. Identify likely stop, target, trailing, time, or reversal rules and label unexplained exits.

Strategy reconstruction:

Use my last six months of trade history to group recurring strategies by entries, exits, stop placement, sizing, timeframes, sessions, trend, volatility, and prior outcomes. State each rule, its statistics, and confidence level.

Prototype EA:

Use my last six months of trades to define the strongest high-confidence strategy, including entry, exit, stop, target, sizing, session, symbol, and regime rules. Create and compile a prototype MQL5 EA, then run a six-month backtest and compare it with my history.

Best and worst conditions:

Using my last six months of history, show where my strategy performs best and worst by symbol, timeframe, session, volatility, trend strength, and trade direction.

Inverse policy inference:

Using the latest 100 buy, sell, hold, resize, and close decisions recorded for PortfolioGuard.ex5 with magic number 74110, fit one multinomial logistic policy from unrealized profit, drawdown, turnover, holding time, and inventory. Report the direction of each inferred preference and the five largest cases where the policy predicts a different action.

Bayesian rule comparison:

Using the latest 80 entries and 80 matched non-entry periods from BlackBoxAlpha.ex5 with magic number 81235, compare five fixed hypotheses for its unknown logic: threshold, crossover, breakout, reversion, and time-based entry. Fit exactly two parameters per hypothesis, rank them with Bayesian Information Criterion, and report when the top two are practically indistinguishable.

Minimum-description strategy:

Using the latest 100 actions from BlackBoxAlpha.ex5, search rule trees no deeper than three levels with five candidate conditions: RSI(14), the EMA(20)-EMA(50) gap, distance from the 20-bar high, ATR(14), and server hour. Rank the best 50 candidate trees by Minimum Description Length and expose rules whose added condition explains fewer than five actions.

Hidden semi-Markov modes:

Fit one hidden semi-Markov model with exactly four latent modes to the latest 150 actions from PortfolioGuard.ex5 with magic number 74110, limiting state duration to 20 actions. Label the modes from their observed action distributions and identify the two observable variables most associated with transitions.

Counterfactual action boundaries:

For the latest 50 actions from PortfolioGuard.ex5 with magic number 74110, perturb only price distance, unrealized profit, and holding time by plus and minus 10% while keeping other values fixed. Use the previously fitted action model to identify which perturbations change the predicted decision and estimate one approximate boundary per variable.

Sequence-aligned prototypes:

For the latest 60 EURUSD H1 trades from BlackBoxAlpha.ex5 with magic number 81235, take the 20 bars before entry and use dynamic time warping on normalized price and volume only. Cluster the sequences into four prototypes, reserve the latest 12 trades for testing, and compare prototype classification with one fixed-window return baseline.

Order-state automaton:

Convert the latest 200 order and deal records from BlackBoxAlpha.ex5 with magic number 81235 into six fixed states: flat, pending, long, short, partially closed, and closed. Infer the smallest deterministic transition table that reproduces them and list the five most frequent ambiguous or exceptional transitions suggesting a hidden condition or manual action.

Ordinal grammar induction:

For 40 entries, 40 exits, and 40 matched no-action windows from BlackBoxAlpha.ex5 on EURUSD H1, encode only the preceding five candles as up, down, inside, or outside bars. Retain the 10 most frequent two- and three-symbol sequences and compare their frequencies across the three action classes.

Parameter-drift timeline:

Divide the latest 120 trades from BlackBoxAlpha.ex5 with magic number 81235 into four consecutive blocks of 30. In each block, estimate only the median entry distance, stop distance, and position size, then apply a simple mean-shift check to these 12 estimates and mark likely parameter changes between blocks.

Executable conformance experiment:

Instrument the 10 entry and exit branches in a copy of BlackBoxAlpha.mq5 with trace labels, compile it, and run the BlackBoxAlpha_EURUSD_H1 tester configuration for the latest month. Align the trace labels with actual orders #72980110 through #72980129 and report which branches explain them and which orders still require another source or manual actor.

## In this section

- [Quick Analysis for Market Entry](https://www.metatrader5.com/zh/terminal/help/practical_examples/market_entry_analysis)
- [Risk Management Operations](https://www.metatrader5.com/zh/terminal/help/practical_examples/risk_management_operations)
- [Account and Behavioral Analysis](https://www.metatrader5.com/zh/terminal/help/practical_examples/account_behavioral_analysis)
- [Quick Workspace Preparation](https://www.metatrader5.com/zh/terminal/help/practical_examples/workspace_preparation)
- [Backtesting and Optimization](https://www.metatrader5.com/zh/terminal/help/practical_examples/backtesting_optimization)
- Reverse Engineering of Strategy
- [Strategy Discovery and New Edge Research](https://www.metatrader5.com/zh/terminal/help/practical_examples/strategy_discovery)
- [Scenario Planning and What-If Analysis](https://www.metatrader5.com/zh/terminal/help/practical_examples/scenario_planning)

```json
{"@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [ {"@type": "ListItem", "position": 1, "item": {"@id": "https://www.metatrader5.com/zh/terminal/help", "name": "MetaTrader 5帮助"}}, {"@type": "ListItem", "position": 2, "item": {"@id": "https://www.metatrader5.com/zh/terminal/help/mcp_and_ai", "name": "MCP and AI"}}, {"@type": "ListItem", "position": 3, "item": {"@id": "https://www.metatrader5.com/zh/terminal/help/mcp_and_ai/practical_examples", "name": "Examples"}}, {"@type": "ListItem", "position": 4, "item": {"@id": "https://www.metatrader5.com/zh/terminal/help/practical_examples/strategy_reverse_engineering", "name": "Reverse Engineering of Strategy"}} ]}
{ "@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{ "@type": "Question", "name": "MetaTrader 5: Reverse Engineering of Strategy", "acceptedAnswer": { "@type": "Answer", "text": "Entry-rule discovery: Exit-rule discovery: Strategy reconstruction: Prototype EA: Best and worst conditions: Inverse policy inference: Bayesian..." } }] }
```
