agentleFS
kecoma1kecoma1/MQL5-SKILLS/skills/optimize/SKILL.md

optimization

Skill17 starsChanged 7 months agoMITView on GitHub

Run MetaTrader 5 parameter optimizations in this workspace and summarize real results from exported optimization reports. Use when Codex needs to optimize EA inputs such as SL, TP, RSI values, or other inputs for experts under MQL5\Experts, by generating a tester .ini with [TesterInputs], launching MT5 from the terminal, and reading the resulting XML ranking.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

23 rules. 0 are common, 13 are distinctive, and 10 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 13

    Distinctive

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill for MT5 strategy optimizations in this workspace.

    line 10
  2. Distinctive:

    Ask for these fields in this order unless the user has already specified them clearly:

    line 17
  3. Distinctive:

    Ask which input parameters will be optimized and the exact ranges.

    line 28
  4. Very specific:

    Create or update a tester .ini under MQL5\config\.

    line 29
  5. Very specific:

    Put the optimization ranges inside a [TesterInputs] section in that .ini.

    line 30
  6. Very specific:

    Create MQL5\backtest\reports\ if missing.

    line 31
  7. Distinctive:

    If MT5 is already running, close it before launch.

    line 32
  8. Distinctive:

    Read terminal and tester logs to confirm the optimization really started and finished.

    line 34
  9. Distinctive:

    Read the exported optimization XML and summarize the best passes.

    line 35
  10. Very specific:

    Do not rely on ExpertParameters=...set for optimization ranges here.

    line 41
  11. Distinctive:

    Use MT5 optimization format:

    line 85
  12. Very specific:

    Use Y only for parameters being optimized.

    line 92
  13. Very specific:

    Use N for fixed parameters.

    line 93
  14. Distinctive:

    Keep the current value equal to the chosen start value unless there is a reason not to.

    line 94
  15. Very specific:

    Write Expert= relative to MQL5\Experts\.

    line 106
  16. Very specific:

    Write the tester .ini under MQL5\config\.

    line 107
  17. Distinctive:

    Use this command pattern:

    line 113
  18. Distinctive:

    Before launching, close any existing MT5 process.

    line 119
  19. Distinctive:

    Read these logs after launch:

    line 123
  20. Distinctive:

    Treat these tester log lines as authoritative:

    line 128
  21. Very specific:

    If the optimization did not start, inspect the .ini and especially [TesterInputs] before retrying.

    line 134
  22. Distinctive:

    Read that XML and extract at least:

    line 140
  23. Very specific:

    All optimized input columns, such as InpStopLossPoints and InpTakeProfitPoints

    line 147

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Optimization

Overview

Use this skill for MT5 strategy optimizations in this workspace.

Confirm the optimization setup, write a tester .ini under MQL5\config\, place the parameter ranges in [TesterInputs], close any running MT5 instance, launch terminal64.exe with /config:..., and summarize the actual ranking from the exported XML report.

Required workflow

  1. Confirm the test configuration before launching.
  2. Ask for these fields in this order unless the user has already specified them clearly:
    • Expert or strategy file
    • Symbol
    • Timeframe
    • Date range
    • Deposit
    • Deposit currency
    • Leverage
    • Tick model
    • Optimization on or off
    • Visualization on or off
  3. Ask which input parameters will be optimized and the exact ranges.
  4. Create or update a tester .ini under MQL5\config\.
  5. Put the optimization ranges inside a [TesterInputs] section in that .ini.
  6. Create MQL5\backtest\reports\ if missing.
  7. If MT5 is already running, close it before launch.
  8. Launch MT5 with the generated .ini.
  9. Read terminal and tester logs to confirm the optimization really started and finished.
  10. Read the exported optimization XML and summarize the best passes.

Critical local rule

In this workspace, command-line optimization works when the parameter ranges are defined in [TesterInputs] inside the tester .ini.

Do not rely on ExpertParameters=...set for optimization ranges here. That produced the tester error: no optimized parameter selected, please check input(s) to be optimized and set start, step and stop values

Tester ini pattern

Use this structure:

[Tester]
Expert=codex\RSICrossTrader.ex5
Symbol=GBPUSD
Period=M15
Model=4
Optimization=1
FromDate=2026.02.28
ToDate=2026.03.28
ForwardMode=0
Deposit=100000
Currency=USD
Leverage=1:100
ExecutionMode=0
OptimizationCriterion=0
Visual=0
Report=MQL5\backtest\reports\report_name
ReplaceReport=1
ShutdownTerminal=1
UseLocal=1
UseRemote=0
UseCloud=0

[TesterInputs]
InpRSIPeriod=4||4||1||4||N
InpRSIPrice=1||1||0||7||N
InpBuyLevel=30.0||30.0||3.000000||300.000000||N
InpSellLevel=70.0||70.0||7.000000||700.000000||N
InpLots=0.01||0.01||0.001000||0.100000||N
InpStopLossPoints=100||100||10||120||Y
InpTakeProfitPoints=100||100||10||120||Y
InpMagicNumber=20260328||20260328||1||202603280||N
InpOnePositionPerSymbol=true||false||0||true||N

Input range format

Use MT5 optimization format:

ParameterName=current||start||step||stop||selected

Rules:

  • Use Y only for parameters being optimized.
  • Use N for fixed parameters.
  • Keep the current value equal to the chosen start value unless there is a reason not to.
  • Preserve the parameter names exactly as declared in the EA inputs.

Example:

InpStopLossPoints=100||100||10||120||Y
InpTakeProfitPoints=100||100||10||120||Y

Path rules

  • Write Expert= relative to MQL5\Experts\. Use codex\RSICrossTrader.ex5, not Experts\codex\RSICrossTrader.ex5.
  • Write the tester .ini under MQL5\config\.
  • Export reports to MQL5\backtest\reports\report_name.
  • Optimization exports a readable XML workbook. Use that XML as the primary source.

Launch command

Use this command pattern:

Start-Process -FilePath 'C:\Program Files\MetaTrader 5\terminal64.exe' -ArgumentList '/config:C:\Users\<user-id>\AppData\Roaming\MetaQuotes\Terminal\<terminal-id>\MQL5\config\your-optimization.ini' -Wait

Before launching, close any existing MT5 process. Otherwise the tester may not run.

Validation

Read these logs after launch:

  • Terminal\...\logs\YYYYMMDD.log
  • Terminal\...\tester\logs\YYYYMMDD.log

Treat these tester log lines as authoritative:

  • Start confirmed: complete optimization started
  • Success confirmed: optimization finished, total passes N
  • Broken config: no optimized parameter selected

If the optimization did not start, inspect the .ini and especially [TesterInputs] before retrying.

Reading the report

Optimization results are exported as an XML workbook under MQL5\backtest\reports\.

Read that XML and extract at least:

  • Pass
  • Result
  • Profit
  • Profit Factor
  • Equity DD %
  • Trades
  • All optimized input columns, such as InpStopLossPoints and InpTakeProfitPoints

Summarize:

  • The best combination
  • The top ranking passes
  • The report path used
  • Whether the optimization finished successfully

Example from this workspace

This exact optimization was validated successfully:

  • Expert: codex\RSICrossTrader.ex5
  • Symbol: GBPUSD
  • Period: M15
  • Dates: 2026.02.28 to 2026.03.28
  • Model: real ticks (Model=4)
  • Optimization: on
  • Visual: off
  • Optimized params:
    • InpStopLossPoints=100||100||10||120||Y
    • InpTakeProfitPoints=100||100||10||120||Y

It completed with 9 passes and produced: MQL5\backtest\reports\codex_rsicrosstrader_gbpusd_lastmonth_opt_sltp_100_120.xml

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.