The Expert Advisor Template: Your Starting Point for Algorithmic Trading in MetaTrader
Camovia Tray Team · 2026-09-16
There's a quiet moment every developer knows — the moment you open MetaEditor, click "New," and stare at a blank file. You have a trading strategy in mind, but where do you start? What goes into the boilerplate that turns an idea into a functioning trading robot?
For MetaTrader users, that starting point is the Expert Advisor (EA) template. It's not a ready-made trading system; it's the skeleton upon which any automated strategy is built. Understanding what the EA template is, what it contains, and how to use it is the first real step toward algorithmic trading on MT5 or MT4.
What Is an EA Template?
An Expert Advisor template is the basic source code file for a trading robot in MetaTrader . Think of it as a scaffold — it provides the standard program header, general properties, and placeholders for the core event handlers that will drive the EA's behavior .
When you create a new EA from the template in MetaEditor, you're not getting a trading strategy. You're getting the structure that makes a strategy executable. The template contains the essential framework:
- The program header — metadata like the EA name, author, and link
- Core event handlers —
OnInit()(called when the EA initializes),OnDeinit()(called when it's removed or the terminal shuts down), andOnTick()(the heartbeat of the EA, triggered with every new price tick)
The template itself is stored in the MQL5/Experts directory for MT5 or MQL4/Experts for MT4, depending on which platform you're using .
What You Get from the Template
Creating an EA from the template gives you a clean, compilable file that does nothing — yet. It's a foundation with no logic. But the value lies in what it provides:
Input parameters — The template allows you to define external variables (the input class variables) that traders can adjust without touching the code. Lot sizes, magic numbers, stop-loss distances — these are typically defined here .
The event model — OnTick() is where your trading logic will go. Every time a new price tick arrives, this function executes. OnInit() handles setup tasks like loading indicators or setting initial variables. OnDeinit() manages cleanup .
Optional event handlers — When creating a template in the MQL5 Wizard, you can add additional event handlers for chart events, depth of market updates, new trade actions, and more — all beyond the core OnTick, OnInit, and OnDeinit .
Two Paths: Template vs. Wizard
MetaEditor offers two distinct starting points, and they serve different purposes :
The Template gives you a blank canvas with structure. You write the trading logic yourself. This is for developers who want full control over every condition, filter, and execution detail. It's the path for custom strategies that don't fit into predefined modules.
The MQL5 Wizard (the "Generate" option) asks you to select signal modules, money management rules, and trailing stop types from the standard library. It generates a complete, ready-to-compile EA from these components — no manual coding required . This is for traders who want to assemble a strategy from proven building blocks without writing MQL5 from scratch.
Both approaches use templates as their foundation. The Wizard just fills in the template with pre-built components.
What the Template Is Not
It's worth clarifying what a template isn't. An EA template is not a trading strategy. It's not a set of signal conditions or entry rules. You'll find complete EA code repositories on platforms like GitHub that offer "templates" with position sizing, stop-loss calculation, and error handling built in — these are customized frameworks, not the MetaEditor template .
The official template is intentionally minimal. It exists to let you build up, not to dictate how you should build.
The Developer's Workflow
Once you've created an EA from the template and added your logic, the workflow is straightforward:
- Write and modify the code in MetaEditor
- Compile with F7 — this produces the
.ex5executable file - Test in the Strategy Tester using historical data
- Attach the EA to a chart in MT5 or MT4
After compilation, the EA appears in the Navigator window under Expert Advisors. Drag it onto a chart, enable AutoTrading, and the EA begins executing according to its logic .
When Development Becomes Management
Here's where the developer's reality sets in: once an EA is live, the screen time multiplies. You're running multiple charts, monitoring performance, checking for errors, and juggling terminal windows. The very tool you built to automate trading starts demanding your attention.
This is where a utility like Camovia Tray enters the workflow — not as a trading tool, but as a way to manage the trading environment itself. Camovia Tray turns MT5 or MT4 into a system tray tool, letting you check live quotes and manage open positions without keeping the full terminal visible [citation:product_knowledge]. For developers testing multiple EAs across different symbols, the ability to hover over a tray icon for a quick quote check or view open positions from the system tray keeps you informed without pulling focus from development work.
The EA template solves the problem of "how do I build a trading robot?" Camovia Tray solves a different problem — "how do I keep working without the terminal taking over my screen?" [citation:product_knowledge]
Getting Started
If you're ready to write your first EA:
- Open MetaEditor from MT5 (Tools → MetaQuotes Language Editor, or press F4)
- File → New → Expert Advisor (template)
- Name your EA, add author details, define input parameters
- Click Finish — you'll see the generated template with
OnInit,OnDeinit, andOnTick - Add your logic inside
OnTick(), compile, and test
The template itself is just the beginning. It's the start of every custom EA, but it's your code that turns it from a structure into a strategy.
MT4/MT5 Tray Assistant
Silent tracking, one-click close - check quotes and manage positions right from the tray.
Download Camovia TrayFrequently Asked Questions
Which systems and terminals are supported?
Windows 10 / 11, with MetaTrader 5 or MetaTrader 4 (installed and logged in; MT4 needs the bridge EA attached once).
Is the MT4 bridge EA safe? What do I need to enable?
Yes. The bridge EA (CamoviaBridge) is bundled with the app - it only reads quotes/positions locally and executes close commands; no DLLs, no data uploads. Closing positions requires turning on AutoTrading in the MT4 toolbar.
How much does it cost? Is there a free trial?
Subscription pricing starts at $2.49/month (also $6.99/3 months, $13.49/6 months, $23.99/year), all plans with full features. New users get a 2-day free trial on first activation (once per device and per email), then decide whether to subscribe.
How do I restore the MT5/MT4 window after hiding it?
Choose "Show MT5/MT4" from the system tray menu and the window returns to its previous position. You can also hover the tray to check quotes and manage positions without opening the terminal.
Online Tools
Popular Symbols Trading Hours
Open/close times, weekend hours & live market status:
Related Articles
Brent Crude Oil Market Open Time in India: What Traders Get Wrong
Brent crude oil market open time in India explained: session timings, IST conversion, and how Camovia Tray helps you track quotes and manage positions from the system tray.
Position Sizing vs. Leverage: Why "Lot Size" Is Not What You Think It Is
Turn MT4/MT5 into a tray tool: view positions, check lot size impact, and manage risk without opening the terminal. Camovia Tray keeps data local.
MT5 Alerts Only Work If Your PC Is On: The Real Fix
Why MT5 alerts miss when your PC sleeps—power settings, terminal state, and the tray-based setup that keeps alerts and quotes alive.
XAUUSD Opening Time: The Assumptions Most Traders Make (And Why They Lead to Missed Sessions)
Track XAUUSD opening time across sessions and brokers. Camovia Tray lets you check live gold quotes and manage positions from the system tray.
XAGUSD Market Open Time in India: A Complete Guide to Silver Trading Hours
Track XAGUSD market open time in India and key silver trading hours. See how Camovia Tray helps you monitor quotes and manage positions from your system tray.
More Articles
What Time Does CME Market Open? A Trader‘s Guide to Avoiding Common Hour Confusion
CME market hours explained: Sunday open, holiday schedules, and how Camovia Tray helps you check live quotes and manage positions from your system tray.
Where to Download MT5 for Windows 11: A Complete Safety Guide
Discover where to download MT5 for Windows 11 safely from official sources, plus how Camovia Tray turns MT5 into a tray tool for private quote checking and position management.
MT5 Toolbox Not Showing? Here’s Why and How to Fix It
Discover why MT5 Toolbox isn't showing and how to fix it. Camovia Tray offers a simpler way to view positions and quotes from your system tray.
AI Signal Tools vs. Manual Strategy Building: Why Your Trade Execution Setup Deserves the Same Attention as Your Entry Rules
Compare AI signal tools vs manual strategy building, and discover why trade execution matters. Camovia Tray turns MT5/MT4 into a tray tool for private, distraction-free position management.
MetaTrader Profit Calculators vs. Real-Time Position Management: What’s Actually Useful?
Discover a smarter way to track open positions beyond basic profit calculators. Camovia Tray lets you view real-time P&L from the system tray, manage trades, and keep data local—without opening MT5 or MT4.