Observability First Template
Most published EAs add logging only after something has already gone wrong in production - a handful of Print() calls dropped in wherever the last bug happened to hurt. That leaves every earlier decision unexplained: a trader staring at a flat account at the end of the day has no record of why the EA did not trade, only evidence of what it did. This template inverts the order. Three observability primitives are wired in before the strategy function even exists: in-memory telemetry counters shown on-chart every tick (ticks processed, signals evaluated, signals fired, orders opened, orders failed, last error code), a one-line health file overwritten on a timer that a dashboard or a human can read without touching the terminal, and an append-only CSV decision log where every signal evaluation is a row - what the signal was, why, and what the EA did about it, whether or not a trade resulted. The demo strategy itself (EvaluateDemoSignal, a fast/slow SMA crossover) is deliberately the only piece meant to be replaced. Position sizing uses live MODE_TICKVALUE/MODE_TICKSIZE risk-percent sizing rather than a fixed lot size, normalised to the broker's actual lot step/min/max, so the skeleton is genuinely tradeable as shipped, not just a logging demo with no real order path behind it. Notes and limitations - The demo strategy is a plain SMA crossover included only to give the telemetry/logging plumbing something real to observe - it is not tuned or validated as a trading system, and should be replaced before live use. - The health file and decision log are sandboxed to MQL4\Files\ (or MQL5\Files\ on the native MQL5 build) like all MQL4 file I/O; nothing here writes anywhere else on disk. - Only one position per symbol/magic is opened at a time by the demo strategy; the observability plumbing itself has no such limit and would log correctly for a strategy that pyramids. - CSV rows accumulate for as long as the file exists; nothing in this skeleton rotates or truncates the decision log automatically.
Expert advisor · MT5 · v1.0 · Free
About Observability First Template
Observability First Template is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average. It can size trades from your balance and risk percent. It has 10 settings, such as Fast ma period, Slow ma period and Risk percent. MQL source code included.
Files in the download: ObservabilityFirstTemplate.ex5, ObservabilityFirstTemplate.mq5, ObservabilityFirstTemplate.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 MA period for the demo crossover signal |
| Slow ma period | 30 | Slow MA period for the demo crossover signal |
| Risk percent | 1.0 | Risk per trade, percent of equity |
| Stop loss pips | 25 | Stop-loss distance in pips |
| Take profit pips | 50 | Take-profit distance in pips |
| Magic number | 48900 | Magic number for this instance's orders |
| Health write sec | 5 | How often the health file is refreshed, seconds |
| Health file name | ObservabilityFirstTemplate_health.txt | Health file, in MQL5\Files\ |
| Decision log name | ObservabilityFirstTemplate_decisions.csv | Decision log, in MQL5\Files\ |
| Log every tick | false | true = log every evaluation; false = only log when the signal changes |
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: Risk & Lot Size · Moving Average · MT5 Expert Advisor · MQL5 Source Code