Loading…

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

SettingDefaultWhat it does
Endpoint urlJSON prediction endpoint (GET request, no auth header sent)
Expected symbolEndpoint's "symbol" field must equal this - blank = accept _Symbol only
Poll interval sec30
Max data age seconds120Endpoint timestamp older than this is rejected as stale
Min prediction magnitude0.30|prediction| must reach this to act at all, otherwise treated as FLAT
Min confidence0.50confidence must reach this to act at all
Magic number44600Magic number that tells this EA's orders apart
Base lots0.02Lots at confidence 1.0, scaled down linearly by actual confidence
Max lots per trade0.10Hard cap - no order may exceed this regardless of confidence
Stop loss pips25Mandatory - every position opened here carries a stop
Take profit pips500 = no take-profit, ride the stop/next-signal exit only
Min seconds between flips300Cooldown after closing a position before opening the opposite side
Max trades per hour6Circuit breaker on new opens, regardless of how often predictions flip
Slippage points5Maximum slippage allowed when opening a trade
Dry runfalse
Max retries5
Retry wait ms500

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Channels & Envelopes · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria