Optimisation Friendly Input Template
The genetic optimiser treats every plain `input` as a dimension of its search space. An EA written with fifteen loose inputs - retry counts, magic numbers, slippage tolerance mixed in alongside the actual strategy parameters - hands the optimiser a search space many times larger than the strategy needs, and generations get spent exploring combinations of settings that were never meant to vary between runs. This template fixes that structurally rather than by convention: the genuinely optimisable parameters (moving average lengths, stop and target distance) are declared with `input`, and everything that must stay constant across every run in a batch (lot size, magic number, slippage, retry policy) is declared with `sinput`, which MT4's optimiser never includes in its parameter grid at all. The distinction is enforced by the compiler, not just documented in a comment. It also implements OnTester(), returning net return divided by the run's own maximum drawdown rather than raw profit. Ranking optimisation results by profit alone rewards the single highest-variance lucky run in the batch - exactly the mechanism by which a genetic optimisation quietly curve-fits itself onto a parameter set that dies in its first real drawdown. A trading signal (a plain EMA cross) is included so the template compiles into something that actually runs end to end in the tester rather than being an empty shell with nothing to optimise. Notes and limitations The bundled EMA cross signal is a working placeholder, not a strategy worth optimising on its own merits - replace it before drawing conclusions from an optimisation run. The custom criterion falls back to plain net return when a run records negligible drawdown, since dividing by a near-zero drawdown would produce a meaningless, unbounded score.
Expert advisor · MT5 · v1.0 · Free
About Optimisation Friendly Input Template
Optimisation Friendly Input Template is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average. It has 9 settings, such as Fast ma period, Slow ma period and Stop loss pips. MQL source code included.
Files in the download: OptimisationTemplate.ex5, OptimisationTemplate.mq5, OptimisationTemplate.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Fast ma period | 10 | Fast EMA period - a real optimisation candidate |
| Slow ma period | 30 | Slow EMA period - a real optimisation candidate |
| Stop loss pips | 30 | Stop loss, in pips - a real optimisation candidate |
| Take profit pips | 45 | Take profit, in pips - a real optimisation candidate |
| Lots | 0.01 | Fixed lot size - constant across every optimisation run |
| Magic number | 20261209 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per order action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Moving Average · MT5 Expert Advisor · MQL5 Source Code