MQL5 Algo Trading
507K subscribers
3.36K photos
3 videos
3.36K 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
Financial ML pipelines leak information because labels overlap in time and regimes change, so classic train/validate/test splits overstate performance. This design blocks leakage with a strict 60/20/20 temporal partition: an outer-training zone for all iteration, an inner-validation checkpoint for accept/reject, and a final test opened exactly once via a programmatic gate.

Hyperparameters are chosen inside nested CV using PurgedWalkForwardCV (purging + embargo) and Masters’ 1-SE rule, selecting the simplest configuration statistically tied with the best. The outer loop then estimates performance on folds the search never sees, supporting both walk-forward and CPCV, with careful index handling.

Probability calibration is done correctly using out-of-fold predictions generated after selection, fitting isotonic calibration only on predictions from models that never t...

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #AI
❀35πŸ‘9πŸ‘Œ1πŸ‘€1
A utility script can be used to display full trading account information in one place, including balances, equity, margin figures, account currency, leverage, and server identifiers. This helps reduce manual checks and supports faster validation during setup and support cases.

Operational guidance is required before deployment. If account information is restricted or unavailable for a client, the script may fail or return partial fields depending on permissions and broker settings.

Email handling should be defined explicitly. Decide whether the email is added as an input parameter, read from platform settings, or stored in an external config, and ensure no sensitive account data is sent without consent and audit logging.

πŸ‘‰ Read | Forum | @mql5dev

#MQL4 #MT4 #script
❀17πŸ‘2πŸ‘Œ1
Retail momentum tools such as MACD and RSI are constrained by their moving-average design. Any averaging process requires past samples, which introduces persistent phase lag. By the time a reversal signal prints, faster execution systems have often already reduced exposure, leaving late liquidity to absorb the shift.

Some proprietary approaches model price as a kinematic series using discrete derivatives rather than smoothed oscillators. First derivative estimates provide velocity (dP/dt). Second derivative estimates provide acceleration (dV/dt), tracking how quickly velocity is changing.

A common exhaustion condition appears when acceleration turns negative while velocity remains positive. This configuration indicates weakening impulse before price direction changes. In automation, acceleration can be used as a gating filter to block breakout ent...

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀15πŸ‘3πŸ‘Œ1πŸ‘€1
This article builds a real-time flag pattern detector for MetaTrader 5 that replaces visual guesswork with repeatable rules. It validates continuation flags using ATR-normalized pole strength, capped retracement, bounded consolidation length, and breakout confirmation, while rejecting weak or overlapping setups.

The MQL5 design is fully graphical: no indicator buffers, only chart objects. Once confirmed, it draws the pole, an adaptive slanted channel from internal highs/lows, a shaded consolidation box, breakout arrow, and labels, with optional alerts.

Efficiency comes from a two-phase OnCalculate flow: one-time historical scan, then incremental updates using prev_calculated, tracking forming patterns separately from already-drawn ones to keep charts clean and processing fast on lower timeframes.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #Indicator
❀20🀩2✍1πŸŽ‰1πŸ‘Œ1
MMAR volatility forecasting pipeline applied to EURUSD 5-minute data moves from fitted multifractal parameters into a full compound process X(t)=B_H[theta(t)]. The build combines a multiplicative cascade for multifractal trading time and Davies-Harte FBM for long-memory increments, with interpolation used to evaluate FBM on the deformed time grid.

Forecasting uses 1,000 Monte Carlo runs, regenerating cascade and FBM each time, then aggregating horizon volatility with mean, dispersion, and confidence bounds. Cascade depth is selected as k=ceil(log2(forecast_length+1)) and output is truncated to the required horizon.

A baseline GARCH(1,1) is fit on identical training data via arch with rescale enabled. Multi-step comparison follows simulation-based forecasting (ugarchsim-style) to match MMAR’s horizon statistic, then both are evaluated against realized ...

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀32πŸ‘Œ1
Manual multi-timeframe checks in Market Watch require repeated chart switching and subjective scoring. At scale, the workflow becomes slow and inconsistent, with missed alignment signals across symbols and timeframes.

CMultiTimeframeMatrix provides a deployable dashboard for MT5: a symbols x timeframes matrix with per-cell composite scoring (trend slope + momentum – volatility) scaled near [-100, +100]. Blue/red intensity reflects bullish/bearish bias, while the numeric score remains visible.

Delivered as a reusable .mqh module plus a thin host EA. Updates run on a timer with differential refresh, re-entrancy protection, performance warnings, and an β€˜M’ hotkey to toggle visibility.

πŸ‘‰ Read | Freelance | @mql5dev

#MQL5 #MT5 #EA
❀29πŸ‘10πŸ‘Œ1
Tool placement on MetaTrader 5 charts typically ends with limited cursor feedback and no fast inspection path for dense price action. Default crosshair behavior is fixed and lacks magnification and measurement support.

Part 32 adds a crosshair manager for MQL5 sidebars: layered reticle ticks, full-width/height lines, and axis labels that report exact time and price. A circular magnifier renders zoomed candles, wicks, bid/ask lines, and a local price label without changing chart zoom.

Double-click enables measure mode with an anchor, diagonal connector (Bresenham), and live stats for bars, pips, and raw price delta. The system uses eleven new canvases, hides on sidebar hover, and refreshes cleanly on theme and tool changes.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀21πŸ‘¨β€πŸ’»4✍1πŸ‘Œ1
MetaTrader 5 custom symbols shift charts from broker-defined timeframes and quote feeds to locally managed market data. A custom symbol is a terminal object with its own tick history, contract specification, and Strategy Tester support, stored under the terminal’s Custom base directory and separated in Market Watch.

Core MQL5 APIs cover lifecycle (CustomSymbolCreate/Delete, SymbolSelect), history writes (CustomTicksAdd/Replace, CustomRatesUpdate), and contract properties (CustomSymbolSet*). Limitations include no MQL5 Cloud optimization, dependency on cross rates for margin/profit, and fixed symbol properties during a test run.

Typical uses include time-independent bars (Renko, Range, Equal-Volume) built via tick aggregation and written with CustomRatesUpdate plus tick emulation, and synthetic instruments (spreads, baskets) requiring tick synchroni...

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀35πŸ‘3πŸ‘Œ1
John Ehlers documented the Hilbert Oscillator in Rocket Science For Traders (pp. 90–91). The indicator is commonly used to flag major turning points by analyzing the relationship between two plotted lines.

A typical interpretation is trend confirmation on crossovers: when the blue line crosses above the red line, an uptrend bias is indicated; the reverse crossover signals a potential downtrend bias.

The MetaTrader 5 implementation adds zero-line color states for immediate signals. A green state above the zero line is treated as a buy condition, while a red state below the zero line is treated as a sell condition.

The MetaTrader 4 variant is not included. Source code and the download are distributed via a Telegram channel referenced in the profile.

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #Indicator
❀31πŸ‘Œ4πŸ‘3
MetaTrader 5 optimizations often mislead by rewarding a single best pass. A sharp peak in Profit Factor or Sharpe can be pure curve-fit; robust systems show a plateau where nearby parameter values stay acceptable. The goal shifts from β€œbest number” to understanding the full optimization surface: sensitivity, degradation rate, and stable zones.

Optimization Frames turn the tester into a telemetry pipeline. Each pass can send custom metrics from OnTester via FrameAdd, then be parsed in OnTesterPass or reliably reprocessed in OnTesterDeinit, even with delayed batches from distributed agents.

A simple, event-driven EA (EMA crossover gated by RSI mode-change events, ATR-based SL/TP) keeps the surface interpretable. Frames log internal quality metrics like trigger-to-trade conversion and profit per signal, then export to CSV for Python analysis (pivot ta...

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀38πŸ‘11⚑3πŸ‘Œ3🀨3
A moving average bands width metric can be used to monitor volatility conditions. The indicator focuses on band width rather than price direction, treating contraction and expansion as volatility signals.

This implementation adds one visual change: periods when band width reaches extreme lows are highlighted in red. These low-width zones can flag unusually compressed conditions, where volatility expansion may follow.

Practical use is non-directional. It can support trade context by identifying congestion, then monitoring for potential trend change after compression, or trend continuation when a range resolves into a directional move.

πŸ‘‰ Read | Calendar | @mql5dev

#MQL5 #MT5 #Indicator
❀29πŸ‘Œ2
DoEasy library tick support moved from single tick objects to per-symbol tick series lists, with default retention set to the current day and an option to store multiple days. Lists are intended for faster search, comparison, and repeated access than ad-hoc CopyTicks calls.

Core updates include new library messages, a retention-days constant, and a fix in the timeseries code path to delete bar objects when insertion fails to prevent leaks. Select.mqh gained tick-oriented search/sort helpers and overloads to fetch ticks by index, time, or millisecond timestamp.

A new tick series class builds an array-backed list of tick objects, loads history via CopyTicksRange() from the computed day boundary, and supports queries such as highest Ask and lowest Bid. Next step is a multi-symbol tick collection with real-time list updates.

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀39πŸ‘4πŸŽ‰2πŸ‘Œ2
An updated Moving Average Bands variant has been published with clearer, signal-oriented behavior. The extension adds a practical ruleset that derives trade signals directly from band values, making the use case more explicit than the earlier release.

The recommended workflow uses band color changes as an actionable state indicator. These transitions can be mapped to initial entries, re-entries after pullbacks, and early exit candidates when conditions reverse.

This approach keeps the logic on-chart and reduces reliance on external filters, while remaining transparent enough to audit and adjust for different instruments and timeframes.

πŸ‘‰ Read | Freelance | @mql5dev

#MQL5 #MT5 #Indicator
❀65πŸ‘13πŸ‘Œ5🀝2
Raw forex and futures prices are non-stationary, so standard regression/classification models trained on levels tend to produce spurious relationships and look-ahead issues. Integer differencing forces stationarity but removes much of the dependence structure that ML features often rely on.

Fixed-width fractional differencing (FFD) uses a non-integer order d in (0, 1) to reach stationarity while retaining as much memory as possible. Weights follow the recurrence w[0]=1, w[k]= -w[k-1]*(d-k+1)/k and stop once |w[k]| falls below a threshold, then apply a reversed dot product over a log-price lookback window.

A production-focused MQL5 implementation is provided: a header-only CFFDEngine with Init(), Compute(), and ComputeBuffer() with prev_calculated optimization, plus an indicator wrapper supporting all applied price types. No dynamic allocation occurs after ...

πŸ‘‰ Read | Signals | @mql5dev

#MQL5 #MT5 #Indicator
❀34πŸ‘6πŸ‘Œ6πŸŽ‰1
Seasonality is measurable recurring price behavior driven by calendar effects and market structure. It is most visible in commodities, but it also appears in FX and equity indices. A practical implementation in MetaTrader 5 uses MQL5 to score seasonality quality for a single symbol or a two-instrument spread.

Spread trading combines long/short exposure on related instruments to target relative price moves. The SpreadMultiYearComparison indicator computes a spread as the difference of the two opens, with optional weighting coefficients to align tick values and quote scales.

Methodology relies on 10–15+ years of D1 history, analyzing one selected month across years. A pattern is treated as actionable when direction repeats in ~70–75% of years and results are not dominated by outliers. The tool outputs year-by-year month returns, an average curve, and a...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Indicator
❀30πŸ‘Œ4✍2πŸ‘2
Part 2 extends the defensive foundation with long-memory measurement on NQ M1 using a robust Hurst workflow.

Three estimators are implemented and blended: classical R/S (Hurst 1951, with Lo 1991 bias considerations), aggregated variance, and absolute moments. Each produces H plus a confidence weight based on valid log-log regression points; low-confidence outputs are excluded.

Four functions are added to MicroStructure_Foundation.mqh: HurstExponentRS(), AdvancedHurstExponent(), HurstExponentRobust(), and PopulateHurstAnalysis(). Results write into RobustFractalAnalysis without new includes. HurstProfile.mq5 plots H*(t), confidence, and a regime buffer.

An empirical run over 133 NQ Globex sessions (Nov 2025–May 2026) shows H*(t) near 0.47–0.50, requires ~40 post-open bars to activate, and breaks if pre-open/post-open data are mixed. Predictive power ...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Indicator
❀24πŸ‘10πŸ‘Œ2
Live trading controls often split across symbol filters, session rules, news blackouts, and daily limits. When manual orders and multiple EAs share a terminal, inconsistent enforcement becomes likely.

A unified discipline framework centralizes validation in CDisciplineEngine.mqh. It acts as a single gate for IsTradeAllowed(), synchronizes rule state, and exposes monitoring data shared by both EA and dashboard.

Architecture is layered: external configuration files, the engine, a chart dashboard, and EA integration. The engine checks whitelist, trading hours, news state, and daily trade counts, then records executed trades for accurate limits.

The dashboard visualizes engine state only. The enforcement EA uses timers to keep positions compliant and avoids duplicating rule logic.

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀41πŸ‘8πŸ‘Œ3😁2πŸŽ‰2
A custom MACD indicator adds a full three-part view in a separate window: a color-coded histogram plus the MACD and Signal lines. This differs from common default layouts that emphasize the histogram only, improving visibility of momentum shifts and line crossovers.

Histogram coloring reflects the zero level: Green when MACD is above 0 and Salmon when below 0. This makes bias changes and zero-line transitions easier to spot at a glance.

Key components include the MACD line (Fast EMA minus Slow EMA), the Signal line (moving average of MACD), and the histogram. Inputs cover Fast/Slow periods (12/26), Signal period (9), selectable Signal MA method (SMA, EMA, SMMA, LWMA), and applied price (default Median).

Typical use cases: zero-line changes for momentum regime shifts, MACD/Signal crossovers for entries/exits, and classical divergence detection. Suitable ...

πŸ‘‰ Read | Freelance | @mql5dev

#MQL5 #MT5 #Indicator
❀25πŸ‘6✍5πŸ‘Œ2
A signal-generation library is available for detecting when market price reaches predefined channel boundaries, rather than triggering on subjective β€œnearby” conditions.

The engine tracks two quantified phases: percentage proximity to a channel line, followed by a percentage reversal from the extreme boundary. A state machine enforces these rules consistently to reduce discretionary interpretation.

Signals do not forecast direction. They flag a boundary-touch event that often marks a decision point, where price either respects the level (validating it as support/resistance) or breaks through with momentum.

The approach is channel-agnostic and can be applied to any channel definition. A common implementation uses the Donchian channel.

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀18πŸ”₯7πŸ‘3πŸ‘Œ3
When strategy optimization exceeds 10+ parameters, tester reports become high-noise datasets. Tables, flat charts, and 2D heatmaps stop scaling, and correlations across period, stop-loss, volatility, and drawdown become hard to validate.

MetaTrader 5 uses DirectX 11 in MQL5 via CDXCanvas and CChartObjectDX. Shaders and textures load from Files\DX\ without external libraries, C++ wrappers, or dependency management. The goal is analytical reduction of cognitive load, not decoration.

3D is justified when a metric depends on two or more continuous variables and geometry matters. Typical cases include optimization landscapes (plateaus vs narrow maxima), regime clustering as a rotatable point cloud, and stress tests mapping parameter vs stress level vs robustness metric.

Core implementation points include canvas initialization, projection setup, vertex...

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀22πŸ‘8πŸ‘€3
Part 3 ported Python get_time_features into MQL5 as CTimeFeatures.mqh, producing a flat double array with Python-identical feature order and names for direct OnnxRun input.

Key MQL5 issues addressed: broker time vs UTC, incremental rolling volatility, and a timeframe-driven frequency gate that must match the feature-name registry. UTC is derived once at init via TimeCurrent()-TimeGMT(); this fixes systematic session misclassification but cannot track mid-run DST shifts.

Architecture: CTimeFeatures exposes Initialize/Update/Calculate, backed by CRingBuffer for population std (ddof=0) and forward-filled session/calendar vol. Session detection handles cross-midnight Sydney via OR logic. Day-of-week and day-of-year are re-indexed to match pandas conventions.

Frequency gating uses PeriodSeconds to support custom periods; calendar flags appear only for D...

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #AITrading
❀20πŸ‘5πŸ‘Œ2