MQL5 Algo Trading
574K subscribers
4.44K photos
7 videos
4.45K links
The best publications of the largest community of algotraders.

Subscribe to stay up-to-date with modern technologies and trading programs development.
Download Telegram
Gold Fractal Breakout EA for MT5 uses confirmed swing highs/lows to stage Buy Stop and Sell Stop entries. Swing detection is implemented via strict neighbor-bar comparisons, not the built-in fractals indicator. Ownership is filtered by symbol plus magic number, with exits managed through percentage-based rules.

Signal data is always read from H1 via an internal constant, regardless of the chart or tester timeframe. Scans are throttled (default 15 minutes, tick-driven), while position management runs on every tick. Default entry offsets are negative, placing buy entries below swing highs and sell entries above swing lows, but orders still must satisfy stop-order validity and broker stop-distance rules.

Key constraints: pending “expiry hours” is calculated but orders are submitted as GTC, so time-based expiration is not implemented. Any open position on the s...

👉 Read | VPS | @mql5dev
❤30🔥8👍7🤩4👀1
MQL4TradeCompat is a compatibility framework that recreates the classic MQL4 order-centric trading model on top of the native MQL5 execution architecture. It keeps legacy code working with familiar MQL4-style functions while translating operations into Position, Order, Deal, and History APIs.

The facade CMQL4TradeCompat exposes an MQL4-compatible interface and dispatches requests to native trade calls. CLiveTradeInfo acts as a live trade repository, aggregating positions and pending orders into a single collection with MQL4-style indexing, ticket selection, snapshot caching, and chronological ordering. CHistoryTradeInfo reconstructs historical trades from deal chains, including closed-trade aggregation, pending-order history, and profit, commission, swap, and weighted close-price calculations.

Core mapping routes OrderSelect through live/history repositorie...

👉 Read | Quotes | @mql5dev
❤16👍9🔥7🤩4👌1
GDS Renko Trade Manager is an MT5 Expert Advisor focused on stop-loss management for positions opened manually. It builds a fixed-size Renko stream per symbol from broker Bid ticks and advances logic only on completed bricks. No entries are generated, no pending orders are placed, and positions are not closed by this release. Existing TP values remain unchanged when SL is modified.

Core functions include break-even after N favorable completed bricks (optional offset) and Renko-based trailing after M bricks at a configurable gap, without intentional stop loosening. Positions can be filtered by verified manual origin or by exact positive Magic Number. A dashboard tracks BUY/SELL tickets, broker SL, thresholds, and brick progress, with an inset of recent completed bricks.

Operational controls include monitor-only mode by default, single-instance locking per accou...

👉 Read | AlgoBook | @mql5dev
❤14👍10🔥8🤩3👌2
Standalone drawdowns and correlation matrices cannot identify which configuration is responsible for a portfolio’s maximum drawdown. This script computes attribution from daily results and prints a full report in the Experts tab.

Key metrics include drawdown added via leave-one-out, the configuration’s share of the portfolio’s worst peak-to-trough window, and an Euler variance share Cov(x_i,P)/Var(P) shown alongside net profit share. A composite A+ to F score evaluates drawdown compression, risk spread, drag-free share, and return-to-drawdown, then issues KEEP, REDUCE, or REMOVE with recommendations.

Data sources are selectable: a reproducible demo portfolio (12 configs, 520 days), live account deals grouped by magic number (optionally symbol), or CSV input (Date,Config,Profit) with automatic separator and flexible number parsing.

Tuning inputs cover m...

👉 Read | CodeBase | @mql5dev
❤11👍7🤩7🔥4👌2
Randomness can be treated as a testable null hypothesis, not a default assumption. Typical targets include PRNG output and discretized market returns, where the goal is to detect deviations from IID uniform behavior.

A practical approach uses a chi-square test over overlapping s-chains. Counts are collected for (s+1)-tuples across an alphabet of size N, then observed transition frequencies are compared to conditional expectations vi_/N. Under H0, the statistic converges to chi-square with N^s*(N-1) degrees of freedom and is consistent against homogeneous ergodic Markov alternatives of order s.

For market data, a quantile transform helps remove drift by enforcing near-uniform state frequencies, isolating transition structure. On ~1,000 daily EURUSD observations (to 2026-04-03), results were: s=1 p=0.98, s=2 p=0.41, s=3 p=0.02, indicating dependence...

👉 Read | NeuroBook | @mql5dev
👍12❤10🔥5🤩4👌1
S3CE-Net reframes market data as an event stream: irregular tick-level impulses in price, volume, and liquidity that often precede visible trends. Instead of waiting for candlestick patterns, it targets early precursors using spike-guided attention.

The architecture combines SSAM to prioritize meaningful micro-events and suppress noise, with STFS to preserve broader context by sampling across time and the feature axis. For market vectors, “spatial” sampling is redefined as random feature subset selection based on functional relationships, not index proximity.

The implementation in MQL5 uses OpenCL kernels to generate five parallel views (global, temporal, feature, plus two alternatives) and produces separate forecasts per view to avoid averaging away weak but actionable signals. Training stability comes from triplet loss and label-smoothed cross-entropy, improvin...

👉 Read | Forum | @mql5dev
👍9❤6🔥4⚡2🤩2👌1
Part 18 extends the multi-symbol architecture with a shared indicator cache to remove duplicated handle management across strategy nodes.

Multi-symbol EAs often recreate identical MA/ATR indicators per module, repeating BarsCalculated(), Refresh(), buffer reads, error handling, and release paths. When requests match on type, symbol, timeframe, and inputs, this causes duplicate work and unclear ownership during partial init and shutdown.

The cache centralizes creation, readiness gating, data access, and lifetime. Consumers request MA or ATR via a full-parameter identity key; hits reuse an existing entry, misses create a new Standard Library CiMA/CiATR object. Each entry tracks references and request counts, and Release(entry&) applies reference counting with final FullRelease() on last consumer.

Strategy nodes keep independent signal and position state, bu...

👉 Read | VPS | @mql5dev
❤7👍6🔥3🤩3👌1😈1
Hermes Agent proposes a tighter alternative to RDP for MQL5 maintenance: a private Telegram bot triggers only explicitly enabled MetaTrader 5 MCP operations on the Windows machine where MT5 is installed (build 6060+).

Requests flow from Telegram to a gateway that validates user IDs, then Hermes maps the message into MCP tool parameters, executes the call in the local terminal, and returns structured output. Terminal logs, compiler diagnostics, and Strategy Tester results remain the source of truth.

The setup emphasizes reproducibility and control: pin the Hermes revision, record versions, keep MT5 running, and start with read-only tools for market data or account history before enabling MetaEditor compile or Strategy Tester jobs. Trading tools stay disabled, and a per-server confirmation gate can require approval for non-read-only actions.

👉 Read | AlgoBook | @mql5dev
👍13❤7🔥5👌1👨‍💻1
ATR Monitor adds a compact panel that compares the current Day, Week, and Month ranges against each timeframe’s built-in ATR. It also reports whether price is currently above or below each period’s open. The three rows are shown on any chart timeframe.

Columns include ATR (pips), Range (high minus low, pips), ATR% (Range/ATR*100), and From open (current minus open, pips). ATR% uses the full high–low range, while From open is a separate direction readout with positive/negative coloring and neutral near zero. Readings at or above MaxATRPercent are highlighted; the default threshold is 100% and does not cap the displayed value.

ATR is calculated on the current forming candle (shift 0) for each timeframe and updates on ticks, so it changes during the period. Period boundaries follow broker candles. Range and ATR differ because ATR uses true range and can incl...

👉 Read | Freelance | @mql5dev
❤5👍4🔥4👌1
PDF files can render cleanly while carrying structural defects. The content may be correct, while xref offsets, stream /Length, and startxref silently drift after minor edits.

Viewers typically seek from EOF to startxref, jump to xref, read offsets, then locate objects. When these bookkeeping steps fail, many implementations switch to repair mode by scanning for “N 0 obj” and rebuilding indexes, often without visible errors unless warnings are enabled.

A practical validator can focus on four generator-critical checks: header at byte 0, startxref landing on “xref”, 20-byte xref entries resolving to “i 0 obj”, and /Length reaching endstream. Passing these checks is necessary, not sufficient, but it reduces reliance on viewer recovery behavior.

👉 Read | Forum | @mql5dev
❤12👍8🤩4🔥2👌1
A combined setup of sloping native MT4 indicators focuses on trend confirmation, filtering, and timing without adding custom code. Typical combinations use Moving Averages for directional bias, MACD main line slope for momentum, and ADX for trend strength. RSI slope can serve as a secondary filter to reduce entries during range conditions.

Parameter alignment matters more than the indicator count. Smoothing periods should be coordinated so signals do not lag excessively, and slope thresholds should be defined to avoid reacting to noise. Validation should include sideways-market performance, spread impact, and consistent rules for entry, exit, and invalidation.

👉 Read | Freelance | @mql5dev
👍6🤩5❤4👌1
MetaTrader 5 “History Quality” can show 100% in real-tick mode even when large parts of a test actually ran on generated ticks. The key is that History Quality is derived from M1 bar data, while the Strategy Tester journal reports what happened minute-by-minute: real ticks accepted, or minutes marked “absent”/“discarded” and replaced with generated ticks.

The tester runs as a mixed stream across the period: accepted broker ticks where they match M1 bars, otherwise synthetic ticks built from each minute bar. Tick files on disk only confirm downloads, not usability for a specific range.

A practical workflow emerges: use the journal line “ticks data begins from” (repeat tests until it stabilizes), and validate from inside an EA by detecting spread changes within a minute and timing patterns that differ between real and generated ticks.

👉 Read | Calendar | @mql5dev
❤14👍11🤩6🔥4👌1
A symbol-agnostic Expert Advisor that trades only the chart instrument, with a hard cap of one position per week. All decisions are derived from closed D1 candles using server time, regardless of the chart timeframe.

Entry rule: evaluated once per week on Monday close. A long is allowed only when Monday’s close is strictly below the previous trading session close (typically Friday). No other condition can create entries.

Exit rule: any open position is closed at Wednesday’s daily close, executed on the first tick of the next D1 session. If that close is missed, the next available daily close triggers the exit.

Risk controls: a mandatory percentage stop is placed on entry, widened if required by the symbol minimum stop distance. After 5 failed SL apply/modify attempts, the system issues an immediate market close. No take-profit is used.

Optional entry rest...

👉 Read | AppStore | @mql5dev
👍8❤7🔥3🤩2👌1
Multi-timeframe analysis on MT5 becomes inefficient when charts are switched repeatedly and historical alignment is done manually. Side-by-side charts help, but time positions drift between M1/M5/M15/H1 views.

A prototype synchronization script addresses this by using a timestamp as the shared reference, not bar indexes. It takes the current chart’s first visible bar (minus one), extracts its time, iterates open charts via ChartFirst/ChartNext, filters by ChartSymbol()==_Symbol, and maps the timestamp per timeframe with iBarShift().

Each target chart disables autoscroll, moves to the end, reads visible bar count, computes displacement, calls ChartNavigate(), then redraws. Result: approximate time alignment across same-symbol charts, with known limits around candle intervals and missing history.

👉 Read | Docs | @mql5dev
❤20👍18🔥8👌1
ATR Monitor adds a compact volatility and direction panel for Day, Week, and Month on any chart. It compares each period’s current high–low range with that timeframe’s built-in ATR and shows whether price is trading above or below the period open.

The table reports ATR (pips), Range (pips), ATR % (Range/ATR*100), and From open (pips). ATR % uses the full high–low distance, while From open is directional, with positive and negative values color-coded and near-zero treated as neutral. Readings at or above MaxATRPercent are highlighted; default is 100% and affects highlighting only.

ATRPeriod defaults to 14 and is applied separately to D/W/M. Values use the current forming candle (shift 0), so ATR and range update during the period and follow broker candle boundaries. Range is high–low, while ATR uses true range and can reflect gaps.

Panel position, size, a...

👉 Read | CodeBase | @mql5dev
👍10🔥6❤4🤩3👌1
This article scales an AI “council” trading architecture from one symbol to eight, acknowledging that FX behavior depends on correlations and regime shifts across pairs. Each symbol runs as an isolated world with its own state, PnL targets, reputation history, and decision dynamics.

The Python server spins up eight PortContext instances and routes WebSocket sessions by a deterministic Magic/Port mapping, so MT5 needs only a preset. The EA stays minimal: consume a single JSON decision, open/hold/reverse one position, place SL/TP immediately, and keep broker-side protection if the link drops.

Decision-making is a three-phase parallel pipeline: 10 diverse analysts generate directional opinions, 4 risk managers gate trades on independent risk axes, then a low-temperature Chairman applies a strict voting procedure. A per-pair reputation engine with deca...

👉 Read | Quotes | @mql5dev
❤21👍11🔥8🤩7👌1
This article reframes chart intuition as time-series regression: modeling returns as stochastic processes, separating signal from noise, and using residuals as the primary diagnostic stream rather than an afterthought.

It starts with the constant-only model for log returns, showing how mean and variance are estimated, why unbiased variance needs n-1, and how confidence and prediction intervals rely on Student’s t when parameters are estimated.

Model trust is built through residual audits: ACF/Ljung–Box for dependence, Jarque–Bera for distribution shape, and Pettitt tests to catch mean or volatility regime breaks early.

It then extends to two-variable regression and stresses a critical implementation detail for MT5 quants: deterministic, exogenous, and endogenous regressors require different assumptions; ignoring regressor type can produce misleadin...

👉 Read | Freelance | @mql5dev
👍15❤11🔥8🤩7👌1
Part 2 of the Position Lifecycle Manager shifts order submission into the manager and removes chart-symbol coupling. Position discovery becomes position-centric, enabling adoption and management across multiple instruments from a single chart attachment.

Two modes define adoption rules. EA Mode uses a magic number and routes trade intents into manager-owned execution. Manual Mode adopts all open account positions, regardless of origin, and applies the same lifecycle rules, including potential SL/TP changes.

After adoption, the position symbol becomes authoritative for pricing, broker constraints, tick grid, volume rules, StopsLevel/FreezeLevel, and execution settings. Protection is staged: SL and TP are applied sequentially with retries and failure surfacing. Break-even is handled as a state transition with throttled reattempts. Telemetry exposes r...

👉 Read | Calendar | @mql5dev
👍16❤11🔥9🤩4👌1
Most trend-following indicators trade responsiveness for smoothness, typically via a fixed moving-average length. A scalar Kalman Filter makes the trade-off explicit by tracking uncertainty and computing the Kalman gain from two user-set variances: process noise Q and measurement noise R. The gain converges to a steady-state level driven by Q/R.

Applied to price, the local-level model treats each close as a noisy observation of an underlying true price. Each bar runs a predict step (state carried forward, variance grows by Q) and an update step (state corrected using gain and R). Correct recursion and initialization matter; wrong startup often looks plausible but is incorrect.

A practical signal uses two independent filters with different Q values and shared R. Example: Q=1.000,R=0.200 yields gain ~0.854; Q=0.005,R=0.200 yields ~0.146. In MT5/MQL5, ...

👉 Read | Signals | @mql5dev
❤16👍10🔥9🤩5👌1
Gaussian Process forecasting is sensitive to feature design. A rolling-window bar index input keeps the kernel geometry nearly constant, producing near-constant predictive variance and turning the horizon step into extrapolation rather than a market forecast.

The described MQL5 engine uses previous-bar log return as x and horizon-ahead log return as y, with input/target standardization to keep length-scale and likelihood scoring stable across regimes.

Implementation details include a symmetric kernel matrix, adaptive-jitter Cholesky, and explicit separation of latent variance from observed variance by adding noise only for realized forecasts. Hyperparameters are searched in log-space with a pure log marginal likelihood routine that avoids mutating fitted state mid-search.

Validation is framed as a calibration check: log forecasts and verify 1-sigma and 2-sig...

👉 Read | Quotes | @mql5dev
❤14👍8🔥6🤩6👌2
STE-FlowNet reframes sequence modeling as adaptive perception: each new event updates internal representations instead of averaging history like typical LSTM/GRU, improving responsiveness to regime shifts, volatility bursts, and rare patterns.

The pipeline treats data as event streams. Events are split into equal-count chunks and reweighted by temporal concentration using a Gaussian fit, so dense bursts get amplified rather than diluted by aggregation. This preserves short-lived, high-impact microstructure signals.

Architecturally, it uses an encoder–decoder with skips, residual blocks, multi-scale intermediate outputs, and ConvGRU at multiple resolutions to retain local detail while building global context. A correlation step aligns features to prior estimates, then iterative residual refinement updates predictions with shared weights for stability.

Trai...

👉 Read | CodeBase | @mql5dev
❤12👍10🔥4🤩3👌2