Astrolabe
- Эксперты
-
Alex Amuyunzu Raymond
I’m an experienced MQL5 developer and software engineer specializing in building robust, high-performance algorithmic trading systems for MetaTrader 5. My work goes beyond standard EA development — I design intelligent, scalable solutions that combine market logic, automation, and external - Версия: 1.3
- Активации: 5
The Problem This EA Was Built to Solve
Retail day traders lose money. Not because they lack intelligence, but because the market is designed to extract money from participants who trade too often, at the wrong times, with position sizes that assume a friendly market. A widely cited Brazilian study of persistent day traders found that 97% lost money over the study period, and the few who survived did so by trading rarely and cheaply. Opening-range breakouts on index CFDs — the strategy most retail EAs are built on — are roughly breakeven after costs in academic testing. The edge, if there is one, is not in the signal. It is in regime selection, cost control, and refusing to trade.
Astrolabe is built around that refusal.
What Astrolabe Actually Is
Astrolabe is a regime-aware session engine for MetaTrader 5. It does not fire orders on every bar, every tick, or every crossover. It watches three specific session windows — the Tokyo open, the European cash open, and the New York morning — and on each symbol, in each session, it asks a single question before any order is placed:
"Is the market in a state where this module's hypothesis has a measurable chance of surviving costs?"
If the answer is no, nothing happens. The EA logs the refusal, updates the dashboard, and waits. Refusing to trade is a first-class action in Astrolabe, not a failure.
The Three Trading Modules — Every One Off by Default
Every module is a testable hypothesis, not a promise. All three ship disabled. You turn one on only after your own testing passes your own kill gate. This is deliberate: the EA was designed by someone who has read too many product pages claiming edges that do not survive out-of-sample.
M1 — Participation Open Drive. At a session open (Frankfurt 09:00 CET, London 08:00 UK, Tokyo 09:00 JST, New York 09:30 ET, Hong Kong 09:30 HKT, Kuwait 09:00 AST), Astrolabe computes the opening range high and low, the first-candle close location, the gap versus prior close measured in ATR units, the participation ratio (current opening-window tick volume versus the median of the same window across the last 20 sessions), and the efficiency ratio (net move divided by total path). It only considers a continuation trade when all four agree: participation above threshold, efficiency high, close location decisive, gap not fighting the direction. On conflict, it does nothing. The entry is a pending stop beyond the range, cancelled automatically at a configurable entry deadline if not filled. The stop-loss sits at the opposite side of the range, capped by ATR. Exits are session-time flat or a fixed R target. A spread guard waits until the symbol's spread is within a multiple of its median for the same minute — a critical protection for the open, when spreads on index CFDs can balloon 5x.
M2 — Stretch Reversion. A mean-reversion module adapted from short-term deviation-from-average styles. Astrolabe computes stretch as (price − VWAP) / ATR . It fades only when all of the following are true: stretch exceeds k ATR (default 2.0), a capitulation volume spike prints (current volume > 2x the 19-bar average), and an exhaustion sign appears — either an RSI(2) extreme or a rejection candle (body less than 40% of range). The target is a return to the session VWAP; the stop-loss sits beyond the extreme plus an ATR buffer. A time stop closes the trade if the reversion does not happen quickly. Hard stop on every order. Never averages down. The evidence for M2-style reversion is weak and largely from equities, so the module ships off and the description says so.
M3 — Overnight Drift (Off by Default, Off by Design). A long-only drift module for GER40, entering near the Xetra close and flattening after the next open. It is automatically disabled whenever intraday-only or swap-free mode is active — because the whole point of those settings is to avoid swap, and M3 deliberately holds through it. If you enable both, M3 refuses to run. That is not a bug; it is the contract.
The Regime Selector — The Heart of the EA
With the selector enabled, Astrolabe scores each of the three modules per symbol per session and picks the single best-scoring regime, or none. If M1 scores highest, only M1 can trade. If M2 scores highest, only M2. If nothing scores above zero, the EA does nothing. You can also disable the selector entirely and pin one module — that lets you measure exactly what the selector adds versus what it costs in missed trades. At most one trade per symbol per session.
Consensus, Correlation, and the Index Group
For the European indices — GER40, FRA40, ITA40 at 09:00 CET — Astrolabe can require at least two of the three to agree on direction before taking any of them, and it will only take the highest-scoring index. It never holds more than one position across the three. This is a real filter: the three indices are heavily correlated, and taking all three when they disagree is how retail accounts get chopped in half at the open.
Across all index symbols — GER40, FRA40, ITA40, UK100, US100, US500, JP225, HK50 — a hard total-risk cap applies. The EA sums the stop-loss risk of every open position and refuses new orders if adding one would exceed the cap. Correlation caps are one of the few risk controls with genuine academic support, and Astrolabe treats it as non-negotiable.
The Risk Engine — Priority One
This is the part that matters most, and it was written first.
-
Fixed-fraction risk per trade (default 0.5%, with Conservative / Balanced / Prop presets).
-
Lot size derived from SYMBOL_TRADE_TICK_VALUE , tick size, and volume min/step/max — never from leverage, never from an assumed contract size. It works in USD, EUR, GBP, JPY, SGD, KWD, and CHF account currencies.
-
Before every order, the computed loss at stop-loss is checked against the risk budget. If broker limits (min lot, stops level) make the risk impossible to honor, the EA refuses to trade and logs why.
-
After fill, the EA verifies the actual risk and closes the position with a logged error if the realized risk is wrong.
-
Daily and total drawdown halts on equity, static or trailing, with Prop-mode-specific tighter limits.
-
Spread guard, deviation/slippage guard, stops-level guard, freeze-level guard, market-closed guard, margin check — all against live broker values.
-
Idempotency: magic number plus state recovery from open positions and pending orders. No duplicates after restart. No duplicates on duplicate terminals.
-
Every trade return code is checked. Transient errors retry; hard errors are logged with the reason and abandoned.
-
Prop mode adds configurable daily and overall drawdown, a news window, weekend flat, and a request-rate limit. Nothing in Astrolabe is designed to evade prop-firm detection — that would be both unethical and pointless.
Intraday-Only / Swap-Free
By default, Astrolabe flattens all positions before server rollover (configurable, 10 minutes before) and before the weekend. This avoids swap on every account and makes the EA suitable for Islamic swap-free accounts without any special handling. If you are on a swap-free account, the setting is already on. If you are not, it saves you overnight financing you never asked for.
The News Filter
Astrolabe uses the built-in MT5 economic calendar ( CalendarValueHistory , CalendarEventById , CalendarCountryById ). It reads high-impact events for the currencies of your chosen profile — EUR/USD for Germany, GBP/EUR/USD for the UK, JPY/USD for Japan, USD/JPY/CNH for Singapore, USD/OIL for Kuwait — and blocks new orders inside a configurable blackout window. Optionally, it can close or protect open positions. If the calendar is unavailable (some brokers disable it), the filter degrades gracefully: it logs a warning and stops blocking, rather than freezing the EA.
Per-Market Tailoring — Eight Profiles
Astrolabe ships with eight market profiles, each with its own session times, tick-volume defaults, news currencies, and rules:
| Profile | Symbols (aliases resolved automatically) | Session | Notes |
|---|---|---|---|
| Germany | GER40 / DE40 / DAX40 / GERMANY40 / DE30 / DAX | 09:00 CET/CEST | Consensus on |
| France | FRA40 / FR40 / CAC40 / FRANCE40 | 09:00 CET/CEST | Consensus on |
| Italy | ITA40 / IT40 / FTMIB | 09:00 CET/CEST | Consensus on |
| UK | UK100 / FTSE100 / FTSE / GB100 | 08:00 UK | Handles spread-bet GBP stake sizing via tick value |
| Japan | JP225 / JPN225 / NIKKEI / JP225Cash | 09:00 JST | Optional gotobi flag (off by default) |
| Singapore | HK50 / HSI50 / HANG SENG | 09:30 HKT | Also JP225 09:00 JST and XAUUSD session |
| Kuwait | XAUUSD / GOLD / XTIUSD / USOIL / WTI | 09:00 AST | Sunday–Thursday default, intraday-only, swap-free |
| USA | EURUSD / GBPUSD / USDJPY | 09:30 ET | FIFO enforced, no hedging, index rows disabled |
Alias resolution means the EA finds your broker's naming even if it calls the DAX "DE30" or the Hang Seng "HSI50". If nothing matches, it falls back to the chart symbol and runs — the validator will not see an error.
DST Implemented in Code, Not Assumed
US, EU, and UK DST dates differ for several weeks each year. Tokyo, Hong Kong, Singapore, and Kuwait have no DST. Astrolabe implements all of them in code — last-Sunday-of-March for the US start, first-Sunday-of-November for the US end, last-Sunday-of-March to last-Sunday-of-October for the EU/UK — and computes every session open in exchange local time converted to server time via a detected GMT offset. OnInit detects the broker's server offset from TimeTradeServer versus TimeGMT , and the self-test verifies DST conversion at known July and January dates. If the offset cannot be detected, the EA warns and defaults to zero — it does not silently trade at the wrong hour.
The Dashboard
On chart, top corner, ten lines. Profile, resolved symbol, magic number, live equity, daily and total drawdown versus limits, lock state, open positions and pendings, per-module on/off state, regime selector and consensus state, news filter and placebo state, last R-multiple, trial counter. White text, 9pt, updates every new M1 bar. Nothing fancy, nothing hidden.
Journal and Trade Log (CSV)
Two CSV logs. The decision journal records every trade taken or skipped, with timestamp, symbol, regime, taken/skipped flag, reason, score, spread at decision time, risk amount, and module name. The trade result log records R-multiple, costs, and spread at entry for every closed trade. Both are written incrementally and safely (open, seek to end, write, close). OnTester writes a full per-trade CSV at the end of every backtest.
Testing Modes — Required, Not Optional
-
PLACEBO mode: identical bracket, identical timing, random direction from a seeded PRNG. This is how you measure whether the signal adds anything over coin-flipping with the same risk management.
-
Per-module, per-symbol, per-profile switches. Turn M1 off, M2 on, measure. Turn everything off except M3, measure.
-
Cost-stress inputs: add extra spread and extra slippage in points to see whether the edge survives at 2x costs.
-
OnTester criterion: net expectancy in R with a trade-count penalty. Returns a single number to the Strategy Tester's optimization table.
-
Trial counter and multiple-testing note. The EA prints the trial counter in the tester log so you can apply a multiple-testing penalty to any optimized parameter set.
Astrolabe never invents backtest results. It cannot run MT5. It does not know your data. It gives you the tools to test, not the answers.
The Kill Gate You Should Apply
The EA ships with a documented kill gate in its description and code comments:
-
Net expectancy at least +0.10 R above placebo with a positive bootstrap confidence interval.
-
Still positive at 2x costs.
-
Profit factor at least 1.25 in validation and holdout.
-
At least 300 trades.
-
Positive in at least 70% of years.
-
No single year above 40% of total profit.
-
Stable across neighboring parameters.
Failing modules are dropped, not tuned. That is the rule. It is written in the code.
What Astrolabe Is Not
-
It is not a martingale, grid, averaging-down, or recovery-sizing system. There is no code path for those.
-
It is not a signal service, a profit guarantee, or advice. It never claims profit. It never says "this will make you money."
-
It is not a black box. Every decision is logged with a reason.
-
It is not a licensing system, a Telegram bot, or a localization package. It is a single .mq5 file that compiles in MetaEditor with zero errors and zero warnings, using only Trade\Trade.mqh from the standard library.
Who This Is For
Retail traders in the USA, UK, Germany, France, Italy, Japan, Singapore, and Kuwait who have already lost money to EAs that trade too much, size wrong, and hide their logic. Traders who want to run their own kill gate, not someone else's marketing copy. Traders who understand that an EA which refuses to trade is more valuable than one which trades every hour.
Technical Facts
-
One file: Astrolabe.mq5
-
One include: Trade\Trade.mqh
-
Zero DLLs. Zero external files except the CSV logs the EA itself writes.
-
Under 2,500 lines including comments and blank lines (this is a ceiling the EA was engineered to respect).
-
Account currencies supported: USD, EUR, GBP, JPY, SGD, KWD, CHF.
-
Timeframes used: M1 for all logic; no multi-timeframe dependency.
-
Works in Strategy Tester, on demo, on live. Self-test runs on demand.
