MetaEditor 帮助 → MCP and AI → Examples → Using Self-Improvement Loops for Algorithms

Using Self-Improvement Loops for Algorithms with AI

Adapt file names, symbols, periods, risk limits, and requirements to your project or preferences. Preserve an unchanged baseline and test the algorithm in a demo environment before live use.
 
You are solely responsible for AI-generated content, AI-assisted actions, trading decisions, trading results, and any resulting losses.

Backtest-report-revise loop:

Create a one month Strategy Tester configuration file in ini format with fixed inputs, run the baseline, read its report, and summarize profit factor, drawdown, win rate, balance, trade count, and a defined Sharpe like metric. Make one evidence-supported code or input change, rerun the identical test once, compare reports, equity curves, and trade lists, and keep it only if the predeclared acceptance criteria pass.

Guarded autonomous parameter optimization:

Generate a native parameter file in set format for at most four justified inputs and run a three-month H1 Open-prices training optimization capped at 64 passes. Select a stable region by profit factor, drawdown, trade count, and Sharpe, not the best isolated pass. Test at most six single-change period, stop, target, or cost perturbations, then test the frozen choice on one untouched month.

MQL5-Python research loop:

Build an MQL5-Python round trip using 100 rows of versioned trade and equity data. Have Python validate, plot, calculate Sharpe and volatility, and return one approved parameter set. Require MQL5 to reject stale, partial, malformed, or mismatched files.

Adversarial falsification loop:

Red team this strategy over a three-month development period. Run only the two cheapest tests against the strongest explanations among leakage, common-factor exposure, period dependence, cost-fragility, parameter luck, and profit concentration. Stop when the hypothesis fails.

Champion-challenger loop:

Keep the current strategy as champion and test two one-change challengers on the same three-month development period. Reject risk or complexity violations, promote only a materially stable winner, and compare champion and winner once on one untouched month.

Negative-control discovery loop:

For one proposed signal-improvement, use the latest 100 trades to run four controls. Delayed signal, block-shuffle, unrelated-symbol feature, and matched noise. Reject the improvement unless it separates from all four on the same chronological validation slice.

Complexity-budget loop:

Create two candidates under this budget. At most two new inputs, one state variable, and one data dependency each. Compare them on one two-month development and two-week validation period by stability, turnover, performance, and complexity. Prefer the simpler near-tie.

Uncertainty-calibration loop:

Using a completed historical sequence of 80 forecasts, use the first 60 for calibration and the final 20 for validation. Monitor conformal coverage by regime, compare only three responses to undercoverage, wider intervals, half risk, or no entry, and never retrain on the validation segment.

Counterfactual trade-review loop:

For the latest 50 trades, replay five counterfactuals. No trade, one-bar-delayed entry, fixed exit, no filter, and constant risk. Attribute results to selection, timing, exit, sizing, or market drift, then nominate only one-component for the next experiment.

Demo drift-and-rollback loop:

Compare the latest two demo weeks with a one-month backtest-baseline for feature distributions, calibration, signal frequency, spread, slippage, rejection, and drawdown. If one predeclared limit fails, pause entries and prepare one diagnosis and rollback proposal without deploying a revision.

Test-driven correction loop:

Run the deterministic tests, group failures into at most three root-causes, and make one coherent correction at a time. Stop after two failed corrections to the same cause and preserve a concise change log.

Regression-guarded refactor loop:

Record a one-month baseline report and trade list, refactor one module, and rerun the identical test. Accept only exact trade and metric equivalence. Otherwise revert the iteration and explain the first difference.

Bounded strategy-development loop:

Implement this predeclared hypothesis through at most two one-component revisions on a two-month training period. Select by a two-week validation period and simplicity, then use the final untouched two weeks once. Record rationale, diff, inputs, costs, and every result. Paste hypothesis.

Walk-forward adaptation loop:

Run three walk-forward folds, each with four weeks of training, at most four fixed parameter sets, and one week of testing. Freeze each selection before its test week, aggregate only the three out-of-sample weeks, and compare with one fixed-parameter baseline.

Robustness-gated parameter loop:

On a completed three-month EURUSD H1 Open-prices window, search at most 36 coarse parameter combinations on the first two months. Reject low-trade, high-drawdown, profit-concentrated, or isolated candidates. Perturb the three survivors once and retest them with higher costs on the final month. Choose the simplest stable region.

Failure-driven debugging loop:

Reproduce the failure on the shortest range containing it, rank three causes, add only distinguishing traces, and run once. Fix only the supported cause, add one regression case, and remove temporary instrumentation.

Performance-tuning loop:

Profile three identical runs, optimize the single largest bottleneck, verify numeric and trade equivalence, and profile three times again. Stop if the gain is below 5 percent or the leading cost is external.

Controlled paper-trading review loop:

Using the latest 20 demo trades, compare signals, requests, fills, costs, and latency with matching backtest events. Report deviations, nominate one research change, and require a new sealed validation before any deployment.