MQL5 Algo Trading
553K subscribers
4.02K photos
6 videos
4.02K 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
Fair Value Gap Scanner identifies three-candle price imbalances and renders bullish and bearish gaps as chart zones based on completed candles only.

Zones can persist after mitigation or be removed automatically. Mitigation logic can be set to either first touch of the zone or full fill, depending on the trading plan. A minimum gap size filter helps exclude minor imbalances on noisier instruments.

The scanner processes new candles rather than recreating objects on every tick, keeping chart load stable while retaining historical context.

Key inputs include Maximum Bars (scan depth), Minimum Gap Points, per-direction visibility toggles, Hide Mitigated, Use Full Fill, Extension Bars for zone length, and optional alerts triggered after candle confirmation. This is a visual analysis indicator and does not execute trades.

πŸ‘‰ Read | VPS | @mql5dev
❀18πŸ‘7✍5🀩3πŸ€”1πŸŽ‰1πŸ‘Œ1
SwiftDraw Starter shows a practical pattern for MT5 chart utilities: hotkey-driven object creation with a minimal indicator footprint (no buffers, no plots) and all interaction routed through OnChartEvent.

Hotkeys are mapped via StringGetCharacter to key codes, then used to arm one β€œpending” mode at a time (H/V lines, trendline, rectangle, Fibonacci, buy/sell arrows). ESC clears state and restores chart mouse scrolling to avoid input conflicts during drawing.

A compact i18n layer is implemented with enums and a Tr() switch, keeping UI prompts consistent across languages. The on-chart legend is rendered using OBJ_RECTANGLE_LABEL and OBJ_LABEL with a prefix for bulk cleanup, enabling a clean show/hide toggle without leaving orphaned objects.

Object creation follows a predictable naming scheme and sets selection/visibility flags for immediate editing after pl...

πŸ‘‰ Read | Signals | @mql5dev
❀12πŸ‘7πŸ‘Œ1
IronHawk SMC Trade Zones M5 is an M5 chart indicator that flags structured setups only on closed candles with non-repainting logic. It aggregates confirmed swing points, liquidity sweeps, BOS/CHoCH, displacement, Fair Value Gaps, Order Blocks, plus RSI, MACD and ATR-based risk metrics. No orders are sent or managed; Entry, Stop Loss, TP1 and TP2 are shown as proposed levels for manual validation.

Setup flow includes ARMED, ACTIVE, TP, SL, EXPIRED, INVALIDATED and AMBIGUOUS states, with up to five completed setups listed and color-coded outcomes. A clickable history jumps to the originating signal candle. Alerts and optional CSV journaling are available.

A retail-frequency mode prioritizes organic SMC. If fewer than two opportunities appear in a broker day, scheduled fallback signals after 09:00 and 14:00 server time can be generated via a closed-bar ...

πŸ‘‰ Read | Forum | @mql5dev
❀22πŸ‘4πŸ‘Œ1
Linked lists in MQL5 move beyond stack-style push/pop by supporting insert and delete at arbitrary positions without shifting large memory blocks.

ArrayInsert is efficient at the end, but mid-array inserts require new allocation plus multiple copy passes. Repeating this over thousands of operations becomes CPU and memory-bus heavy.

The next implementation step is pointer-only updates: add a node by relinking neighbors, remove a node by bypassing it. Code revisions progress from a singly linked list to a doubly linked list, enabling forward and backward traversal plus FIFO-style reads (SEEK_SET) versus LIFO-style reads (SEEK_END).

πŸ‘‰ Read | VPS | @mql5dev
❀17πŸ‘3πŸ”₯2πŸ‘1🀩1πŸ‘Œ1
MetaTrader 5 chart objects can be selected reliably via ZOrder, but horizontal price lines remain hard to hit when lines are close.

A practical workaround is adding a small OBJ_LABEL β€œmove handle” next to each SL/TP line. Selection is done by clicking the handle, not the line. DispatchMessage is adjusted to cascade events to redraw and to clear selection on generic chart clicks.

Moving a line requires minimal code: when a handle is selected and the next click occurs elsewhere, the indicator sends a custom message to the EA with the new price. The EA updates SL/TP on the server and returns the confirmed level for rendering.

To allow recreating SL/TP after removal, pointers are not dropped when values become zero. Instead, the handle remains and is relocated to the entry price line, enabling the same click-to-set flow.

πŸ‘‰ Read | NeuroBook | @mql5dev
❀15πŸ‘6πŸ”₯3πŸ†2πŸ‘Œ1
First Fractal Breakout is an intraday, session-bound system that replaces fixed opening-range windows with the first confirmed Bill Williams fractals after the open. Those five-bar pivots define a price-driven breakout box that naturally widens or tightens with volatility, enabling up to one long and one short attempt per session.

Implementation details matter: fractals confirm with a two-bar delay, so the logic queries M5 data at shift 3 and starts scanning ~15 minutes after open to avoid noise and repaint risk. Stops scale using a fraction of D1 ATR, position size is computed from percent risk, and take-profit uses a fixed reward-to-risk multiplier (both optimized to reduce overfitting).

The MQL5 EA enforces session timing, validates broker constraints (stops/freeze, margin), handles bid-trigger vs ask execution, tracks per-direction outcomes, and ...

πŸ‘‰ Read | Quotes | @mql5dev
❀17πŸ‘5πŸŽ‰2🀩2πŸ‘Œ1
PropFirmGuard is a risk-control layer for prop firm constraints, focused on daily loss and maximum total drawdown. It monitors account equity on every tick and, near a breach, closes all open positions, removes pending orders, and blocks new trades until the daily reset. It does not place trades and can run alongside any EA or manual trading on any symbol/timeframe as a tick source.

Daily loss is measured from equity at the configured reset hour. Total drawdown is measured from the highest equity since start. A configurable buffer is subtracted from both limits to trigger earlier (e.g., 5% daily with 0.5% buffer enforces at 4.5%). Total drawdown breach locks trading permanently.

The guard polls account state, so it also covers manual trades and other EAs without integration hooks. State is in-memory only; tester behavior matches live. On terminal restart, t...

πŸ‘‰ Read | Forum | @mql5dev
❀8πŸ‘6πŸ”₯2🀩1πŸ‘Œ1
This article removes the usual β€œtranslation tax” when streaming MetaTrader 5 tick batches into Python by writing ticks directly in Apache Arrow’s columnar memory layout inside Windows shared memory. Instead of serializing rows and unpacking fields into Python objects, the reader can import the same buffers as an Arrow RecordBatch with zero deserialization.

On the MT5 side, ArrowBufferWriter.mqh builds 64-byte aligned validity/data buffers for six tick columns and publishes them via a double-buffered seqlock (odd/even generation counter) to guarantee consistent reads without mutexes. No pointers are shared; both sides recompute offsets from a fixed schema contract.

An EA batches ticks by size or timeout and flushes with a small, bounded set of memory copies per batch. A self-test script validates byte-level correctness before adding the Python reader...

πŸ‘‰ Read | Forum | @mql5dev
πŸ‘11❀9🀩1πŸ‘Œ1
Engineering workflow for suppressing noise in lagged MA features and converting regime structure into a deployable, risk-aware MQL5 system.

Pipeline uses MA lags, ICA embedding, and a linear classifier. Two issues surfaced: unstable out-of-sample gains and non-deployable spectral clustering due to skl2onnx limits.

Fixes include time-series CV for ICA tuning, a cluster-count search with a peak at 8 regimes, and a supervised surrogate to predict spectral regimes for ONNX export.

Validation highlights a common failure: per-cluster accuracy on one-hot labels is reward-hackable by predicting zeros. Joint accuracy and class-share checks are required.

MQL5 integration loads three ONNX models and applies regime-conditioned position sizing and stop width using expected return and risk per cluster, then backtests on the last three years with tick-accurate sett...

πŸ‘‰ Read | AppStore | @mql5dev
❀9πŸ‘6πŸ”₯2🀩1πŸ‘Œ1
Part 2 connects dynamic risk-budget computation to position sizing via WParamCalibrator.

The calibrator converts risk_budget_pct into a sigmoid w parameter, then PropFirmAwareSizer scales positions smoothly from full size to zero as the daily budget erodes. The sizing logic remains independent of the specific prop-firm rule set.

A sigmoid is used to avoid threshold discontinuities that cause abrupt sizing shutdowns and unstable behavior in path-dependent strategies. The chain computes cal_bet_size = (risk_budget_pct * safety_factor) / stop_loss_pct, then numerically inverts the sigmoid to get w. The 0.98 cap and 0.02 floor are arithmetic guards, not business rules.

Default parameters create a long flat sizing ceiling until roughly 1.4% budget remains, concentrating de-risking late. This requires strategy-specific tuning and backtesting.

A product...

πŸ‘‰ Read | Docs | @mql5dev
❀12πŸ‘4πŸ‘Œ1
The article completes a doubly linked list in MQL5 by adding safe deletion and insertion in the middle, avoiding array-style shifting and extra copying. The core technique is pointer rewiring: link a node’s prev directly to its next (and vice versa), then free the removed node.

Deletion evolves from value-based search to index-based removal, with a maintained element count to validate bounds and handle head/tail as fast paths. A further refinement accepts negative indexes to traverse from the end, requiring direction-aware pointer updates to prevent deleting the wrong node.

These patterns matter when building MT5 tools that process large, frequently changing datasets, such as order/price event buffers, where predictable runtime and minimal memory churn are critical.

πŸ‘‰ Read | VPS | @mql5dev
❀19πŸ‘7πŸ‘Œ1
The MVC table library for MT5 is extended with a vertical header, enabling row-aware layouts where both axes carry meaningful labels. The example builds a symmetric symbol correlation matrix: row/column headers show symbols, cells show correlation values.

Rendering is improved with three-point color interpolation for coefficients in [-1..+1], so each cell can be shaded consistently based on correlation strength and sign. Cells now support their own background color instead of inheriting the row color.

Interaction handling is refined: hover/click can operate at cell level without row flicker, and events report the selected row/column plus header texts. Header classes are refactored into a common base with specialized column/row variants, and column headers can emit sortable-click events. Subwindow sizing is handled to keep cursor tracking correct afte...

πŸ‘‰ Read | VPS | @mql5dev
❀8πŸ‘2πŸ‘Œ1
Replay/simulation UI updates for MQL5 position indicators.

A chart-only long/short cue is added when SL and TP are absent. C_ElementsTrade gains a direction object; CreateInfoDirect builds a Wingdings glyph via CharArrayToString from a ushort array, selecting code 236 or 238 based on a constructor flag. C_IndicatorPosition is adjusted to pass position direction with minimal edits.

Interaction safety is tightened for SL/TP dragging. DispatchMessage now signals the mouse indicator to hide the horizontal line during move mode and restore it after selection. Follow-up changes route the active price into UpdateViewPort, enabling an auxiliary line and synchronized movement of related controls while waiting for server confirmation.

πŸ‘‰ Read | Freelance | @mql5dev
❀19πŸ‘4🀩1πŸ‘Œ1πŸ‘¨β€πŸ’»1
SCNN splits a time series into long-term, seasonal, short-term, coupled, and residual components, training each path separately. This improves auditability versus monolithic models and supports mixed heuristics plus neural modules.

Current implementation work focuses on the coupled component via spatially weighted normalization with attention. OpenCL kernels AdaptSpatialNorm and AdaptSpatialNormGrad compute weighted mean/variance per time step, normalize per variable, and backpropagate gradients to inputs, attention weights, and saved statistics.

A new CNeuronAdaptSpatialNorm class in MQL5 wires the forward/backward passes and builds attention from a reduced trainable tensor, its transpose, a correlation matrix, and SoftMax, while persisting mean/stddev for later graph stages.

πŸ‘‰ Read | Calendar | @mql5dev
❀14πŸ‘6πŸ”₯2πŸŽ‰2πŸ‘Œ2🀩1
Ecological Cycle Optimizer (ECO) reframes metaheuristic search as an ecosystem: 20% producers hold elite solutions, herbivores and carnivores iteratively chase better regions, and omnivores blend signals across trophic levels to reduce blind spots.

Exploration is controlled by an adaptive predation coefficient that starts aggressive for broad search, then decays toward 1 to emphasize local refinement. Target selection uses fitness-weighted sampling to keep diversity while favoring strong candidates.

A decomposition phase applies three mutation styles (best-neighborhood, distance-scaled local randomness, and time-decaying global jumps) to avoid early stagnation. Greedy revision rolls back losing moves, preserving monotonic improvement.

The MT5 implementation structures this as a configurable class with grouped agent ranges, per-iteration Moving/Revis...

πŸ‘‰ Read | Docs | @mql5dev
❀5πŸ‘5🀩1πŸ‘Œ1
Most SMC indicators stop at annotation. They mark swings, FVGs, and liquidity lines, then leave interpretation and trade decisions to manual work. Many also repaint by confirming swings only after the fact, so historical study does not match live conditions.

A workable approach is a single analysis pipeline that produces an explicit Market Intent Score (0–100) and maps it to a small set of decision states. The same code path must run in both β€œindicator” and β€œexecution” modes, with one boolean controlling whether orders are sent.

The system uses four timeframes (default H4/H1/M15/M5) and five stages: structure, liquidity, price behavior, intent scoring, and decision/trade plan. Key implementation details include storing swing confirmation lag, separating β€œbroken” vs β€œswept” levels, pooling liquidity with ATR-scaled tolerance, and using protected hig...

πŸ‘‰ Read | Forum | @mql5dev
❀15πŸ‘8πŸ‘¨β€πŸ’»3πŸ”₯2🀩2πŸ‘Œ2πŸ†1
A quantum-enhanced MT5 pipeline is extended with a 3D-bar module to preserve the joint structure of price, time, volume, and volatility that 2D indicators miss. M15 OHLCV for 8 FX pairs feeds three parallel feature builders (3D bars, an 8‑qubit Qiskit encoder, and 33 classic indicators) before CatBoost predicts 24‑hour direction, with optional Llama-based interpretation.

The Bars3D layer tackles non-stationarity by converting OHLCV into stationary, windowed features: cyclical time encoding, returns and price acceleration, volume change and acceleration, plus rolling volatility and its change, scaled to a 3–9 range. It also flags β€œyellow clusters” where high price and volume volatility coincide, estimating local reversal probability.

Quantum features come from RY angle encoding with CZ entanglement on a ring, measured into entropy, dominant-state p...

πŸ‘‰ Read | Calendar | @mql5dev
❀14πŸ‘4πŸ”₯2⚑1✍1🀩1
SCNN implementation in MQL5 reaches the assembly and test phase, focusing on the Encoder’s end-to-end data path. The model decomposes a time series into long-term, seasonal, short-term, and spatially-aware components, keeping intermediate signals interpretable.

The forward pass applies long-term normalization, seasonal transposition and period normalization, short-term extraction, and attention-based spatial normalization. Outputs plus summary statistics are concatenated without expanding means/std across time to reduce memory, then passed through projection and a Fusion block with TANH and SIGMOID convolution branches combined by element-wise multiplication.

Backpropagation mirrors this layout: gradients split across the gated convolution branches, recombine after transpose, then flow through projection and sequential deconcatenation. Normalizers...

πŸ‘‰ Read | AppStore | @mql5dev
πŸ‘9❀7🀩2⚑1
Partial Information Decomposition (PID) is implemented in MQL5 to fix a common failure in trading feature selection: single-indicator screens miss pair-only effects (classic XOR), where each input is useless alone but powerful together. PID splits information from two sources into four atoms: redundancy, two uniques, and synergy, with internal consistency checked via co-information.

The library supports three redundancy axioms (I_min, I_MMI, I_ccs) and shows they can disagree materially, making the axiom a modeling choice rather than an implementation detail. Continuous market data is discretized into equal-frequency bins to build a compact joint count table; all entropies are computed efficiently using precomputed log lookups.

Finite-sample bias makes raw atoms nonzero even on pure noise, so the library relies on a permutation null (with block shufflin...

πŸ‘‰ Read | Signals | @mql5dev
❀6πŸ‘2πŸ”₯1
An MQL5 signal class is set up to test whether a neural confirmation adds measurable value to a trend-continuation ruleset on EURUSD H4. The rule engine proposes entries from ADX/DI, an HMM gates them by regime probability, and an optional GRU vetoes unless direction and confidence thresholds are met.

The HMM estimates range, trend, or high-volatility states from normalized ADX and standardized ATR/price using a 3-state Gaussian model with Baum-Welch fitting and posterior gating (>= 0.6). The GRU is regime-specific and predicts near-term direction; it must agree with the rule and exceed |output| >= 0.05.

Evaluation is framed as a three-way comparison: raw rule, HMM-gated rule, and HMM+GRU. The added complexity is justified only if rejected trades have worse expectancy and risk metrics, rather than simply reducing trade count.

πŸ‘‰ Read | AppStore | @mql5dev
πŸ‘2