MQL5 Algo Trading
568K subscribers
4.25K photos
7 videos
4.26K 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
ST-Expert reframes market forecasting as a regime-adaptive problem, addressing how correlation structures collapse during shocks like COVID-era shifts and policy cycles. Instead of fitting one stable dependency graph, it maintains multiple specialized โ€œexpertsโ€ that each represent a distinct market behavior.

Regimes are extracted by splitting history into time intervals that maximize structural dissimilarity using Kendallโ€™s tau, solved via dynamic programming (MSGD). Each interval trains an expert graphon: a probabilistic graph generator that models links between assets as connection probabilities, sampled with Gumbel-Softmax to reduce noisy edges.

Training uses episodic learning: one expert forecasts while a gating network learns to mix the remaining experts to reproduce the active regime. At inference, the gate weights experts from live signals,...

๐Ÿ‘‰ Read | Calendar | @mql5dev
โค20๐Ÿ‘4๐Ÿคฉ4๐Ÿ‘Œ2๐Ÿ”ฅ1๐ŸŽ‰1
This article builds an MQL5 dashboard to answer a practical question: how trade holding time relates to net profit in a specific account, beyond aggregate win rate.

A script extracts every closed trade, recovers true open time via position ID, computes duration in minutes, and calculates net P/L including swap and commission. Results are plotted as a CCanvas scatter plot (one dot per trade), colored by symbol, with a per-symbol summary table.

It overlays a least-squares regression (slope, intercept, Rยฒ) to quantify the overall duration-profit trend, and adds a simple short/medium/long bucket analysis to surface ranges that outperform even when a single line is misleading. A log-scaled duration axis keeps long-tail hold times readable while preserving โ€œprofit per minuteโ€ on linear data.

๐Ÿ‘‰ Read | NeuroBook | @mql5dev
โค13๐Ÿ‘8๐Ÿ”ฅ2๐Ÿ‘Œ2๐Ÿคฉ1
APARCH support is added to the MQL5 volatility library as CAparchProcess under CVolatilityProcess, targeting cases where fixing the power term delta constrains estimation. Standard ARCH-family models predefine the exponent, which can mask better-fitting transformations and interact with asymmetry terms.

APARCH jointly estimates delta with omega, alpha, beta, and gamma. Delta governs whether dynamics align closer to squared or absolute residuals, consistent with the Taylor effect evidence that intermediate powers often retain stronger autocorrelation than squares. Gamma is bounded in (-1, 1) to keep the shifted shock term valid under fractional powers.

Implementation details include VOL_APARCH registration, new ArchParameters fields (aparch_delta, aparch_common_asym), a dedicated aparch_recursion() using raw residuals, repacking logic for fixed delta or...

๐Ÿ‘‰ Read | AppStore | @mql5dev
โค14๐Ÿคฉ9๐Ÿ”ฅ7๐Ÿ‘4๐Ÿ˜1๐Ÿ‘Œ1
Market behavior rarely fits a single variable; meaningful models require joint distributions that capture how multiple assets and factors move together.

The article lays out multivariate CDF/PDF mechanics, emphasizing that marginals are only projections: knowing each seriesโ€™ standalone distribution cannot reconstruct dependence. Singular joint structures matter in practice because they reveal hard constraints, including deterministic links between instruments.

Dependence is formalized via factorization: independence holds only when the joint distribution equals the product of marginals, making conditional and unconditional distributions identical. This reframes independence as โ€œcontext adds no information.โ€

Conditional distributions lead directly to conditional expectation as the regression function. Many forecasting and ML models can be viewed as approxima...

๐Ÿ‘‰ Read | Calendar | @mql5dev
โค14๐Ÿ‘10๐Ÿ”ฅ8๐Ÿคฉ5๐Ÿ‘Œ1
Price windows can be compressed into fixed-length words to enable indexing and large-scale comparisons without revisiting raw series. SAX typically does this via z-normalization, PAA averages, and a shared Gaussian breakpoint table, but the bit budget wยทlog2(a) is rarely evaluated for efficiency.

SFA replaces PAA with low-frequency DFT coefficients and replaces the shared bin table with Multiple Coefficient Binning, learning per-position quantiles so each letter is used. This avoids collapsing low-variance coefficients into a single symbol and supports three bin modes, including a Gaussian ablation.

A full similarity harness compares MinDist, ApproxDist, and TrueDist, validating a sound lower bound with the required factor-of-two from conjugate symmetry. Results show SFA gains when the alphabet is deep over few positions, shrinking as bits spread across many po...

๐Ÿ‘‰ Read | Freelance | @mql5dev
โค17๐Ÿ‘13๐Ÿ”ฅ12๐Ÿคฉ7โœ1๐Ÿ‘Œ1
Impulse candles can be formalized instead of identified visually. This indicator flags momentum bars with fixed rules and draws arrows: green below bullish impulses and red above bearish impulses.

A bar is marked when its body is at least ATR(InpAtrPeriod) * InpImpulseAtrMult, the body is at least InpMinBodyRatio of the full range, and the close is located in the top or bottom segment of the bar based on InpMinCloseLoc. Optional confirmation requires tick volume to exceed InpVolumeMult times the average of the prior InpVolumePeriod bars.

Signals are stable after close because calculations use only the current bar. The active bar can repaint until it closes; automation should read shift 1. For EAs, buffer 0 is bullish and buffer 1 bearish; non-zero values hold the arrow price via iCustom/CopyBuffer.

Defaults target M1โ€“M15 on volatile symbols. On H1+ ...

๐Ÿ‘‰ Read | Freelance | @mql5dev
๐Ÿ‘17โค13๐Ÿคฉ12๐Ÿ”ฅ8๐Ÿ‘จโ€๐Ÿ’ป3๐Ÿ‘Œ2
Stormbreaker ADX is an MT5 Expert Advisor that trades only on completed candles, combining a Supertrend trend filter with ADX strength and the +DI/โˆ’DI relationship. Signals are evaluated once per new H4 bar using the previous barโ€™s indicator values, then orders are sent with an ATR-derived stop.

Default parameters use Supertrend ATR(10) factor 3.0, ADX(14) with entry at 23 and exit at 18. Buy requires bullish Supertrend, ADX โ‰ฅ 23, and +DI > โˆ’DI. Sell requires bearish Supertrend, ADX โ‰ฅ 23, and โˆ’DI > +DI. Exits occur on ADX < 18, Supertrend reversal, or an opposite qualifying signal; no fixed take-profit is used.

Position sizing targets 0.5% equity risk via OrderCalcProfit against the proposed stop, with volume rounded to broker steps and margin checked. Realized risk can differ due to spread, gaps, and execution. The source is provided for testing and modificatio...

๐Ÿ‘‰ Read | NeuroBook | @mql5dev
๐Ÿ‘22โค21๐Ÿ”ฅ13๐Ÿคฉ8โšก2๐Ÿ‘Œ1
The updated MT5 walk-forward auto-optimizer focuses on speed, multi-asset runs, and lower memory usage by removing mutex-based report generation and reducing expensive file operations.

A new date auto-complete window splits a chosen period into alternating historical and forward windows: historical ranges can overlap, forward ranges are continuous, and both use fixed step sizes. The calculation is isolated behind a singleton data model and event-driven updates, with tools to bulk-clear and reapply ranges via a sub-window wrapper.

ReportManager.dll adds a user-defined optimization coefficient, keeps compatibility with older reports, and extends sorting options. On the MQL5 side, robots can supply this coefficient via a callback passed into the uploader.

Report export is accelerated by buffering passes in C# and writing the full report in one shot, ...

๐Ÿ‘‰ Read | Forum | @mql5dev
โค56๐Ÿ”ฅ16๐Ÿ‘14๐Ÿคฉ7โšก3๐Ÿ†2๐Ÿ‘€1
Inversion Fair Value Gaps adds automated fair value gap detection with bar-close confirmation and no repaint behavior.

Gaps are tracked until a candle body closes through the zone, marking an inversion event. After inversion, the tool monitors for bounce reactions off the inverted area and generates signals.

Options include a midline, filled-zone removal, and adjustable color settings for zones and markers. Alert routing is supported via popup, sound, push notification, e-mail, and Telegram.

๐Ÿ‘‰ Read | Docs | @mql5dev
โค31๐Ÿ‘16๐Ÿ”ฅ9๐Ÿคฉ9โœ8๐Ÿ‘จโ€๐Ÿ’ป4๐Ÿ‘2
Entry/exit points remain the core problem in algorithmic trading because recognizable patterns are usually visible only after the move. Trend and flat regimes are easy to label visually, but unreliable as predictive signals without quantified probabilities.

Price formation can be described via market vs limit orders. Limit orders populate the order book, market orders consume it. Spread is the gap between best bid/ask. Stop Loss/Take Profit placement creates distributed trigger levels that can amplify acceleration or reversal.

From a probabilistic view, discrete ticks imply a random process where expected payoff for random entries converges to zero, excluding spread. Expected value and profit factor can be expressed through conditional events: closing by stops vs signals, with nested probabilities per stop configuration.

Regime detection can be fr...

๐Ÿ‘‰ Read | AlgoBook | @mql5dev
โค68๐Ÿ‘23๐Ÿ”ฅ14๐Ÿคฉ10๐Ÿ‘€7๐Ÿ‘Œ5๐Ÿ‘จโ€๐Ÿ’ป1
ZoneUS30 is a simplified Expert Advisor focused on the US30 index and limited to SELL-only execution. The logic targets overextended upside moves where price may revert toward a prior reference area, triggering entries when internal conditions align.

The model combines mean-reversion behavior with the practical impact of swap. When a broker pays positive overnight swap on US30 shorts, holding positions across multiple sessions can add carry while waiting for a correction, without treating swap as the primary edge.

Trading is closer to swing or position holding than scalping, with some trades lasting days. The public build exposes only two inputs: lot size and the signal timeframe; remaining parameters are fixed.

Key risk: this is counter-trend selling in strong uptrends, with potential for extended adverse movement. Swap terms can change by broker rules an...

๐Ÿ‘‰ Read | CodeBase | @mql5dev
โค31๐Ÿ‘7๐Ÿ”ฅ5๐Ÿคฉ3โšก2๐Ÿ‘Œ2
RSI Exhaustion Reversal - EURUSD is an open-source MQL5 Expert Advisor built for strategy research, historical testing, and education. It is restricted to the MetaTrader 5 Strategy Tester and will not place trades when attached to a regular chart. Full source code is included for inspection and modification.

The strategy targets EURUSD on M5 with SELL-only logic. It watches RSI(14) for an overbought exhaustion condition around level 65 during the 14:00โ€“18:00 broker/server-time session. Before entry, spread is checked against volatility using a max Spread/ATR ratio of 0.15.

Risk controls use ATR(14) to size SL and TP at 4x ATR, cap position duration to 96 candles, and enforce a single concurrent position. User inputs are limited to internal timeframe, fixed lot size, and magic number.

Backtests are recommended on real ticks where available; results vary by broke...

๐Ÿ‘‰ Read | VPS | @mql5dev
โค16๐Ÿ‘10๐Ÿ”ฅ4๐Ÿคฉ4๐Ÿ‘Œ1๐Ÿ‘จโ€๐Ÿ’ป1
An Adaptive Kalman Trend Filter indicator is designed to reduce short-term price noise and present a clearer view of the underlying trend. It applies Kalman-style state estimation to smooth input data while retaining enough responsiveness to reflect meaningful movement.

The adaptive component modifies the filterโ€™s sensitivity as volatility and market structure change. In lower-noise phases it can prioritize smoothness; during faster moves it can react sooner to shifts in direction.

Typical usage focuses on trend bias, momentum change points, and timing confirmations when combined with risk rules and other signals. As with any filter, parameter selection and out-of-sample checks remain critical to avoid overfitting.

๐Ÿ‘‰ Read | Signals | @mql5dev
โค24๐Ÿ”ฅ5๐Ÿคฉ4๐Ÿ‘2๐Ÿ‘Œ2๐Ÿ‘จโ€๐Ÿ’ป1
A specification panel reflects the brokerโ€™s current contract report. Broker Contract Change Watch logs when selected contract properties differ from the last saved observation, with a baseline stored per account server, login, and chart symbol.

Watched fields include digits, point size, minimum tick, contract size, volume min/max/step and directional limit, stops and freeze levels. It also tracks trading and execution modes, filling flags and allowed order flags, plus swap mode, long/short swap values, and the triple-swap weekday.

After reattachment or terminal restart, the next valid observation is compared to the saved baseline. A compact panel shows the latest change, volume settings, and stop restrictions. CSV output records local time, property, previous value, and new value. Spread and currency-converted tick value are excluded to avoid routine marke...

๐Ÿ‘‰ Read | CodeBase | @mql5dev
โค17๐Ÿ‘7๐Ÿคฉ3๐Ÿ”ฅ2๐Ÿ‘Œ1
MetaTrader 5 EAs often keep critical strategy state only in RAM (grid depth, recovery steps, daily counters, online-trained model weights). After a terminal restart, the EA can mismanage existing positions because its internal context is gone.

A common persistence bug is overwriting the live state file: a crash mid-write truncates it, leaving โ€œvalid-lookingโ€ but wrong data. The proposed fix is atomic-style saving: write to a temporary file, flush/close it, then replace the live file using FileMove, without DLLs.

To detect silent damage from edits or partial copies, the file includes a header with a magic identifier, a format version, and a checksum. On load, the store rebuilds a canonical body and verifies the checksum, returning an empty state if integrity fails.

Beyond scalars, the utility persists double arrays, making it practical to restore rolling statisti...

๐Ÿ‘‰ Read | Forum | @mql5dev
โค14๐Ÿ‘6๐Ÿคฉ3๐Ÿ‘Œ1
Refactor proposal for MQL5 divergence logic: extract oscillator, pivot detection, divergence classification, and state tracking from Adaptive SuperTrend into a reusable header, DivergenceEngine.mqh.

The module owns settings, optional RSI handle, buffers, and state (last pivots, divergence type, bars-since). Public access stays narrow: last divergence type, age, oscillator value, reset, and required lookback.

Integration pattern stays consistent across indicators and EAs: init engine, compute lookback, resize buffers, seed boundary at limit+1, refresh RSI buffer if selected, run a backward per-bar loop calling CalculateOscillator and DetectDivergence, then query and act outside the engine, and release on deinit.

Demonstration case uses Parabolic SAR: adapt its Acceleration Factor when an opposing divergence is recent, highlighting reuse without coupling to ...

๐Ÿ‘‰ Read | AlgoBook | @mql5dev
โค13๐Ÿ‘5๐Ÿ”ฅ2๐Ÿคฉ2
ST-Expert reframes forecasting as a spatiotemporal problem: price history plus a dynamic network of cross-asset links. Using a Mixture of Experts, it shifts weight between specialist blocks as market drivers change, improving resilience, and exposing which relationships influenced a signal.

The article moves from concept to MQL5 implementation by integrating ST-Expert components into Extralongerโ€™s three-route Transformer (temporal, spatial, mixed). A key idea is replacing classic Self-Attentionโ€™s Query/Key logits with a graphon-derived connectivity graph, keeping only Value paths.

A new CNeuronGraphAttention module builds attention from ST-Expert graphs, applies SoftMax to produce interpretable weights, and uses residual paths to retain contextโ€”aiming for fewer noise-driven signals when correlations break or rotate.

๐Ÿ‘‰ Read | Docs | @mql5dev
โค8๐Ÿ‘4โšก1๐Ÿ”ฅ1๐Ÿคฉ1
Media is too big
VIEW IN TELEGRAM
With Model Context Protocol (MCP), AI can work directly with MetaTrader 5 data and tools โ€” turning the built-in AI Assistant into an agent capable of handling complex, multi-step tasks.

Analyze markets and trading history, review open positions, work with charts, test and optimize Expert Advisors, and perform supported trading operations โ€” all through natural-language instructions.

Instead of manually collecting data and switching between tools, simply describe what you want to achieve and let the AI Assistant coordinate the necessary steps.

Watch the video to see how MCP works in MetaTrader 5 and explore practical AI workflows for trading, analysis, and algorithmic development.

Discuss the video:
๐Ÿ‘‰ MQL5.community for traders
๐Ÿ‘‰ MetaQuotes official YouTube channel
โค17๐Ÿ‘4๐Ÿ”ฅ4๐Ÿคฉ4
Running one strategy across multiple symbols and hours creates separate variants, and account-level metrics can hide where performance differs. A dashboard script addresses this by grouping closed deals by symbol and UTC closing hour, then computing win rate and payoff-based edge ratio per cell.

The pipeline reduces each deal to symbol, close-hour, and net profit, aggregates into symbol-hour cells, and renders two CCanvas heatmaps: win rate and edge ratio. Undefined ratios (all wins or all losses) are explicitly flagged and shown as neutral cells, not zero.

Breakeven deals count toward volume but are excluded from win/loss buckets to avoid ratio distortion and divide-by-zero. An Experts-tab table lists best and worst symbol-hour combinations by win rate with minimum-trade filtering. Limitations include linear scans, fixed color boundaries, server-time a...

๐Ÿ‘‰ Read | AppStore | @mql5dev
โค10๐Ÿ‘4๐Ÿคฉ2๐Ÿ”ฅ1๐Ÿ‘€1
Adaptive EA design using random graph theory instead of a fixed market map.

A state-transition network encodes each closed bar via EMA spread/ATR, ATR regime, and optional RSI buckets, producing 45 states. Transitions update a decayed, Laplace-smoothed Markov matrix. A k-step matrix power yields the distribution k bars ahead, converted into a bounded directional expectation plus an entropy-based confidence gate.

A second outcome graph manages exits as an R-multiple random walk across milestones. Smoothed survival probabilities trigger closes when the next hop becomes unlikely.

A structural filter binarizes edges above a uniform baseline, measures clustering, then compares it to an Erdosโ€“Renyi G(n,p) null via z-score. Near-zero separation is treated as a โ€œstay flatโ€ condition.

๐Ÿ‘‰ Read | AppStore | @mql5dev
โค9๐Ÿ‘2๐Ÿคฉ2
Markov chains offer a practical way to model market uncertainty by turning price behavior into discrete states and estimating transition probabilities between them. The key constraint is โ€œmemorylessnessโ€: forecasts depend only on the current state, which can still work well for changing, nonstationary conditions.

The article shows two implementations: a simple 3-state regime model (down/flat/up) using a transition matrix, and a richer chain built from price differences bucketed into multiple states. Forecasts can be generated step-by-step via vectorโ€“matrix multiplication, with accuracy degrading as multi-step probabilities flatten.

It also extends beyond forecasting: a 2-state win/loss chain updates in real time to adjust expected value and win probability after each trade, enabling adaptive position sizing and risk-aware scenario planning in MT5 s...

๐Ÿ‘‰ Read | Freelance | @mql5dev
โค3