MQL5 port of four bet-sizing methods lands with a five-file stack designed for a tick-driven EA without NumPy/SciPy.
BetSizingUtils.mqh adds missing statistical primitives: normal CDF/ICDF via Hart minimax rational approximation, raw-moment computation, shared structs, plus an O(N log N) sweep-line counter to replace O(Nยฒ) overlap scans for concurrent positions. AvgActiveSignals remains O(Nยฒ) by necessity when averaging signal values across active intervals.
Sizing methods map to include files: probability sizing (z-score, averaging, discretization), dynamic forecast-price sizing (sigmoid/power, closed-form calibration, limit price via inverse sizing), budget sizing (exposure normalization with seeded running maxima), and reserve sizing using EF3M-3 mixture fitting from three moments with multi-start analytic solves and log-likelihood selection. Output...
๐ Read | Signals | @mql5dev
#MQL5 #MT5 #AlgoTrading
BetSizingUtils.mqh adds missing statistical primitives: normal CDF/ICDF via Hart minimax rational approximation, raw-moment computation, shared structs, plus an O(N log N) sweep-line counter to replace O(Nยฒ) overlap scans for concurrent positions. AvgActiveSignals remains O(Nยฒ) by necessity when averaging signal values across active intervals.
Sizing methods map to include files: probability sizing (z-score, averaging, discretization), dynamic forecast-price sizing (sigmoid/power, closed-form calibration, limit price via inverse sizing), budget sizing (exposure normalization with seeded running maxima), and reserve sizing using EF3M-3 mixture fitting from three moments with multi-start analytic solves and log-likelihood selection. Output...
๐ Read | Signals | @mql5dev
#MQL5 #MT5 #AlgoTrading
โค29
A MetaTrader 5 canvas butterfly curve renderer is extended from a four-segment anti-aliased outline to a full illustration with wing fills, texture, and anatomical body details. Rendering remains based on precomputed parametric points mapped to pixel space and processed through the same supersampled pipeline.
Wing interiors are filled via scanline polygon rasterization with a nonzero winding rule to handle self-intersections. Three layers are added: outer vertical gradient, an inward-scaled vertical gradient, and an innermost inward-scaled radial gradient. Veins are rendered as thin anti-aliased lines from the curve origin to sampled boundary points.
Scale texture is added using dense boundary sampling and small filled circles, colored per parametric segment via t ranges (3ฯ, 6ฯ, 9ฯ), then slightly brightened toward edges. The body is composed fro...
๐ Read | CodeBase | @mql5dev
#MQL5 #MT5 #AlgoTrading
Wing interiors are filled via scanline polygon rasterization with a nonzero winding rule to handle self-intersections. Three layers are added: outer vertical gradient, an inward-scaled vertical gradient, and an innermost inward-scaled radial gradient. Veins are rendered as thin anti-aliased lines from the curve origin to sampled boundary points.
Scale texture is added using dense boundary sampling and small filled circles, colored per parametric segment via t ranges (3ฯ, 6ฯ, 9ฯ), then slightly brightened toward edges. The body is composed fro...
๐ Read | CodeBase | @mql5dev
#MQL5 #MT5 #AlgoTrading
โค27๐2
Trading losses often come from trading at the wrong time: low-liquidity hours and scheduled news can invalidate otherwise solid entries via spread expansion, slippage, and regime shifts. This system turns โdisciplineโ into enforceable rules by blocking execution outside defined sessions and during configurable pre/post news blackout windows.
The MQL5 design uses a modular control layer: a permission engine (single boolean allow/deny), an enforcement EA that intercepts transactions so neither manual trades nor other EAs can bypass limits, and a dashboard for visibility.
Key implementation details include external session/news files for no-recompile updates, smart caching via file timestamps to avoid per-tick I/O, robust parsing with validation, fast minute-based session checks with early exits, and correct handling of day rollover plus โnext allowed timeโ ca...
๐ Read | Quotes | @mql5dev
#MQL5 #MT5 #EA
The MQL5 design uses a modular control layer: a permission engine (single boolean allow/deny), an enforcement EA that intercepts transactions so neither manual trades nor other EAs can bypass limits, and a dashboard for visibility.
Key implementation details include external session/news files for no-recompile updates, smart caching via file timestamps to avoid per-tick I/O, robust parsing with validation, fast minute-based session checks with early exits, and correct handling of day rollover plus โnext allowed timeโ ca...
๐ Read | Quotes | @mql5dev
#MQL5 #MT5 #EA
โค29
Manual liquidity zone work on higher timeframes misses the internal structure of the base candle. Verifying whether a zone was built by a triangle, rectangle, or double top/bottom requires repeated lower-timeframe zooming, which is slow and produces inconsistent labeling.
An automation module is proposed to classify the lower-timeframe geometry inside each base candle as ascending triangle, descending triangle, symmetrical triangle, rectangle, M, W, or undefined, then annotate the zone and alerts with the result.
Implementation outline targets MQL5: isolate detection logic in an include file (CGeometryDetector), add configurable tolerances and swing-distance filtering, compute slopes for symmetry, and integrate by extracting intrabar data for each base candle interval and storing the detected shape per zone.
๐ Read | AppStore | @mql5dev
#MQL5 #MT5 #Indicator
An automation module is proposed to classify the lower-timeframe geometry inside each base candle as ascending triangle, descending triangle, symmetrical triangle, rectangle, M, W, or undefined, then annotate the zone and alerts with the result.
Implementation outline targets MQL5: isolate detection logic in an include file (CGeometryDetector), add configurable tolerances and swing-distance filtering, compute slopes for symmetry, and integrate by extracting intrabar data for each base candle interval and storing the detected shape per zone.
๐ Read | AppStore | @mql5dev
#MQL5 #MT5 #Indicator
โค37๐ฅ4
Deterministic Oscillatory Search (DOS) is a reproducible metaheuristic for global optimization that removes randomness entirely. Particles start from deterministically distributed points, making runs repeatable under identical inputsโuseful for research and trading system validation.
Search is driven by a โfitness slopeโ state: improving, worsening, or unknown. When fitness deteriorates, a particle reflects (reverses direction) and halves velocity, producing controlled oscillations that refine local extrema without derivatives.
If oscillations stall (worsening persists), DOS switches to a swarm step, pushing particles toward the current global best using a configurable movement factor. An MT5-style implementation centers on per-particle velocity vectors, range clamping, best-solution tracking, and adaptive velocity updates.
Tests show stronger behav...
๐ Read | Quotes | @mql5dev
#MQL5 #MT5 #algorithm
Search is driven by a โfitness slopeโ state: improving, worsening, or unknown. When fitness deteriorates, a particle reflects (reverses direction) and halves velocity, producing controlled oscillations that refine local extrema without derivatives.
If oscillations stall (worsening persists), DOS switches to a swarm step, pushing particles toward the current global best using a configurable movement factor. An MT5-style implementation centers on per-particle velocity vectors, range clamping, best-solution tracking, and adaptive velocity updates.
Tests show stronger behav...
๐ Read | Quotes | @mql5dev
#MQL5 #MT5 #algorithm
โค21๐4
DADA (Adaptive Bottlenecks + Dual Adversarial Decoders) targets time-series anomaly detection with adaptive compression, dual reconstructions for normal vs anomalous regimes, and patching/masking to reduce noise and improve generalization.
The Adaptive Bottlenecks block is implemented as CNeuronAdaBN inheriting CNeuronMoE. It reuses top-k gating and expert routing, but populates experts with autoencoders at multiple latent sizes. A convolution stage produces a latent vector whose segments map to each autoencoder, followed by multi-window conv, tensor transpositions, and per-autoencoder decoder weights.
Instead of a monolith, the system is assembled from library components into three jointly trained models: a state encoder autoencoder with patching/masking and AdaBN, an Actor replacing the anomalous decoder for action selection, and a direction predictor as a deci...
๐ Read | Calendar | @mql5dev
#MQL5 #MT5 #AI
The Adaptive Bottlenecks block is implemented as CNeuronAdaBN inheriting CNeuronMoE. It reuses top-k gating and expert routing, but populates experts with autoencoders at multiple latent sizes. A convolution stage produces a latent vector whose segments map to each autoencoder, followed by multi-window conv, tensor transpositions, and per-autoencoder decoder weights.
Instead of a monolith, the system is assembled from library components into three jointly trained models: a state encoder autoencoder with patching/masking and AdaBN, an Actor replacing the anomalous decoder for action selection, and a direction predictor as a deci...
๐ Read | Calendar | @mql5dev
#MQL5 #MT5 #AI
โค31๐2๐2โก1
An Expert Advisor can automate session control by recalculating daily start, end, and close times, clearing internal state, and initializing the price range used for breakout logic.
During the range window, minute-level highs and lows are sampled to compute the session maximum and minimum. A chart rectangle is updated in real time to reflect the current consolidation zone.
After the range window completes, the close of the latest finished candle is compared to the stored boundaries, independent of the range end timestamp. On confirmation, a market order is placed in the breakout direction, with take-profit set to the measured range size and stop-loss set to the opposite boundary.
๐ Read | VPS | @mql5dev
#MQL5 #MT5 #EA
During the range window, minute-level highs and lows are sampled to compute the session maximum and minimum. A chart rectangle is updated in real time to reflect the current consolidation zone.
After the range window completes, the close of the latest finished candle is compared to the stored boundaries, independent of the range end timestamp. On confirmation, a market order is placed in the breakout direction, with take-profit set to the measured range size and stop-loss set to the opposite boundary.
๐ Read | VPS | @mql5dev
#MQL5 #MT5 #EA
โค23๐ฏ3๐1๐1
L1 trend filtering can be used to estimate piecewise-linear price trends while suppressing short-term noise. The method keeps turning points and slope changes that are often lost with moving averages or heavy smoothing.
An example implementation in MQL5 demonstrates L1 Trend Filter routines for float and double vectors, validated on random-walk simulated series. This setup helps verify numerical stability, parameter sensitivity, and output consistency across data types.
In trading workflows, the filtered trend can support regime detection, adaptive risk controls, and signal preconditioning by separating structural movement from micro-variations. The same code is packaged as a shared project under MQL5\Shared Projects\L1Trend.
๐ Read | Calendar | @mql5dev
#MQL5 #MT5 #Indicator
An example implementation in MQL5 demonstrates L1 Trend Filter routines for float and double vectors, validated on random-walk simulated series. This setup helps verify numerical stability, parameter sensitivity, and output consistency across data types.
In trading workflows, the filtered trend can support regime detection, adaptive risk controls, and signal preconditioning by separating structural movement from micro-variations. The same code is packaged as a shared project under MQL5\Shared Projects\L1Trend.
๐ Read | Calendar | @mql5dev
#MQL5 #MT5 #Indicator
โค22๐2
CATCH targets subtle anomalies in multivariate market series by moving analysis to the frequency domain, where volatility bursts and regime shifts separate into different bands. Its key idea is โfrequency patchingโ: split the complex FFT spectrum into overlapping patches, learn normal behavior per band, then reconstruct with iFFT and flag anomalies via reconstruction error.
A channel-aware fusion stage uses a masked Transformer to model cross-asset dependencies without letting irrelevant instruments dilute attention. The mask is learned and refined with an explicit objective to strengthen meaningful inter-channel links while suppressing noise.
The article then maps these ideas into MQL5 with OpenCL acceleration: complex-valued convolution and masked attention are implemented using float2 buffers for real/imag parts, reusing existing layer infrastr...
๐ Read | AlgoBook | @mql5dev
#MQL5 #MT5 #AlgoTrading
A channel-aware fusion stage uses a masked Transformer to model cross-asset dependencies without letting irrelevant instruments dilute attention. The mask is learned and refined with an explicit objective to strengthen meaningful inter-channel links while suppressing noise.
The article then maps these ideas into MQL5 with OpenCL acceleration: complex-valued convolution and masked attention are implemented using float2 buffers for real/imag parts, reusing existing layer infrastr...
๐ Read | AlgoBook | @mql5dev
#MQL5 #MT5 #AlgoTrading
โค24๐4๐2๐1
Strategy Tester gaps around CalendarValueHistory() make news-driven EAs hard to verify. Historical events are often missing, so entry blocks, SL/TP suspension, and pre-news closes never trigger, producing misleading curves and no audit trail in logs.
A deterministic fix is a static CSV of events (time, currency, importance, name) loaded once in OnInit() when MQL_TESTER is true. Tester mode switches isUpcomingNews()/IsNewsTime() to an in-memory scan, while live trading keeps the terminal calendar API unchanged.
Implementation points: strict CSV format compatible with StringToTime(), FILE_COMMON access for tester sandbox, a symbol currency cache built at init, and an optional script that exports the terminal calendar to CSV for chosen date ranges.
๐ Read | NeuroBook | @mql5dev
#MQL5 #MT5 #AlgoTrading
A deterministic fix is a static CSV of events (time, currency, importance, name) loaded once in OnInit() when MQL_TESTER is true. Tester mode switches isUpcomingNews()/IsNewsTime() to an in-memory scan, while live trading keeps the terminal calendar API unchanged.
Implementation points: strict CSV format compatible with StringToTime(), FILE_COMMON access for tester sandbox, a symbol currency cache built at init, and an optional script that exports the terminal calendar to CSV for chosen date ranges.
๐ Read | NeuroBook | @mql5dev
#MQL5 #MT5 #AlgoTrading
โค20๐4๐2
Price action systems often fail on breakout filtering, with liquidity sweeps creating false continuation signals. A structured model is required to locate likely resting orders, validate breaks, and keep risk rules consistent.
An MQL5 automation is outlined for order block trading in consolidation zones, using higher-timeframe swing structure as the trend filter. Setups require inducement first, then break of structure, with fair value gap alignment inside the impulse leg.
Implementation details cover enums for trade mode, FVG state, trailing type, and mitigated-zone handling. Core structs track OB metadata, FVG links, and open-trade trailing state, plus chart rendering utilities for zones, labels, BoS lines, and mitigation marks. Swing and consolidation functions drive detection, followed by zone creation, mitigation tracking, and risk-based execu...
๐ Read | Docs | @mql5dev
#MQL5 #MT5 #AlgoTrading
An MQL5 automation is outlined for order block trading in consolidation zones, using higher-timeframe swing structure as the trend filter. Setups require inducement first, then break of structure, with fair value gap alignment inside the impulse leg.
Implementation details cover enums for trade mode, FVG state, trailing type, and mitigated-zone handling. Core structs track OB metadata, FVG links, and open-trade trailing state, plus chart rendering utilities for zones, labels, BoS lines, and mitigation marks. Swing and consolidation functions drive detection, followed by zone creation, mitigation tracking, and risk-based execu...
๐ Read | Docs | @mql5dev
#MQL5 #MT5 #AlgoTrading
โค18โ3๐2
MetaTrader 5 keeps trade history inside the terminal, so external analytics need an explicit export path. This article completes that link by adding a lightweight EA that emits a trade record the moment a position is closed.
The core design is event-driven: OnTradeTransaction filters only โdeal addedโ events that represent exits, avoiding fragile OnTick polling and ensuring only final, complete trades are sent.
The EA reconstructs a full trade by pairing the closing deal with its opening deal, normalizes enums (reason, direction) into readable strings, builds JSON manually (no native MQL5 JSON), then POSTs it via WebRequest to a versioned Flask API endpoint.
Local testing covers server startup, MT5 WebRequest URL whitelisting, and verifying 200 responses and server logs. Known gaps include no retries, no payload validation, and no local queueing for outa...
๐ Read | AppStore | @mql5dev
#MQL5 #MT5 #EA
The core design is event-driven: OnTradeTransaction filters only โdeal addedโ events that represent exits, avoiding fragile OnTick polling and ensuring only final, complete trades are sent.
The EA reconstructs a full trade by pairing the closing deal with its opening deal, normalizes enums (reason, direction) into readable strings, builds JSON manually (no native MQL5 JSON), then POSTs it via WebRequest to a versioned Flask API endpoint.
Local testing covers server startup, MT5 WebRequest URL whitelisting, and verifying 200 responses and server logs. Known gaps include no retries, no payload validation, and no local queueing for outa...
๐ Read | AppStore | @mql5dev
#MQL5 #MT5 #EA
โค15๐ฏ5๐3๐2
MQL5 EAs often persist input changes by rewriting a single settings file, which removes history and makes past test results hard to reproduce.
A practical alternative is an append-only binary log. Each parameter snapshot is stored as a fixed-size struct record, enabling fast reads of the latest configuration while keeping prior versions intact.
The struct is typically split into metadata (version, timestamp), adjustable trading inputs, and an integrity field. A checksum is computed only from adjustable inputs so timestamps, counters, and performance metrics do not trigger new versions.
On startup, create version 1 only if the file is empty. On later runs, read the last record, recompute the checksum from current inputs, and append a new record only when the checksum differs.
๐ Read | CodeBase | @mql5dev
#MQL5 #MT5 #EA
A practical alternative is an append-only binary log. Each parameter snapshot is stored as a fixed-size struct record, enabling fast reads of the latest configuration while keeping prior versions intact.
The struct is typically split into metadata (version, timestamp), adjustable trading inputs, and an integrity field. A checksum is computed only from adjustable inputs so timestamps, counters, and performance metrics do not trigger new versions.
On startup, create version 1 only if the file is empty. On later runs, read the last record, recompute the checksum from current inputs, and append a new record only when the checksum differs.
๐ Read | CodeBase | @mql5dev
#MQL5 #MT5 #EA
โค26๐4๐3๐2
A confluence detector identifies price zones where Fibonacci retracement levels from multiple swing pairs align.
The algorithm selects 4โ5 significant swing points, calculates 38.2%, 50%, 61.8%, and 78.6% levels for each swing pair, then scans for clusters where two or more levels converge within a configurable tolerance. Zones are ranked by density, with more overlapping levels treated as higher strength.
Confluence areas are rendered as shaded rectangles and color-coded by strength: yellow for 2 matches, orange for 3, and red for 4 or more. Labels list the contributing levels, while individual Fibonacci lines can be enabled or hidden. An alert triggers when price enters a strong zone.
Runs on all timeframes, with typical use on H1, H4, and D1.
๐ Read | Docs | @mql5dev
#MQL4 #MT4 #Indicator
The algorithm selects 4โ5 significant swing points, calculates 38.2%, 50%, 61.8%, and 78.6% levels for each swing pair, then scans for clusters where two or more levels converge within a configurable tolerance. Zones are ranked by density, with more overlapping levels treated as higher strength.
Confluence areas are rendered as shaded rectangles and color-coded by strength: yellow for 2 matches, orange for 3, and red for 4 or more. Labels list the contributing levels, while individual Fibonacci lines can be enabled or hidden. An alert triggers when price enters a strong zone.
Runs on all timeframes, with typical use on H1, H4, and D1.
๐ Read | Docs | @mql5dev
#MQL4 #MT4 #Indicator
โค21๐5๐1๐ค1
Daily Risk Monitor Lite is a free, open-source MT5 indicator that renders intraday account risk directly on the chart with a small, explainable feature set. The panel shows Daily Realized P/L, Floating P/L, Daily Total, and current drawdown percent, plus SAFE/WARNING/DANGER status via configurable colors.
Daily Realized P/L counts only exit deals within the active day range, with optional commission and swap inclusion. Floating P/L uses the current result of all open positions, optionally including swap. Daily Total is realized plus floating. Drawdown is max((Balance-Equity)/Balance*100, 0), or N/A when Balance<=0.
Day boundaries can follow broker 00:00 or a manual server-hour start. This is read-only: no auto-close, no trade blocking, no enforcement engine. Intended as a lightweight sample for monitoring and further development.
๐ Read | Quotes | @mql5dev
#MQL5 #MT5 #Indicator
Daily Realized P/L counts only exit deals within the active day range, with optional commission and swap inclusion. Floating P/L uses the current result of all open positions, optionally including swap. Daily Total is realized plus floating. Drawdown is max((Balance-Equity)/Balance*100, 0), or N/A when Balance<=0.
Day boundaries can follow broker 00:00 or a manual server-hour start. This is read-only: no auto-close, no trade blocking, no enforcement engine. Intended as a lightweight sample for monitoring and further development.
๐ Read | Quotes | @mql5dev
#MQL5 #MT5 #Indicator
โค15๐ฅ1
Self-Aware Trend System (SATS) is a multi-engine SuperTrend for MT5 built around four parts: adaptive ATR SuperTrend bands, a Trend Quality Index (TQI), composite signal scoring, and on-chart risk levels (entry, SL, TP1โTP3).
Band width adapts with Kaufman Efficiency Ratio: tighter in directional moves, wider in chop. TQI (0โ1) combines efficiency, volatility regime (ATR vs baseline), pivot-based structure, and momentum persistence. A character-flip module flags sharp TQI drops during an active trend as an early warning before a line flip.
Signals are gated by a configurable score (momentum, ER, volume Z-score, RSI zone, pivots). The dashboard tracks TQI components plus rolling win rate, average R, drawdown, streaks, and cumulative R. Optional auto-calibration adjusts โQuality Influenceโ from recent R results. Non-repainting uses confirmed closed bar...
๐ Read | Freelance | @mql5dev
#MQL5 #MT5 #Indicator
Band width adapts with Kaufman Efficiency Ratio: tighter in directional moves, wider in chop. TQI (0โ1) combines efficiency, volatility regime (ATR vs baseline), pivot-based structure, and momentum persistence. A character-flip module flags sharp TQI drops during an active trend as an early warning before a line flip.
Signals are gated by a configurable score (momentum, ER, volume Z-score, RSI zone, pivots). The dashboard tracks TQI components plus rolling win rate, average R, drawdown, streaks, and cumulative R. Optional auto-calibration adjusts โQuality Influenceโ from recent R results. Non-repainting uses confirmed closed bar...
๐ Read | Freelance | @mql5dev
#MQL5 #MT5 #Indicator
โค22๐ฅ2
Options theory is framed around clear mechanics (call/put rights vs seller obligations), key parameters (underlying, strike, premium, expiration), and exercise/settlement styles. Pricing is anchored to Black-Scholes for European options, with practical caveats: shifting volatility, non-lognormal returns, and limited fit for American exercise. Sensitivities are handled via Greeks, especially Delta for replication.
The core idea is emulating options by trading the underlying to match an option portfolioโs Delta, enabling synthetic contracts with custom strikes/expirationsโeven when listed options donโt exist or are illiquid. Delta-hedged rebalancing (time-based or delta-step) keeps the synthetic payoff aligned, but requires systematic automation, low friction costs, and continuous monitoring to avoid tracking error and missed adjustments.
๐ Read | Signals | @mql5dev
#MQL5 #MT5 #EA
The core idea is emulating options by trading the underlying to match an option portfolioโs Delta, enabling synthetic contracts with custom strikes/expirationsโeven when listed options donโt exist or are illiquid. Delta-hedged rebalancing (time-based or delta-step) keeps the synthetic payoff aligned, but requires systematic automation, low friction costs, and continuous monitoring to avoid tracking error and missed adjustments.
๐ Read | Signals | @mql5dev
#MQL5 #MT5 #EA
โค20
CAPM emerged from Markowitzโs 1952 portfolio theory and the efficient frontier. In 1964, Sharpe reduced the computational burden of covariance-heavy optimization into a market equilibrium model; Lintner and Mossin reached similar results. By the 1970s, CAPM became standard for cost of capital estimates.
Classical CAPM links expected return to the risk-free rate and beta, with beta defined via covariance with the market over market variance. Assumptions include frictionless markets, shared expectations, and diversified portfolios pricing only systematic risk.
A MetaTrader 5 adaptation for FX replaces beta with a volatility-driven dynamic risk premium, uses unbiased variance, handles low-data cases, and annualizes volatility with a 252 factor. Two buffers expose expected return and risk premium, using CopyClose for efficient data access. Limitations includ...
๐ Read | NeuroBook | @mql5dev
#MQL5 #MT5 #Indicator
Classical CAPM links expected return to the risk-free rate and beta, with beta defined via covariance with the market over market variance. Assumptions include frictionless markets, shared expectations, and diversified portfolios pricing only systematic risk.
A MetaTrader 5 adaptation for FX replaces beta with a volatility-driven dynamic risk premium, uses unbiased variance, handles low-data cases, and annualizes volatility with a 252 factor. Two buffers expose expected return and risk premium, using CopyClose for efficient data access. Limitations includ...
๐ Read | NeuroBook | @mql5dev
#MQL5 #MT5 #Indicator
โค31๐3๐3๐ฏ1