This article tackles two common failure modes in ML trading: noisy price-derived features that overfit, and equity curves dominated by a single instrumentโs regime.
It builds a Python+MT5 pipeline around a causal L1 Trend Filter solved with ADMM (banded O(N) iterations, adaptive rho, correct residual tracking). A sliding window makes the filter usable live, producing a piecewise-linear trend and explicit breakpoints.
Features come from trend geometry and indicators computed on the filtered series, with targets defined over a structural horizon (3 L1 segments) rather than fixed time. Models are trained per symbol with CatBoost and strict walk-forward (purge/embargo, internal early stopping).
Portfolio stability is improved by trading 29 instruments and sizing lots via 95% parametric VaR, allocating inversely to volatility and backtesting the weight...
๐ Read | VPS | @mql5dev
It builds a Python+MT5 pipeline around a causal L1 Trend Filter solved with ADMM (banded O(N) iterations, adaptive rho, correct residual tracking). A sliding window makes the filter usable live, producing a piecewise-linear trend and explicit breakpoints.
Features come from trend geometry and indicators computed on the filtered series, with targets defined over a structural horizon (3 L1 segments) rather than fixed time. Models are trained per symbol with CatBoost and strict walk-forward (purge/embargo, internal early stopping).
Portfolio stability is improved by trading 29 instruments and sizing lots via 95% parametric VaR, allocating inversely to volatility and backtesting the weight...
๐ Read | VPS | @mql5dev
โค13๐10๐ฅ6๐คฉ3
Volatility tools built on close-to-close returns discard intrabar dispersion. OHLC-based estimators reduce that loss and react faster to regime shifts, with direct impact on sizing, stops, and breakout timing.
The GarmanโKlass (1980) variance estimator uses ln(H/L)^2 plus a corrected ln(C/O)^2 term. It is theoretically more efficient than close-to-close under zero drift, but it ignores prior-close to current-open gaps, which can understate risk in instruments with frequent jumps.
Testing on synthetic GBM in Python showed materially lower MSE for GK, but also exposed a failure mode: GK-to-MA crossovers do not classify regimes. Percentile rank over a lookback window produced stable squeeze (<30th) to expansion (>60th) signals, filtered by a directional SMA.
In MQL5, correct series indexing, incremental recalculation, and storing recursive squeeze s...
๐ Read | Signals | @mql5dev
The GarmanโKlass (1980) variance estimator uses ln(H/L)^2 plus a corrected ln(C/O)^2 term. It is theoretically more efficient than close-to-close under zero drift, but it ignores prior-close to current-open gaps, which can understate risk in instruments with frequent jumps.
Testing on synthetic GBM in Python showed materially lower MSE for GK, but also exposed a failure mode: GK-to-MA crossovers do not classify regimes. Percentile rank over a lookback window produced stable squeeze (<30th) to expansion (>60th) signals, filtered by a directional SMA.
In MQL5, correct series indexing, incremental recalculation, and storing recursive squeeze s...
๐ Read | Signals | @mql5dev
โค16๐คฉ6๐ฅ5๐4
This article builds an MT5 โsignal routerโ that mimics discretionary filtering: a lightweight online classifier scores direction, Shannon entropy converts the score into uncertainty, then signals are auto-traded, skipped, or sent to a human review step. In Strategy Tester, the human step is replaced with deterministic proxies (always confirm/reject) or seeded randomness.
Key engineering choices: rolling online logistic regression with warm-start refits on a 300-bar window, careful no-leak label indexing, and a Pยฒ streaming quantile to keep a fixed review budget under distribution drift without storing all history. Execution code enforces broker constraints (stops/freeze, min lot, fill modes) and attributes PnL per decision tag.
Validation is treated as the core problem: thresholds are tuned on one window and judged on a held-out window against mult...
๐ Read | AppStore | @mql5dev
Key engineering choices: rolling online logistic regression with warm-start refits on a 300-bar window, careful no-leak label indexing, and a Pยฒ streaming quantile to keep a fixed review budget under distribution drift without storing all history. Execution code enforces broker constraints (stops/freeze, min lot, fill modes) and attributes PnL per decision tag.
Validation is treated as the core problem: thresholds are tuned on one window and judged on a held-out window against mult...
๐ Read | AppStore | @mql5dev
๐6๐คฉ6๐ฅ4โค3
State-space models formalize sequential data via latent states and an observation process. A categorical HMM is the discrete-state, categorical-emission case, with dynamics defined by a transition matrix and conditional independence of observations given the current state.
An MQL5 CCategoricalHMM implementation targets regime inference from event sequences such as candlestick colors. Core methods include forward-backward posterior inference, Baum-Welch EM training, Monte Carlo sampling, online Bayesian filtering, and model selection via AIC/BIC.
Training stability is handled with Bayesian pseudocount regularization for transition/emission matrices and Dirichlet-based random initialization to avoid zero-probability degeneracy. A two-die experiment (fair vs loaded) demonstrates state decoding, filtering vs smoothing behavior, and likelihood-driven parameter learning.
๐ Read | Signals | @mql5dev
An MQL5 CCategoricalHMM implementation targets regime inference from event sequences such as candlestick colors. Core methods include forward-backward posterior inference, Baum-Welch EM training, Monte Carlo sampling, online Bayesian filtering, and model selection via AIC/BIC.
Training stability is handled with Bayesian pseudocount regularization for transition/emission matrices and Dirichlet-based random initialization to avoid zero-probability degeneracy. A two-die experiment (fair vs loaded) demonstrates state decoding, filtering vs smoothing behavior, and likelihood-driven parameter learning.
๐ Read | Signals | @mql5dev
โค9๐6๐ฅ5๐จโ๐ป2๐คฉ1
Daily P/L by Magic Number renders account history and current open positions as a compact on-chart table, grouped by strategy magic number or an assigned name. Rows cover Today, Week, and Month results, with optional inclusion of floating P/L. Additional columns show current float, trades closed today, and DayDD (largest intraday drop from the dayโs peak while running). A TOTAL row aggregates all values, with green/red/grey color coding.
Designed for multi-EA accounts where a single balance curve hides attribution. It separates manual trading (magic 0), highlights abnormal losses or elevated DayDD early, and supports hedging or netting on any symbol/timeframe from a single chart.
Periods follow broker server time; weeks start Monday and months on the 1st. History is read from the earliest of the current week or month to limit load. Intraday drawdown combin...
๐ Read | NeuroBook | @mql5dev
Designed for multi-EA accounts where a single balance curve hides attribution. It separates manual trading (magic 0), highlights abnormal losses or elevated DayDD early, and supports hedging or netting on any symbol/timeframe from a single chart.
Periods follow broker server time; weeks start Monday and months on the 1st. History is read from the earliest of the current week or month to limit load. Intraday drawdown combin...
๐ Read | NeuroBook | @mql5dev
๐9โค8๐คฉ5๐ฅ4
Parameter searches can manufacture a positive Sharpe by selecting the best of many trials. The article quantifies this selection effect by rerunning the entire MT5-style development pipeline on bar-permuted EURUSD H1 data that preserves per-bar OHLC structure and drift but removes inter-bar predictability.
A 100-pair moving-average crossover search shows Sharpe 0.17 on real 2018โ2024 data, yet the same search on permuted bars produces a higher median Sharpe (~0.25). Across multiple parameter sets, the real outcome sits near the middle of the null distribution with non-informative p-values, indicating no measurable edge beyond what noise plus selection produces.
Key tooling includes full process permutation, spurious performance curves versus trial budget, distribution-free quantile confidence intervals, and cache-isolation checks to prevent stale artifa...
๐ Read | VPS | @mql5dev
A 100-pair moving-average crossover search shows Sharpe 0.17 on real 2018โ2024 data, yet the same search on permuted bars produces a higher median Sharpe (~0.25). Across multiple parameter sets, the real outcome sits near the middle of the null distribution with non-informative p-values, indicating no measurable edge beyond what noise plus selection produces.
Key tooling includes full process permutation, spurious performance curves versus trial budget, distribution-free quantile confidence intervals, and cache-isolation checks to prevent stale artifa...
๐ Read | VPS | @mql5dev
๐14โค9๐ฅ7๐คฉ5๐จโ๐ป1๐1
Part 5 packages the adaptive Parabolic SAR trailing stop as AdaptivePSARTrail.mqh, built for inclusion in existing MQL5 Expert Advisors. The module can trail positions it did not open, qualifying by symbol and magic number, while keeping its own SAR series and DivergenceEngine state.
Naive โset SL to last SARโ fails at SAR side flips and under broker constraints. The utility blocks wrong-side stops, enforces non-regression, and sequences checks for stop distance, freeze level, and tick grid to avoid silent stagnation and journal spam.
Integration is a four-call lifecycle: Init(cfg), Refresh() on new bars, ApplyToPositions() on ticks, and Deinit(). Trading calls are compile-guarded to allow indicator builds without CTrade. Acceleration adapts per bar using opposing divergence within a bar-age limit, with optional reset on trend change.
A demo EA runs...
๐ Read | Quotes | @mql5dev
Naive โset SL to last SARโ fails at SAR side flips and under broker constraints. The utility blocks wrong-side stops, enforces non-regression, and sequences checks for stop distance, freeze level, and tick grid to avoid silent stagnation and journal spam.
Integration is a four-call lifecycle: Init(cfg), Refresh() on new bars, ApplyToPositions() on ticks, and Deinit(). Trading calls are compile-guarded to allow indicator builds without CTrade. Acceleration adapts per bar using opposing divergence within a bar-age limit, with optional reset on trend change.
A demo EA runs...
๐ Read | Quotes | @mql5dev
๐9๐คฉ7โค6๐ฅ5๐5
Automated trading often stops without visible errors due to PC sleep, terminal disconnects, algo trading being disabled, profile changes, or an EA being removed from a chart. BotWatchdog is designed to detect these conditions and send push notifications to a phone. It does not place trades.
Alerts include broker connection lost or restored, algo trading switched off or on, watched EAs missing from all charts with a comma-separated name list, terminal login changed to an unexpected account, open positions without a stop-loss for N minutes, equity falling by a configured percentage from the dayโs starting balance, and margin level dropping below a defined threshold.
A daily scheduled โall OKโ heartbeat can be configured; if it does not arrive, the terminal or host PC is likely offline. A final alert is triggered if the watchdog is removed.
Setup requires en...
๐ Read | CodeBase | @mql5dev
Alerts include broker connection lost or restored, algo trading switched off or on, watched EAs missing from all charts with a comma-separated name list, terminal login changed to an unexpected account, open positions without a stop-loss for N minutes, equity falling by a configured percentage from the dayโs starting balance, and margin level dropping below a defined threshold.
A daily scheduled โall OKโ heartbeat can be configured; if it does not arrive, the terminal or host PC is likely offline. A final alert is triggered if the watchdog is removed.
Setup requires en...
๐ Read | CodeBase | @mql5dev
โค11๐ฅ10๐9๐คฉ4๐3
SessionEdgeTester checks whether a fixed intraday rule survives real broker costs using only the terminalโs H1 history. The test is run locally and places no trades, returning results in roughly 20 seconds.
The rule is simple: enter at a specified hour on selected weekdays, then exit after a fixed number of hours. Each simulated trade is charged the larger of 1.5x the live spread and the entry-bar spread, plus optional commission, plus live swap for each server midnight crossed, including triple rollover.
Time alignment supports server, New York, or London clocks with daylight saving handling, so the entry remains at the same local hour across GMT and New York-close brokers. An optional percentage stop-loss is evaluated using H1 highs/lows.
Reporting includes all trades, a split of the first 60% versus last 40% for an out-of-sample check, plus PASS/WATCH/F...
๐ Read | AlgoBook | @mql5dev
The rule is simple: enter at a specified hour on selected weekdays, then exit after a fixed number of hours. Each simulated trade is charged the larger of 1.5x the live spread and the entry-bar spread, plus optional commission, plus live swap for each server midnight crossed, including triple rollover.
Time alignment supports server, New York, or London clocks with daylight saving handling, so the entry remains at the same local hour across GMT and New York-close brokers. An optional percentage stop-loss is evaluated using H1 highs/lows.
Reporting includes all trades, a split of the first 60% versus last 40% for an out-of-sample check, plus PASS/WATCH/F...
๐ Read | AlgoBook | @mql5dev
โค14๐10๐คฉ9๐ฅ6๐2
Indicators recalculate on every tick, so a simple โprice > levelโ check can trigger the same popup continuously while the condition remains true. This also causes a burst of stale alerts when an indicator is attached, because historical bars are processed immediately.
AlertKit is a lightweight class that suppresses duplicates by sending a single alert per event name and bar. It maintains separate state per event string so buy and sell signals do not block each other, and it ignores anything earlier than the bar where tracking started. Output can be routed to popup, push, email, or sound, with an optional cooldown.
Testing is addressed via CSV logging. Since alerts do not fire in the strategy tester, AlertKit can record every decision, including rejected alerts and reasons. In one EURUSD H1 run (JunโAug 2026), 6,419 alert checks resulted in 27 alerts, with ...
๐ Read | Freelance | @mql5dev
AlertKit is a lightweight class that suppresses duplicates by sending a single alert per event name and bar. It maintains separate state per event string so buy and sell signals do not block each other, and it ignores anything earlier than the bar where tracking started. Output can be routed to popup, push, email, or sound, with an optional cooldown.
Testing is addressed via CSV logging. Since alerts do not fire in the strategy tester, AlertKit can record every decision, including rejected alerts and reasons. In one EURUSD H1 run (JunโAug 2026), 6,419 alert checks resulted in 27 alerts, with ...
๐ Read | Freelance | @mql5dev
๐คฉ16๐8โค6๐ฅ6๐1
Most VWAP tools reset per session, which limits usefulness on 24/5 markets. This implementation uses a rolling VWAP over a fixed bar count, sliding forward each bar to keep the anchor aligned with recent volume-weighted activity rather than a calendar boundary.
The close-to-VWAP deviation is normalized into a Z-Score using a rolling standard deviation of the same deviation series. This makes thresholds portable across instruments and volatility regimes, since the reading is expressed in standard deviations from rolling fair value.
Regime detection applies a two-step filter: the Z-Score must close beyond a configurable threshold and persist for N consecutive bars before switching state. The histogram mirrors the Z-Score but only changes color after confirmation, reducing noise-driven flips.
Key inputs include VWAP/StdDev periods (default 50), Z-Score...
๐ Read | Signals | @mql5dev
The close-to-VWAP deviation is normalized into a Z-Score using a rolling standard deviation of the same deviation series. This makes thresholds portable across instruments and volatility regimes, since the reading is expressed in standard deviations from rolling fair value.
Regime detection applies a two-step filter: the Z-Score must close beyond a configurable threshold and persist for N consecutive bars before switching state. The histogram mirrors the Z-Score but only changes color after confirmation, reducing noise-driven flips.
Key inputs include VWAP/StdDev periods (default 50), Z-Score...
๐ Read | Signals | @mql5dev
โค14๐คฉ5๐ฅ4๐3
TradeGuard separates execution safety from strategy logic. Strategy code decides what to trade and when; TradeGuard validates and normalizes every request to broker limits, retries only safe cases, blocks duplicate signals, isolates by symbol and magic, and rebuilds state after a restart. Delivery is a single include file with no DLL plus a Strategy Tester test suite.
Coverage includes permission and session checks, quote age and spread filters, margin and OrderCheck, volume/price/stop normalization, freeze level, filling mode, and expiration handling. Each request carries an intent key to ensure โone order per signalโ, including after VPS restarts, and uncertain server replies are verified on the server before any resend.
Verification data comes from a bundled suite: 83 unit tests passing, thousands of key checks, and large randomized โbad requestโ runs sh...
๐ Read | Signals | @mql5dev
Coverage includes permission and session checks, quote age and spread filters, margin and OrderCheck, volume/price/stop normalization, freeze level, filling mode, and expiration handling. Each request carries an intent key to ensure โone order per signalโ, including after VPS restarts, and uncertain server replies are verified on the server before any resend.
Verification data comes from a bundled suite: 83 unit tests passing, thousands of key checks, and large randomized โbad requestโ runs sh...
๐ Read | Signals | @mql5dev
โค10๐4๐คฉ3๐ฅ2
Position sizing logic converts stop distance and account value into an allowed loss and a lot size via a single static call. Calculation divides risk money by the 1-lot loss at the provided stop, normalises to volume step and symbol min/max, then optionally caps size to fit 70% of free margin using a buy-at-ask margin check.
Supported risk bases: fixed lot (stop ignored), percent balance, percent equity, and fixed cash amount. Percent modes compute risk money as account value times risk/100; fixed amount uses the value as-is.
A daily loss baseline is set on first call, logged, and reset on server day change. Breach is detected when equity drops by the configured percentage from that base; zero or negative inputs disable breaches. Baseline is in-memory only and resets on restart.
Edge cases return minimum lot silently on invalid inputs, which can exceed una...
๐ Read | AlgoBook | @mql5dev
Supported risk bases: fixed lot (stop ignored), percent balance, percent equity, and fixed cash amount. Percent modes compute risk money as account value times risk/100; fixed amount uses the value as-is.
A daily loss baseline is set on first call, logged, and reset on server day change. Breach is detected when equity drops by the configured percentage from that base; zero or negative inputs disable breaches. Baseline is in-memory only and resets on restart.
Edge cases return minimum lot silently on invalid inputs, which can exceed una...
๐ Read | AlgoBook | @mql5dev
๐ฅ1