Camovia Tray™

Blog · Knowledge

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 handlersOnInit() (called when the EA initializes), OnDeinit() (called when it's removed or the terminal shuts down), and OnTick() (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 modelOnTick() 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:

  1. Write and modify the code in MetaEditor
  2. Compile with F7 — this produces the .ex5 executable file
  3. Test in the Strategy Tester using historical data
  4. 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:

  1. Open MetaEditor from MT5 (Tools → MetaQuotes Language Editor, or press F4)
  2. File → New → Expert Advisor (template)
  3. Name your EA, add author details, define input parameters
  4. Click Finish — you'll see the generated template with OnInit, OnDeinit, and OnTick
  5. 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 Tray

Frequently 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.

Popular Symbols Trading Hours

Open/close times, weekend hours & live market status: