Prediction Endpoint Trader
An external prediction endpoint is an unvalidated input channel exactly like a webhook or a spreadsheet - a bug, an outage, or a compromised endpoint can hand this EA any number at all, and nothing stops it from claiming maximum confidence on a garbage value. Three guards apply before a single field from the response is allowed to influence a trade. The prediction (expected in [-1,+1]) and confidence (expected in [0,1]) are sanity-bounded and rejected outright if outside those ranges, not clamped and used anyway - a corrupt value is treated as no signal, never as an extreme signal. The endpoint's own declared timestamp is checked against InpMaxDataAgeSeconds (and against the clock running backwards, in case of a timezone mismatch) - a frozen or stuck endpoint cannot silently keep steering trades on data from hours ago. Every order carries a mandatory stop-loss and a lot size hard-capped at InpMaxLotsPerTrade regardless of how confident the endpoint claims to be; position size scales down from InpBaseLots by the reported confidence, but never up past the cap. An hourly circuit breaker (InpMaxTradesPerHour) and a cooldown between direction flips (InpMinSecondsBetweenFlips) exist because a noisy or flapping model can otherwise whipsaw the position open-close-open on every poll, paying the spread each time for no edge. A direction change closes the existing position on one cycle and only opens the new side after the cooldown, so a single noisy reading cannot flip the book twice in a row. Notes and limitations This EA trades exactly one symbol per chart attachment - running it on several symbols means attaching it several times, each with its own InpExpectedSymbol and magic number. The JSON response is parsed with a small hand-rolled key scanner suited to the documented fixed shape, not a general-purpose JSON parser; a response with nested arrays, scientific notation, or unusual whitespace would not parse correctly. Confidence-scaled sizing is a linear scale of InpBaseLots, not a Kelly or volatility- adjusted sizing model - it is a simple, auditable rule, not a claim of optimal sizing.
Expert advisor · MT5 · v1.0 · Free
About Prediction Endpoint Trader
Prediction Endpoint Trader is an expert advisor (trading robot) for MetaTrader 5. It has 17 settings, such as Endpoint url, Expected symbol and Poll interval sec. MQL source code included.
Files in the download: PredictionEndpointTrader.ex5, PredictionEndpointTrader.mq5, PredictionEndpointTrader.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 |
|---|---|---|
| Endpoint url | JSON prediction endpoint (GET request, no auth header sent) | |
| Expected symbol | Endpoint's "symbol" field must equal this - blank = accept _Symbol only | |
| Poll interval sec | 30 | |
| Max data age seconds | 120 | Endpoint timestamp older than this is rejected as stale |
| Min prediction magnitude | 0.30 | |prediction| must reach this to act at all, otherwise treated as FLAT |
| Min confidence | 0.50 | confidence must reach this to act at all |
| Magic number | 44600 | Magic number that tells this EA's orders apart |
| Base lots | 0.02 | Lots at confidence 1.0, scaled down linearly by actual confidence |
| Max lots per trade | 0.10 | Hard cap - no order may exceed this regardless of confidence |
| Stop loss pips | 25 | Mandatory - every position opened here carries a stop |
| Take profit pips | 50 | 0 = no take-profit, ride the stop/next-signal exit only |
| Min seconds between flips | 300 | Cooldown after closing a position before opening the opposite side |
| Max trades per hour | 6 | Circuit breaker on new opens, regardless of how often predictions flip |
| Slippage points | 5 | Maximum slippage allowed when opening a trade |
| Dry run | false | |
| Max retries | 5 | |
| Retry wait ms | 500 |
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: Channels & Envelopes · MT5 Expert Advisor · MQL5 Source Code