Par William Harris · Dernière révision
How to Attach an EA to a Chart in MT5 (with input tuning)
Ce dont vous avez besoin
- • MT5 with the EA already in MQL5\Experts\
- • Vendor preset file (optional but recommended)
- • Trading account with the correct symbol enabled
Instructions étape par étape
Étape 1 : Open the right chart first
Before dragging an EA onto a chart, make sure the chart matches the EA's expected configuration. The two parameters that matter are the symbol (EURUSD, XAUUSD, etc) and the timeframe (M1, M5, H1, etc).
In Market Watch (Ctrl+M), right-click the symbol → 'New Chart' if you don't already have it open. Switch to the timeframe via the toolbar buttons (M1, M5, M15, H1, H4, D1, MN). Most EAs are documented for a single timeframe; running off-timeframe usually still works but produces different signal counts and stop sizes than the vendor's published backtests.
If the EA trades multiple symbols (rare; usually 'multi-pair' EAs use a master chart), the documentation will specify which chart to attach. Default: one EA, one chart, one symbol.
Étape 3 : Configure the Common tab
The Common tab has three sections: Position management, Live trading, and Magic Number override.
Under Position management, leave 'Long & Short' selected unless the vendor specifies otherwise (some grid EAs are direction-restricted). Under Live trading, tick 'Allow live trading' — without this the EA runs in read-only mode and never sends orders. Tick 'Disable auto-trading when the account has been changed' as a safety guard against accidental live execution after switching to a demo account.
'Allow modification of signal settings' is needed for EAs that copy from MQL5 Signals; safe to leave on. The 'Magic Number override' is the most important field for multi-EA setups: it forces a specific Magic regardless of what the EA's internal default is. If you run two copies of the same EA on different symbols, use the override to ensure each copy has a unique Magic.
Étape 4 : Configure the Inputs tab
Switch to the Inputs tab. This shows every configurable parameter the EA exposes, with the EA's compiled-in defaults as starting values.
Click the 'Load' button at the bottom and pick the vendor's .set preset from MQL5\Presets\. The values update across the board. Important: the .set file overrides every parameter it defines and leaves anything new (added in a later version) at default. If you see warnings in the Experts log later like 'Unknown parameter X', the .set is from a different EA version.
Review risk-related inputs even after loading a preset. Lot Size, Risk Percent, Max Drawdown, and Daily Stop Loss should be calibrated to your actual account balance. A preset designed for a $10,000 account on a $1,000 account will trade 10× larger than intended. Adjust before clicking OK.
Étape 5 : Check the Dependencies tab (if it appears)
Some EAs use custom indicators or other resources. If the EA depends on a custom indicator file, the Dependencies tab appears next to Inputs and lists each required resource with its file path.
Green ticks mean MT5 found the resource. Red crosses mean it is missing — copy the indicator .ex5 into MQL5\Indicators\ and refresh the Navigator. The popup needs to be closed and re-opened to re-check dependencies; there is no 'refresh' button on this tab.
If the EA cannot run without a missing dependency, OnInit will fail when you click OK and the chart will show a red sad face with 'EA could not be initialised' in the tooltip. Read the Experts log to confirm which resource was missing.
Étape 6 : Save the chart as a template
Click OK to close the popup. The EA is now attached. Verify the green smiley appears top-right of the chart.
Right-click the chart → Template → Save Template. Give it a name like 'MyEA-default-EURUSD-M5.tpl'. Templates store: chart symbol, timeframe, indicators, EA attachment with all inputs, and visual styling. Loading a template via Template → Load applies everything in one click.
This matters because MT5 sometimes detaches EAs after reconnect or account change. Having a saved template lets you re-attach in seconds rather than redoing the whole configuration. Many traders save one template per EA per account and store them all in the data folder's templates/ sub-directory.
Erreurs courantes à éviter
- ✗ Two EAs with the same Magic Number on different chartsSolution: Use Common tab → Magic override to assign each EA-chart pair a unique integer. Otherwise they read each other's positions.
- ✗ Leaving 'Allow live trading' untickedSolution: Even with global AutoTrading on, per-chart trading off means the EA cannot place orders. Both must be green.
- ✗ Loading a .set from a different EA versionSolution: MT5 silently drops mismatched lines. Always source the .set from the same vendor release as the .ex5.
- ✗ Not saving the chart templateSolution: If MT5 restarts or you switch accounts, the EA may detach. Saved templates restore the entire setup in one click.
Questions fréquemment posées
Can I make my EA load by default when I open a new chart?
Caveat: a default.tpl with an EA attached applies to every chart you open, which includes charts you open for manual analysis. To avoid the EA accidentally attaching to a chart you intended for visual scanning, name the template something specific like 'eurusd-myea.tpl' and apply it manually via right-click → Template → Load.
How should I pick Magic Numbers when running 5+ EAs?
The scheme matters because in OnTrade and OnTradeTransaction handlers, an EA scans every position in the terminal and filters by PositionGetInteger(POSITION_MAGIC). If two EAs accidentally share a Magic, both will think the other's positions are their own and may close them. Document your Magic scheme in a spreadsheet and stick to it across all EAs.
Can I attach an EA without the configuration popup appearing?
The Shift-drag shortcut is undocumented but stable since MT5 build 3000. It does not let you load a .set in the same gesture, so if you need a preset, drop the EA normally on the first chart, configure with the .set, then Shift-drag onto subsequent charts — MT5 remembers the inputs at the EA-name level (not per chart), so the second attach inherits.
How do I remove an EA from a chart?
Closing the chart also removes the EA (after a final OnDeinit call), but leaves the EA in the Navigator. To completely uninstall an EA, remove it from all charts, then close all charts that used it, then delete the .ex5 from MQL5\Experts\. MT5 caches the EA in memory until the terminal restarts, so the file delete may appear to not work until the next launch.
Why are some EA inputs greyed out and uneditable?
There is no way to override a locked input from the MT5 UI. If you need a different value, the vendor must recompile the .ex5 with the input opened up, or expose a separate input that you can edit. As a workaround, some traders use MT5's `OnInit` interception via MQL5 community scripts, but that breaks vendor licensing terms and is not recommended.
Ready to test what you just attached?
Before letting the EA run live, validate the .set against historical data. Five minutes of backtesting catches 90% of configuration errors.
Continue to: How to backtest an EA in MT5 →Guides connexes

William Harris
Fondateur et développeur principal de FxRobotEasy
Chicago, USA · Depuis 2021
- 12+ ans de trading en direct
- 10+ ans MQL5 / MQL4
- 3 Expert Advisors vérifiés en direct
- Fondé en 2021
“Je développe avec du code depuis le collège. Je trade depuis l'université. L'intersection de ces deux mondes — algorithmes, marchés et la technologie qui les relie — c'est là que j'ai passé les quinze dernières années. FxRobotEasy est ce qui se produit lorsqu'on refuse d'abandonner jusqu'à ce que l'idée imaginée fonctionne réellement sur un compte de courtier en direct.”