Installation & SetupBeginner8 min read

AUTOTRADING IN METATRADER 4: COMPLETE SETUP & SAFETY GUIDE

Learn how to enable and configure AutoTrading in MetaTrader 4 safely, manage global vs chart permissions, whitelist WebRequest URLs, and avoid silent shutdown mistakes.

By YoForexEA Research Desk

Quick Summary

AutoTrading in MetaTrader 4 requires two separate permissions: enabling the global AutoTrading toggle in Tools > Options > Expert Advisors (or Ctrl+E), and checking Allow live trading inside each chart's EA Common properties (F7). Because MT4 EAs run locally in your terminal, closing MT4 or switching profiles stops automated logic immediately.

How MetaTrader 4 AutoTrading Permissions Work

Many beginners assume clicking the toolbar AutoTrading button once enables every Expert Advisor permanently. In reality, autotrading in MT4 uses a two-layer security architecture—a global terminal switch and a per-chart permission lock—so a single unintended click or profile switch cannot fire trades on the wrong chart.

Both layers must be active simultaneously for an Expert Advisor to open, modify, or close orders. If either layer is off, the EA still executes indicator calculations inside OnTick(), but MetaTrader rejects every trade request with error 4109 (Trade is not allowed) and shows a sad face icon in the top-right corner of the chart.

Layer 1: Global MT4 Terminal Settings

To configure terminal-wide automated trading behavior, open Tools > Options (Ctrl+O) and select the Expert Advisors tab:

  • Allow automated trading: Master switch mirrored by the toolbar AutoTrading button (shortcut Ctrl+E). When enabled, the toolbar button displays a green circle/play symbol.
  • Disable automated trading when the account has been changed: Recommended safety lock. If you switch from a demo login to a live funded account in the same terminal, MT4 pauses AutoTrading automatically so demo parameters never fire on live capital by accident.
  • Disable automated trading when the profile has been changed: Useful if you maintain separate chart templates for manual trading vs automated bots.
  • Disable automated trading when the charts symbol or period has been changed: Prevents an EA tuned for M15 from trading on M1 or another pair if you drag a new symbol onto an active EA chart.
  • Allow DLL imports: Keep this unchecked by default. DLL libraries run native Windows machine code outside MetaTrader's MQL4 sandbox. Enable it only for audited EAs whose documentation explains why external DLL calls are necessary.
  • Allow WebRequest for listed URL: Required when an EA fetches an economic news calendar, license check, or API endpoint. Add only exact verified base URLs rather than arbitrary third-party links.

Layer 2: Per-Chart Expert Properties (F7)

Whenever you attach an EA to a chart (or press F7 on an already running chart), inspect the Common tab before clicking OK:

  • Positions (Long & Short / Only Long / Only Short): Leave on Long & Short unless your strategy explicitly filters directional bias on a higher timeframe.
  • Allow live trading: Must be checked on every individual chart where you want the EA to execute trades. Even when global AutoTrading is green, an unchecked box here keeps the chart icon frowning.
  • Allow modification of Signals settings: Needed only for signal-copying utilities, not standard strategy EAs.
  • Disable alert once hit / Safety tab controls: Review any chart alert rules so notifications do not pause expected execution workflows.

Magic Numbers for Multi-Chart AutoTrading

If you run two Expert Advisors on the same MT4 account—or even the same EA across two different symbols or timeframes—assign a unique integer Magic Number in each instance's Inputs tab (for example, 10101 for EURUSD M15 and 10102 for GBPUSD M15).

MetaTrader 4 assigns every automated order a hidden OrderMagicNumber() tag. Well-written EAs inspect that tag before calculating lot scaling, trailing stops, or basket exits. If two EAs share the default magic number 0 or 12345, one robot may close, trail, or count the other robot's trades—including your own manual trades, which always carry magic number 0.

What Happens When You Change Timeframes, Close Charts, or Shut Down MT4?

A critical point for anyone trading on MetaTrader 4 with robots is understanding where EA code actually lives: Expert Advisors execute client-side inside your running MT4 process, never on your broker's server.

Action in MT4 Broker-Side Hard SL & TP EA Trailing Stop, Breakeven & New Signals
You close the MT4 desktop app or your PC sleeps Remain active on the broker's server Stop immediately until MT4 restarts and reconnects
You close the chart holding the EA Remain active on the broker's server Stop permanently for that chart
You switch the chart timeframe (e.g., M15 to H1) Remain active on the broker's server EA re-initializes (OnDeinit then OnInit) and resets non-persistent memory variables
You press AutoTrading off (red stop icon) Remain active on the broker's server New trade/modify requests are blocked, though chart logic keeps running

Because closing your laptop halts virtual trailing stops, hidden stops, and exit signals, traders running EAs continuously during market hours use a dedicated Windows VPS and place hard server-side stop-losses on every position.

Running Multiple MT4 EAs Without Conflicts

MetaTrader 4 allows only one Expert Advisor per individual chart window, yet you can attach different EAs across multiple open charts inside the same MT4 terminal. Before enabling global AutoTrading across a multi-chart workspace, enforce three safeguards:

  • Distinct Magic Numbers: Assign a documented, unique Magic Number per chart (e.g., 2101, 2102, 2103) so position-counting loops and trailing functions stay strictly isolated.
  • Combined Margin & Risk Budget: Account-wide free margin is shared across every open chart. If four EAs each risk 1% on correlated USD pairs simultaneously, one macro surprise produces a 4% combined loss.
  • Watch CPU & Terminal Memory: Heavy multi-timeframe custom indicators called by multiple EAs can slow down tick processing. Monitor the Windows Task Manager and MetaTrader Journal for lag warnings during peak New York market hours.

Pre-Live AutoTrading Verification Checklist

Before toggling AutoTrading on a funded account, confirm these five checks on a demo terminal first: verify at least one live trade opens and closes cleanly with the expected lot size, inspect the Experts tab for zero error 130 or 4109 messages, verify that Stop Loss and Take Profit orders actually appear on the broker's Trade tab (not merely drawn as local chart lines), test what happens if you toggle AutoTrading off and back on, and save a clean .set backup of your verified Inputs.

ACTION CHECKLIST

  1. Open MT4 Options: Launch MetaTrader 4 and navigate to Tools > Options > Expert Advisors (or press Ctrl+O).
  2. Enable global AutoTrading: Check Allow automated trading and keep safety switches enabled for account or profile changes.
  3. Configure DLL and WebRequest rules: Leave Allow DLL imports unchecked unless explicitly required by trusted documentation, and whitelist only verified URLs under Allow WebRequest.
  4. Attach EA and allow live trading: Drag the EA onto your target chart, open the Common tab (F7), and check Allow live trading.
  5. Assign a unique Magic Number: Set a distinct Magic Number in the Inputs tab whenever running multiple EAs or multiple charts on one account.
  6. Verify green toolbar and smiley icon: Confirm the toolbar AutoTrading button is green and the chart top-right icon shows a smiley face with zero errors in the Experts tab.

FREQUENTLY ASKED QUESTIONS

How do I turn on AutoTrading in MT4 without allowing unsafe DLL scripts?

In Tools > Options > Expert Advisors, check Allow automated trading while leaving Allow DLL imports unchecked. Standard MQL4 Expert Advisors do not require external DLL calls to read indicators or send broker orders.

Will my MT4 EA keep trading if I close MetaTrader 4 or turn off my computer?

No. MT4 Expert Advisors run locally inside your open terminal. Already-placed Stop Loss and Take Profit levels remain on your broker's server, but new signals, trailing stops, and EA-managed exits stop until MT4 is running again.

Why did AutoTrading turn itself off after I switched accounts in MT4?

By default, MT4 checks 'Disable automated trading when the account has been changed' inside Tools > Options > Expert Advisors. This protects live accounts from accidentally executing demo-configured EAs when you switch logins.

What happens if two MT4 EAs use the same Magic Number?

If two EAs share the same Magic Number—or use 0, which matches manual trades—each EA can miscount open positions, miscalculate basket lot sizes, or prematurely trail and close the other strategy's trades.

EXPLORE RELATED EA HUBS

MT4 Expert Advisors →Scalpers →Grid Bots →

CONTINUE READING

EXPLORE VERIFIED EXPERT ADVISORS

Browse MT4 and MT5 bots, indicators, and setup resources across YoForexEA.

Browse EAsAll 18 Guides