Alpha Engine: Intrinsic-Time Coastline Trader
Info
The Alpha Engine: Intrinsic-Time Coastline Trader is a Expert Advisor for MetaTrader 5 that overviewmost trading systems in metatrader operate on a fixed calendar time, with indicators and expert advisors sampling the market at regular intervals (e. g.
Usage
This tool is typically used for automated trading on major forex pairs and gold.
Platform
This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Alpha Engine: Intrinsic-Time Coastline Trader
1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.
2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.
3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.
4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.
Frequently Asked Questions
Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.
Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.
Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.
What this tool does
OverviewMost trading systems in MetaTrader operate on a fixed calendar time, with indicators and Expert Advisors sampling the market at regular intervals (e.
Typical Use Case
This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.
Description & Settings
Related: KCI N-Matrix Engine: Advanced Trading Framework for MetaTrader 5 - another powerful expert for MetaTrader 5 traders.
OverviewAlso recommended: ba r s alligator - similar expert with strong performance on MetaTrader 5.
Most trading systems in MetaTrader operate on a fixed calendar time, with indicators and Expert Advisors sampling the market at regular intervals (e.g., every minute, hour, or day). This approach does not account for the market's inherent activity. High-volume periods, like news releases, can see significant price action within a single minute, while quiet sessions may offer little information over an entire hour. Sampling on a fixed clock assigns equal importance to both, leading to inefficient market observation.
Intrinsic Time
The Olsen group in Zurich developed an alternative called intrinsic time, where price movement, not the calendar, dictates the passage of time. A threshold, termed delta, is set. The clock advances only when the price reverses by at least delta from its last extreme, marking a directional change. Following a confirmed change, the price typically continues in the new direction for a period, known as the overshoot. The entire price path is thus an alternating sequence of directional change and overshoot sections, referred to as the coastline. In this system, both a volatile hour and a quiet hour are measured by the same unit: market events.
A jagged price path is resolved into directional-change (solid) and overshoot (dashed) sections at a fixed threshold. The intrinsic-time clock ticks only at these events.
This Expert Advisor is a direct MQL5 port of the Alpha Engine, a counter-trending coastline trader developed by Golub, Glattfelder, and Olsen using the intrinsic time clock. The EA opens positions against a price move at an intrinsic event. If the price continues to move against the position, it adds to the position at the next event (cascading). It then closes these added positions incrementally for a profit as the price reverts (de-cascading). Since new positions are only added in fixed increments, this strategy is not a martingale. The core logic, including the log-threshold runners and the information-theoretic liquidity indicator, is a line-for-line translation from the authors' reference Java implementation, with only the order handling adapted for the MetaTrader terminal.
A long agent cascades (adds to the position) as the price falls through successive intrinsic events, then de-cascades (reduces the position for a profit) as the price recovers.
Please read this before evaluating the results. The research indicates that the Alpha Engine is profitable even on a random walk. In tests on 200 seeded random walks, each comprising a million ticks, the reference engine consistently booked a realized profit. However, its total profit, including open positions, averaged zero. This pattern of closing winning trades more frequently than adding to losing ones reshapes the payoff distribution into numerous small wins and occasional large losses, but does not inherently create a trading edge. Therefore, a rising balance line from this EA should be viewed with caution; focus on the equity line for a more accurate performance assessment.
How It Trades
The EA operates using the ensemble described in the research: eight independent agents, each comprising one long-only and one short-only agent, operate at four different thresholds: 0.25%, 0.5%, 1%, and 1.5%. Each agent manages its own orders and positions using a unique magic number, ensuring no interference between agents.
The trading lifecycle is executed using limit orders on a hedging account, where each cascading step naturally becomes a separate position. A long agent maintains a single buy-limit order at the next downward intrinsic-event level. Each fill creates a new position with a take-profit set exactly delta above its entry price. This take-profit serves as the de-cascade mechanism. As the price declines, the ladder of buy-limit orders fills; as it recovers, the take-profits are used to close positions incrementally. A short agent functions as a mirror image. The resting order is only repositioned when a change occurs (an intrinsic event, a tier switch, or a fill), preventing unnecessary order churn on every tick.
Two primary defenses prevent a pure contrarian strategy from excessive losses during trends. The first is an inventory-driven skew: each agent advances three runners on every tick. The current inventory determines which runner dictates order placement. As inventory increases, the adverse threshold widens relative to the favorable one, making the agent more hesitant to add positions and more inclined to trim them. The second is fractional sizing: the size of added positions decreases as inventory grows.
Inventory (units)
Active runner
Adverse : favourable threshold
Unit added
below 15
Symmetric
1 : 1 (delta each way)
1
15 to 30
First skewed
2 : 1 (1.5 delta against 0.75 delta)
1/2
30 and above
Second skewed
4 : 1 (2 delta against 0.5 delta)
1/4
Additionally, the trade size is scaled by the liquidity indicator L, an information-theoretic measure of recent price action normality. This indicator treats each intrinsic event as a symbol, calculates the average surprise (self-information) of the event sequence, standardizes it, and maps it through the normal distribution function. L is close to 1 during normal market conditions and approaches 0 during unusually one-sided price movements. The add amount remains whole when L is 0.5 or higher, is halved when L is between 0.1 and 0.5, and is reduced to one-tenth when L is below 0.1. The indicator operates using its own wider overshoot threshold, 2.525729 times delta, which the research paper selected to sharply differentiate between normal and abnormal market behavior.
Abstract units are converted into lots through the InpLotPerUnit input parameter. The InpMaxUnits parameter caps each agent's inventory. This cap acts as a risk control measure not detailed in the original research: once the maximum inventory is reached, the agent cancels its resting entry orders and ceases adding new positions, while existing take-profit orders continue to be active.
Recommended Setup
Setting
Recommended value
Notes
Symbol
EURUSD
The primary instrument for development and testing, and the one on which the paper's scaling laws were verified. Since thresholds are relative (percentage of price), other liquid FX pairs should perform well without rescaling.
Timeframe
Any
The EA operates on an intrinsic time basis, processing ticks individually, making the chart timeframe irrelevant to its decision-making process.
Account type
Hedging
Required. Each cascading step must be a distinct position. On a netting account, the EA will prevent initialization by design and display a message.
Tester model
Every tick based on real ticks
Intrinsic events are determined on the tick stream. Bar-based models distort both event recognition and limit order fills. Ensure you are logged into a hedging account before testing, as the tester inherits the margin mode of your connected account.
InpLotPerUnit
0.02 (shipped), up to 0.4
When using a 0.01-lot step, the half and quarter units, along with the liquidity haircut, are only distinct sizes when a unit is approximately 0.4 lots. Below this, smaller additions are rounded up to the minimum lot size. The threshold skew mechanism remains unaffected.
Important:
Removing the EA from the chart cancels only its resting entry orders. Open positions are unaffected and will continue to be managed with their take-profits active. Manually close these positions if you wish to flatten the account.
Backtest Results
EURUSD, Every tick based on real ticks, February 2 to July 31, 2026. Starting deposit: 10,000 on a hedging account. Default settings (InpLotPerUnit = 0.02, InpMaxUnits = 30) with all eight agents enabled. The thresholds, sizing rules, and take-profit levels are based on the research paper and have not been specifically tuned for this symbol or period.
The Strategy Tester report for the six-month EURUSD run.
The simulation yielded a +10.68% return, with a profit factor of 2.21 and a maximum equity drawdown of 10.10% over 318 positions. The net profit figure aggregates two distinct performance streams. Analyzing the results by how each position was closed provides more insight than the total sum:
Component of the six-month result
Amount
294 positions closed at their take-profit
+1,934.14
24 positions closed by the tester at the end of the run
-823.55
Commission charged on entries
-42.14
Net profit
+1,068.45
Both closing lines include swap charges, which amounted to -620.38, significantly exceeding commission costs. For a strategy that can hold a cascade for extended periods, financing costs are more dominant than spread costs. The 24 positions closed by the tester represent cascades that did not recover; in live trading, these would have remained open.
The balance (blue line) increases as take-profit orders are executed. The equity (green line) reflects the value of open cascades and aligns with the balance only when the tester closes these positions on the final day.
This analysis covers one currency pair over a single six-month period, demonstrating a functional mechanism rather than peak performance. Any strategy that closes profitable trades while holding losing ones will show a rising balance. Therefore, the equity line and the implications of forced closes are the crucial aspects to examine.
Input Parameters
Parameter
Default
Description
InpLotPerUnit
0.02
Specifies the number of lots per one abstract unit defined in the research paper's sizing model. Increase this value towards 0.4 to maintain precise fractional sizing on symbols with a 0.01-lot minimum, or decrease it to trade smaller volumes.
InpMaxUnits
30
The maximum inventory limit per agent, measured in units. Once this limit is reached, the agent stops placing new entry orders and allows existing take-profit orders to manage the open position. The deepest skew tier is only activated beyond 30 units; therefore, at the default cap, it is never reached.
InpMagicBase
990000
The base magic number for the EA. The eight agents utilize magic numbers ranging from InpMagicBase to InpMagicBase + 7. Adjust this value if another EA on your account uses this range.
InpTradeLong
true
Enables the four long-only agents.
InpTradeShort
true
Enables the four short-only agents. With both enabled, the EA operates with the full symmetric setup described in the research.
Using the Classes in Your Own Code
Each agent is encapsulated within a self-contained class, CAeLiveTrader. This class operates independently of other agents. Consequently, an EA can utilize a single agent, a modified set of thresholds, or manage multiple symbols by creating multiple instances of the class.
#include
CAeLiveTrader agent;
//--- in OnInit: configure a long-only agent with a 0.5% delta, 0.02 lots per unit, and a 30-unit cap
agent.Init(_Symbol,
990100
,
1
,
0.005
,
0.02
,
30.0
);
//--- in OnTick
MqlTick t;
if (
SymbolInfoTick
(_Symbol,t))
agent.OnTickUpdate(t.bid,t.ask,t.time);
//--- in OnDeinit: cancel the resting entry order; open positions retain their take-profits
agent.Shutdown();
The intrinsic-time runner component can also be used independently. The CAeRunner class accepts distinct up and down thresholds in log-price terms. It returns an event code for each quote (e.g., +1/-1 for a directional change, +2/-2 for an overshoot step, 0 otherwise). It also consistently provides the precise prices at which the next events are expected to occur, making it a natural source for limit order levels in other trading strategies.
#include
CAeRunner runner;
runner.Init(
0.005
,
0.005
,
0.005
,
0.005
); // delta up/down, overshoot up/down
int
ev=runner.Run(AeTick(t.bid,t.ask,t.time));
if(ev==AE_EVENT_DC_DOWN)
(
You may also like: exp_i4_drf_v3 Expert Advisor - excellent alternative for expert users on MetaTrader 5.
Source Code
#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version "1.00"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#include <IntrinsicTime\AeLiveTrader.mqh>
input double InpLotPerUnit =0.02;
input double InpMaxUnits =30.0;
input long InpMagicBase =990000;
input bool InpTradeLong =true;
input bool InpTradeShort =true;
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.