MQL5 Algo Trading
548K subscribers
3.93K photos
6 videos
3.94K 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
A causal trend-scanning engine was ported from Python to MQL5 as CTrendScanningFeatures.mqh, exposing four EA-friendly buffers (window, slope, t_value, RΒ²) via a standard iCustom-compatible indicator. The implementation replaces full window recomputation with O(1) per-horizon updates using running sums plus a ring buffer, while preserving numerical parity against the reference.

Building the port from first principles uncovered a sign inversion in the Python causal mode: reversing inputs without negating slope and t_value. The Part 13 wrapper is corrected by flipping both signs; most earlier conclusions remain unchanged because comparisons were sign-symmetric.

Two research-level caveats stand out. With volatility_threshold=0.0, β€œmasking” collapses to a simple running minimum. More importantly, selecting the max |t| across window lengths does not select th...

πŸ‘‰ Read | CodeBase | @mql5dev
❀57πŸ‘5πŸ‘Œ3πŸ†3⚑2
Volume-Weighted Delta Divergence Oscillator (VWDD) derives a delta proxy from each candle without requiring true order-flow. The close position inside the high-low range is mapped to a -1..+1 ratio and multiplied by volume (tick or real). Per-bar values are accumulated over InpDeltaPeriod, then normalized by a rolling standard deviation over InpNormPeriod to keep readings comparable across symbols and sessions. InpSmoothPeriod reduces noise.

The subwindow histogram shows net pressure: above zero suggests buy dominance, below zero suggests sell dominance. Divergence detection uses fractal-style swing confirmation with InpDivLookback bars on both sides and searches back up to InpDivSearchRange. Higher highs with lower oscillator highs flag bearish divergence; lower lows with higher oscillator lows flag bullish divergence. Arrows lag by roughly InpDivLoo...

πŸ‘‰ Read | Calendar | @mql5dev
❀21πŸ‘10πŸ‘Œ2πŸ‘¨β€πŸ’»2
Adaptive Volume Profile Node Tracker implements a rolling volume profile where bin size adapts to current volatility. On each rebuild it reads ATR(InpATRPeriod), derives a bin height from it, then clamps bin count between 5 and InpMaxBins. This keeps profiles granular in tight ranges and prevents over-fragmentation during fast markets.

The profile is built from the last InpLookback completed bars, bucketing tick volume (or real volume when enabled) by each bar’s close. It then identifies the Point of Control, expands outward to capture InpValueAreaPercent for Value Area High/Low, and classifies High/Low Volume Nodes using a mean and standard deviation threshold (InpNodeStdDevMult). Levels update every InpRecalcBars bars.

Operationally, POC and Value Area define fair value vs extension, HVNs tend to behave as liquidity shelves, and LVNs often mark fas...

πŸ‘‰ Read | NeuroBook | @mql5dev
❀27πŸ‘6πŸ‘Œ2
Multi-Symbol Correlation Divergence Meter quantifies when two typically linked instruments stop behaving alike. It calculates rolling Pearson correlation on bar-to-bar returns between the current chart and a user-defined reference symbol, plus a log-price spread converted into a rolling z-score.

A divergence event is signaled only when correlation drops below a configurable threshold and the spread z-score exceeds an extreme level. This filters for situations where decoupling and relative mispricing occur together, often preceding either mean reversion or a regime change.

Outputs include a correlation line bounded from -1 to +1 with a color change on breakdown, a spread z-score histogram, and optional up/down arrows for qualifying extremes. Typical use is risk tightening on correlation-dependent positions or conditional mean-reversion setups, validat...

πŸ‘‰ Read | Freelance | @mql5dev
❀15πŸ‘6πŸ”₯5πŸ‘Œ2
Candle Body-to-Wick Pressure Oscillator converts candle geometry into a bounded pressure score, then smooths it into an oscillator with an EMA signal line. Instead of relying on closes, it combines signed body ratio (|close-open| / range) with a wick imbalance term ((lower wick - upper wick) / range), weighted by InpWickWeight and normalized to stay near Β±1 before scaling to Β±100.

Histogram values above zero indicate bullish pressure dominance over the lookback; values below zero indicate bearish pressure. Crosses versus the signal line and the zero line help classify regime shifts and continuation.

Optional divergence marks are generated from confirmed price pivots (InpFractalRange) within InpDivergenceLookback, flagging higher oscillator lows vs lower price lows, or lower oscillator highs vs higher price highs. Defaults typically transfer across sy...

πŸ‘‰ Read | NeuroBook | @mql5dev
❀28πŸ‘7πŸ‘Œ3πŸ€”1
Currency Strength Meter computes relative strength for the 8 major currencies by aggregating percentage changes across all available broker pairs, rather than relying on a single cross. Each symbol contributes +change to the base currency and -change to the quote currency, then each currency score is averaged across the pairs it appears in. Missing crosses are skipped, keeping results usable without hard failures.

Output is a ranked list from strongest to weakest, with a per-currency average percent change over the selected lookback window. Bars are scaled to the largest absolute score on each refresh; colors differentiate positive versus negative readings.

Key inputs include calculation timeframe (independent of chart), lookback bars, and refresh mode (new bar only or every tick), plus panel layout and styling. Designed as read-only: no trade operat...

πŸ‘‰ Read | AppStore | @mql5dev
❀28πŸ‘6πŸ‘Œ2πŸ†2
Liquidity Void Decay Oscillator identifies gap-like displacements only when range expansion aligns with below-average tick volume, filtering for thin-participation moves rather than candle geometry alone.

Each detected void starts with a score of 100 and decays as later bars overlap the zone. Faster re-trading reduces the score quickly, while repeated approaches with limited overlap keep the charge elevated and signal an area still affecting order placement.

Outputs include a 0–100 histogram for the strongest active void, bar coloring to indicate whether the nearest void is below or above price, and a short SMA signal line. A cross below the signal line while still high indicates accelerating absorption.

Typical use on liquid FX pairs and lower timeframes. Scores holding 60–100 after multiple retests can define actionable levels; rapid decay toward...

πŸ‘‰ Read | Calendar | @mql5dev
❀25πŸ‘7πŸ‘Œ2
A compact MQL5 toolkit measures market β€œefficiency” by treating recent returns as a symbol string and scoring how well that string can be described by Lempel–Ziv phrase parsing. The LZ76 count is parameter-free and fast enough per bar; normalization maps values near 1 to noise-like behavior and lower values to repeatable structure.

Prices are not fed directly. The pipeline converts a trailing window of log-returns into symbols using SAX: z-normalize to remove scale, optionally aggregate, then quantize via Gaussian breakpoints so random data is uniformly distributed across the alphabet. Breakpoints are computed on the fly with a high-precision inverse normal approximation, and flat windows are handled explicitly to avoid divide-by-zero artifacts.

The library is split into symbolizer, complexity, NCD distance, and a facade class with reusable buffer...

πŸ‘‰ Read | Calendar | @mql5dev
❀16πŸ‘6πŸŽ‰1πŸ‘Œ1πŸ‘€1
Most automated chart pattern detectors validate geometry but ignore context. Reversal shapes inside ranges and continuation shapes without a prior impulse are routinely misclassified when prerequisite structure is not enforced.

A second failure mode is timeframe coupling. Swing logic computed on the same chart timeframe inherits intraday noise, causing trend state to flip repeatedly and invalidating context checks.

A proposed MQL5 approach fixes both issues by reading market structure from H4 regardless of the trading timeframe. H4 swing points are detected with a configurable strength window, labeled HH/LH/HL/LL, and the latest labels define trend state. Patterns on lower timeframes are evaluated only when the H4 prerequisite is met, while drawing remains correct via datetime anchoring.

πŸ‘‰ Read | Quotes | @mql5dev
❀14πŸ‘11πŸ‘Œ3
Entry filters are often judged by running an EA with and without enforcement, then comparing net profit, drawdown, and trade activity. That A/B test captures operational path changes from occupancy, compounding, sizing, and constraints, but it does not isolate whether accepted trades are an unusually favorable subset of base trades.

FilterEdgeAnalyzer.mqh separates these claims. A diagnostic run executes all base entries while tagging each position as accepted or rejected at entry. Completed positions are reconstructed from deals, net profit is aggregated per position, and accepted vs rejected mean outcomes are compared against fixed-count placebo selections that preserve the same acceptance count.

Three null models are supported: full mask permutation, equal-block permutation, and circular shifts. A finite-sample–corrected upper-tail p-value is report...

πŸ‘‰ Read | Freelance | @mql5dev
❀18πŸ‘6πŸ†2πŸ‘Œ1
This article turns the Oops gap reversal into a rule-complete MQL5 Expert Advisor, removing the common manual errors: missing the gap, confirming too early, letting setups run past validity, and inconsistent risk sizing. The EA detects gap-up and gap-down opens beyond the prior candle’s range, filters by a minimum gap in points, and tracks each setup for a fixed number of bars.

A shared state structure stores the gap bar time, reference levels, and lifecycle counters. Confirmation only happens on a later completed candle closing back into the prior range, preventing repeat signals and avoiding same-bar confirmation.

After confirmation, the EA rebuilds the gap-bar stop using iBarShift, projects take-profit from a risk-reward ratio, and sizes volume via fixed lots or percent-risk using OrderCalcProfit with broker step/limits. Execution is guarded by one-posit...

πŸ‘‰ Read | VPS | @mql5dev
❀25πŸ‘8πŸ†3πŸ‘€2πŸ‘Ύ2πŸ‘Œ1
EdgeMeter evaluates one question about any entry signal: after transaction costs, is there positive expectancy. It places no orders, reads history, tests the signal on each closed bar, and prints the result.

It reports gross edge across user-defined holding periods, net per-trade after costs (one position at a time), a t-statistic on non-overlapping trades, share of profitable months, and maximum drawdown. A random control with identical firing rate is included to validate the simulator and define the noise floor.

A common failure mode is overlap inflation. If forward windows overlap, treating samples as independent can overstate significance by roughly sqrt(horizon). EdgeMeter avoids this by simulating sequential, non-overlapping trades.

Pass criteria require net per trade > 0 after cost, |t| > 2, and at least 3 profitable months out of 4. Costs are e...

πŸ‘‰ Read | Docs | @mql5dev
❀20πŸ‘5πŸ‘Œ2
Stock CFDs continue to gain adoption, with broader platform support and FX brokers expanding availability. A common approach in equity intraday trading is the Opening Range Breakout (ORB), typically implemented around the NY cash session open.

A 5‑minute AAPL CFD algorithm based on ORB logic was built and tested. The entry module captures the early-session high/low range, then applies a volatility filter to qualify breakouts and reduce false triggers.

Risk management uses a fixed-risk stop loss, with take profit defined as a ratio of SL. Trailing and breakeven rules are included. Position sizing is derived from risk per trade relative to initial capital rather than floating equity, aligning with evaluation accounts where compounding can amplify drawdowns.

Session timing remains critical. The NY opening bell must be mapped to broker server time, with parame...

πŸ‘‰ Read | Calendar | @mql5dev
❀15πŸ‘10πŸ‘Œ4πŸ‘¨β€πŸ’»3✍2
Hybrid Microstructure EA targets XAUUSD scalping on M1 using tick-level signals rather than OHLC-derived indicators. Core inputs include tick velocity windows, 500-tick ring-buffer VWAP with dynamic deviation bands, and liquidity sweep rejection logic intended to filter stop-hunt spikes.

Execution is built around an OnTick() loop with spread/session/ATR gating, microstructure state machines, and a snapback confirmation step before entries. Order routing supports IOC/FOK filling, with fixed-lot or risk-percent sizing plus ATR or fixed stops, break-even, and trailing updates via TRADE_ACTION_SLTP.

A dual-layer decision gate adds an AI Bridge: a deterministic 0.0–1.0 weighted score and an optional local OpenAI-style HTTP endpoint (/analyze) called from MT5. The web payload uses messages/roles and expects decision, confidence, and reason, typically served with a...

πŸ‘‰ Read | AlgoBook | @mql5dev
❀29πŸ‘7πŸ‘Œ7
MetaTrader 5 runs EAs in a single thread; indicators get separate symbol threads. Heavy indicator work can delay tick processing, so parallel compute is typically pushed to DLLs or OpenCL. OpenCL avoids DLL permissions and keeps deployment to one EX5, with compute placed on CPU or GPU.

Neural nets allow parallelism per neuron inside a layer, while layers still run sequentially. This design uses OpenCL kernels with vector ops: FeedForward, output gradient, hidden gradient, and UpdateWeights in a 2D thread space.

Implementation centers on one-dimensional OpenCL buffers, a CBufferDouble wrapper, a COpenCLMy extension for dynamic buffer management, and a CNeuronBaseOCL layer object. Testing highlights that COpenCL::Execute queues kernels, so reads are needed to force completion.

πŸ‘‰ Read | AlgoBook | @mql5dev
❀45πŸ‘10πŸ‘Œ2
Wolfe Wave Dashboard v1.25 is a MetaTrader 5 indicator built for multi-symbol, multi-timeframe monitoring. It scans up to 20 symbols across configurable timeframes from M1 to MN1 and flags the newest valid Wolfe Wave setups using strict geometric constraints, including alternating pivots, 1-3 and 2-4 convergence, tolerance controls, and pattern width limits.

The scanning engine is optimized and processes only newly closed bars to keep CPU load predictable at scale. The dashboard lists Symbol, Timeframe, Direction, Pattern, Age (bars since point 5), historical Average Time-To-Target, and an Open action.

Chart opening draws the full layout automatically, with 1-3 and 2-4 lines, filled triangle, numbered points, entry arrow, and optional 1-4 target line. Alerts support popup, sound, email, and push notifications. Time-To-Target statistics persist to CSV...

πŸ‘‰ Read | Freelance | @mql5dev
❀68πŸ‘9πŸ‘Œ4πŸ‘€4😁3πŸ‘¨β€πŸ’»3✍1
A SuperTrend indicator implementation for MetaTrader 5 built from first principles, using an ATR-scaled envelope, a ratcheting band that only tightens in the active trend direction, and a binary trend state that flips only after a confirmed close beyond the opposite band.

Recursive state is stored in indicator calculation buffers (upper band, lower band, trend flag) instead of manually-managed arrays. This delegates sizing and persistence to the terminal, reducing continuity issues that often surface in backtests when state resets or desynchronizes.

The logic uses consistent series indexing and a deterministic seeding step from the oldest usable bar. Reversal arrows are plotted only after confirmation on a bar that will not be recalculated, avoiding transient signals that appear and disappear on subsequent ticks.

πŸ‘‰ Read | Calendar | @mql5dev
❀32πŸ‘6πŸ‘¨β€πŸ’»3πŸ‘Œ2🀣2πŸ‘€1
A complete Fisher Transform oscillator for MetaTrader 5 built from statistical first principles. It reshapes bounded price-derived values into a near-normal distribution, producing sharper turning points than many averaging-based oscillators.

Computation is performed in three stages: normalize price to a fixed range from recent highs/lows, smooth the normalized series with a clamp near the boundary to keep the logarithm well-behaved, then apply the Fisher log transform and recursively blend with the prior output. Recursive state uses registered indicator buffers, with the main output serving as its own continuous memory.

The output is a single oscillator line without built-in trade arrows. Typical interpretation combines level and behavior: readings beyond about Β±1.5 to Β±2 indicate extremes, while the usable event is the turn back toward zero after t...

πŸ‘‰ Read | Calendar | @mql5dev
❀22πŸ‘4πŸ‘¨β€πŸ’»4πŸ‘Œ1
Hurst Exponent Regime Switch is a regime filter that estimates a rolling Hurst exponent (H) from price using classic rescaled-range (R/S) analysis, then plots it as a 0–1 oscillator with threshold-based state changes.

Per bar, the lookback series is split into multiple chunk sizes. For each chunk, the range of cumulative mean-adjusted deviation is scaled by its standard deviation. Average R/S per chunk size is regressed in log-log space; the slope is clamped to [0,1] as H and optionally smoothed with a short EMA.

Interpretation is straightforward: H near 0.5 implies random-walk behavior, above the trend threshold (default 0.55) indicates persistence, and below the reversion threshold (default 0.45) signals anti-persistence. Primary inputs: lookback 200, min chunk 8, chunk steps 6, smoothing 5, applied price close. Best behavior typically appears on ...

πŸ‘‰ Read | AlgoBook | @mql5dev
❀23πŸ‘7πŸ‘Œ3πŸ‘€3
Prop-firm style daily loss rules often fail in real EAs because checks run per bar, ignore floating P&L (and swap), or don’t hard-block new orders. This module fixes that with an on-tick circuit breaker that measures combined daily P&L using server-midnight as the reset boundary.

CDailyPnlCalculator sums realized exits from deal history plus current position profit and swap, giving a true β€œtoday” exposure number every tick. When the limit is breached, the breaker closes all positions and removes all pending orders (using MqlTradeRequest actions), then enters a HALTED state until next server midnight.

A small API (Init/OnTick/IsHalted/GetStatus/ForceReset) makes integration predictable: gate every OrderSend with IsHalted. A chart dashboard and a verification script validate the math, reset timing, and formatting before deployment.

πŸ‘‰ Read | CodeBase | @mql5dev
❀25πŸ‘9πŸ‘Œ1
Bollinger Band mean-reversion works in ranges but fails systematically in trend formation. When ADX rises above 25 and bandwidth expands, band touches often precede breakouts, creating clustered losses under a fixed-rule strategy.

Meta-labeling splits direction from trade selection. A primary Bollinger signal provides side; a secondary classifier outputs {take, skip} plus a probability used for position sizing, with calibration required before bet sizing.

Secondary features include %B and normalized bandwidth, plus bandwidth momentum and a percentile-based regime flag with one-bar lag to prevent leakage. Deployment targets MQL5 via ONNX, using a two-EA file-bus and strict feature-order parity between Python and terminal.

πŸ‘‰ Read | Forum | @mql5dev
❀29πŸ‘12πŸ‘Œ3πŸ‘¨β€πŸ’»2