MQL5 Algo Trading
534K subscribers
3.74K photos
6 videos
3.74K 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
An MT5 Expert Advisor implements the Relative Moving Average framework based on fractiles rather than price levels. Each bar is ranked inside a trailing return distribution as a value in [0, 1], aiming to make thresholds portable across symbols and volatility regimes. The calculation is centralized in a companion indicator loaded via iCustom, so chart state and trading state cannot diverge, and the signal rules remain broker-independent.

All four cross-strategies are included: cross-reverse and cross-revert on both sides. Entries are armed at distribution extremes and triggered by subsequent quantile-bin crossings, not by the extreme itself. Exits use an Adaptive Crossover Exit that switches by regime between a full distribution crossover and an extremum revert trigger, with a separate adverse-movement safety exit and a re-entry block until median recross.

...

πŸ‘‰ Read | NeuroBook | @mql5dev
πŸ‘12❀11πŸ‘Œ2⚑1
This article explores whether astronomical cycles can be modeled as measurable market inputs rather than superstition. The core idea is a layered mechanism: lunar/solar rhythms influence sleep, stress, and risk appetite, which can synchronize trader behavior and show up as volatility and directional bias.

A practical pipeline is built around stable constants (synodic month, tropical year) plus each currency’s β€œbirth date.” Currency traits (risk-on vs safe-haven) are encoded as coefficients, then combined with lunar/solar phase angles and multiple harmonics (sin/cos features) to capture overlapping periodic effects. Lagged versions of these signals add market β€œmemory,” producing 88 features per weekly bar.

Using MetaTrader 5 data (15 years EUR/USD) and CatBoost with chronological splitting, the model predicts β€œsignificant up-move” as a binary task. Results s...

πŸ‘‰ Read | NeuroBook | @mql5dev
❀15πŸ‘8πŸ‘Œ4πŸ€”1
Mantis reframes time-series modeling as regime classification with calibrated probabilities, not fragile point forecasting. It standardizes inputs via tokenized patches and uses hybrid attention to capture both local microstructure and long-range context. Contrastive pretraining builds embeddings that stay stable under shifts, scaling, and noise, while temperature scaling turns scores into reliable confidence.

This article moves from theory to MT5 implementation details: adding temporal/positional encoding using an existing CMamba4CastEmbedding module, then building the patching stage that makes processing independent of raw sequence length.

A key engineering change is replacing mean-pooling with per-channel convolution plus max-pooling to preserve sharp moves. The CNeuronMantisPatching pipeline uses transpositions for axis-isolated processing, th...

πŸ‘‰ Read | VPS | @mql5dev
❀12πŸ‘10πŸ‘Œ2😁1
Automatic object placement removes the manual dependency from earlier chart-object pipelines. The system generates pitchforks, trendlines, Fibonacci, channels, and support/resistance directly from detected swing structure, then routes them through the same evaluators used for user-drawn objects.

A modular layout is used: swing detection, object placement, market data caching, signal evaluation, topology management, and adaptive execution. Swing detection relies on cached OHLC arrays to avoid repeated iHigh/iLow calls and identifies highs/lows via strict neighbor comparisons.

TopologyManager coordinates placement, scanning, evaluator lifecycle, and signal processing, with throttling to limit redraw and scan overhead. Chart events trigger immediate refresh to remove timer polling latency.

AdaptiveTrade calculates instrument-aware SL/TP using point size, s...

πŸ‘‰ Read | NeuroBook | @mql5dev
❀25πŸ‘4πŸ‘Œ4πŸ”₯1
MetaTrader 5 keeps full tick history in its cache, but exporting it for external analysis is bottlenecked by CSV size, slow parsing, and rounding from text conversion. A binary export solves this with fixed-width records: ~48 bytes per tick versus ~60+ in CSV, faster loads, and exact IEEE-754 price preservation.

The script defines a simple file format: a 64-byte header (magic ID, version, symbol, digits, tick count, time range) followed by contiguous 48-byte tick records (time_msc, bid/ask/last, volume, flags, padding). This enables direct random access and zero-parse reading in Python via NumPy.

Implementation is modular: separate structs for header and tick layout, then an exporter that uses CopyTicksRange(COPY_TICKS_ALL), writes the header with FileWriteStruct, and writes tick batches with FileWriteArray for high throughput.

πŸ‘‰ Read | Freelance | @mql5dev
❀18πŸ‘7πŸ‘Œ3
Mean-variance allocators can become unstable when instruments are highly correlated, due to covariance matrix inversion. Small estimation noise can translate into large, leveraged long/short weights that flip across windows.

Hierarchical Risk Parity (Lopez de Prado, 2016) avoids inversion. The workflow converts prices to simple returns, builds covariance and correlation matrices, clusters instruments via a correlation-to-distance transform, then forms a binary merge tree using single-linkage.

Tree order drives quasi-diagonalization, pushing correlated instruments into blocks. Recursive bisection allocates capital across blocks using cluster variance from an inverse-variance sub-portfolio and a covariance quadratic form, producing long-only weights that sum to 1. A rebalancing EA can apply the output per basket.

πŸ‘‰ Read | Docs | @mql5dev
❀14πŸ‘8πŸ‘Œ1
ACCS (Artificial Coronary Circulation System) is a bio-inspired metaheuristic by Kaveh and Kooshkbaghi (2019). Candidate solutions are modeled as arteries/capillaries, with Coronary Growth Factor (CGF) used to weight solution quality and influence search dynamics.

Core mechanics: random population init, center position calculation, CGF normalization, then alternating global search (direction based on CGF vs center) and local search (update toward best and away from worst with an iteration-dependent factor). Pruning reverts worsening moves.

Implementation uses Heart Memory to retain the top solutions (default 25% of population, minimum 1). Data structures separate persistent best states from temporary trial positions, followed by a selection phase that commits global-search candidates and refreshes memory by fitness sorting.

πŸ‘‰ Read | Calendar | @mql5dev
❀15πŸ‘6πŸ‘Œ1πŸ‘€1
An indicator calculates the Asian session range (default 00:00–08:00 server time) and plots the high/low as horizontal levels. It then monitors the London session for confirmed breaks and retests of these levels, generating buy/sell signals intended for manual scalping around the London open.

The current session range is drawn on-chart with breakout and retest highlights. Signals are fixed on closed bars with no repainting. Supported timeframes include M1, M5, and M15 across any symbol.

Key inputs include SessionStartHour and SessionEndHour for range definition, optional EMA-based trend confirmation, and an optional volume filter to avoid low-activity moves. SignalMode supports alerts, push notifications, or arrows only. Default trade management levels can be set via StopLevelPips and TakeLevelPips.

πŸ‘‰ Read | Quotes | @mql5dev
❀10πŸ‘5🀣2πŸ‘¨β€πŸ’»2πŸ‘Ύ2⚑1πŸ‘Œ1
Symbolic Aggregate approXimation (SAX) turns a rolling price window into a short word, enabling text-style matching over market history. The pipeline z-normalises to keep shape only, applies Piecewise Aggregate Approximation to reduce dimensionality, then discretises via Gaussian breakpoints so letters are equiprobable.

Historical search uses a two-stage process: prune candidates with MINDIST, which provably lower-bounds Euclidean distance on z-normalised series, then rank survivors by true Euclidean distance. A validation harness confirms the same matches as brute force while skipping most comparisons.

The indicator scans for prior analogs with strict no-lookahead, measures each analog’s forward path in ATR units, and projects a median plus interquartile band as a fan cone. A verdict panel reports the current word, analog count and distances, forwa...

πŸ‘‰ Read | Docs | @mql5dev
❀11πŸ‘3πŸ‘Œ1
Trade Analytics Dashboard indicator reads the terminal’s closed-deal history via HistorySelect() and HistoryDealGetTicket(), aggregates results, and renders a compact on-chart panel using CCanvas. No price analysis and no order placement, modification, or closure. Since it only reads existing deals, it does not require AutoTrading permission.

Panel fields summarize the selected lookback window: trade count, win rate (at/above break-even including swap/commission), profit factor (gross profit divided by gross loss), and net P/L with visual gain/loss coloring. It also reports current win/loss streak from the most recent deal, best and worst contributing symbols, and a simple cumulative equity curve line.

Inputs are grouped for layout, data scope, and colors: anchor corner and pixel offsets, panel size, refresh interval independent of ticks, history da...

πŸ‘‰ Read | AppStore | @mql5dev
❀12πŸ‘5πŸŽ‰1πŸ‘Œ1
Session Volatility Heatmap is a measurement indicator designed to map real, symbol-specific intraday movement instead of relying on textbook session times. It loads InpLookbackDays of history on the active timeframe, groups each bar’s (high βˆ’ low) range by the hour the bar closes, and averages all 24 hourly buckets.

Output is split into two aligned views. A compact heatmap panel shows 24 hourly columns of the broker/server day: higher, warmer columns indicate historically larger hourly ranges; lower, cooler columns indicate quieter periods. Session bands are also drawn behind candles for the last InpSessionDays, marking Asian, London, and New York windows in server time; overlaps typically align with the highest-liquidity hours.

Used together, the heatmap identifies the hour and the session shading provides context. If peak hours do not match sessi...

πŸ‘‰ Read | NeuroBook | @mql5dev
πŸ‘9❀7⚑3πŸ‘Œ1
Most risk tooling in MT5 assumes the next worst loss will resemble the worst already observed. ATR sizing, Monte Carlo reshuffles, and historical VaR all stay inside the sampled distribution and tend to understate fat-tailed crash risk.

A native MQL5 indicator applies Extreme Value Theory using Peaks-Over-Threshold. Closes are converted into a one-sided downside loss series, exceedances above a high quantile are extracted, and a Generalized Pareto Distribution is fit with maximum-likelihood optimisation via the terminal’s built-in constrained optimiser, with no external dependencies.

It reports rolling EVT VaR, EVT Expected Shortfall, and the fitted tail shape xi with regime colouring. The engine refuses to print numbers without enough exceedances (floor of 30) and withholds ES when the fitted shape makes the mean diverge. This is a magnitude gauge for ex...

πŸ‘‰ Read | Signals | @mql5dev
❀7πŸ‘3πŸ‘Œ1
Self-Organizing Maps (SOM) give MT5 traders a practical way to compress hundreds of market features into a 2D β€œstate map” where similar regimes land close together. Each tick finds a Best Matching Unit via Euclidean distance, then a Gaussian neighborhood update nudges nearby neurons, smoothing noise and forming stable clusters for trend, decline, and range conditions.

The EA implementation uses a 20Γ—20 grid with ~400 features per sample, trains on historical bars, and adds a supervised target by looking ahead (rise/fall/flat thresholds mapped to 0.8/0.2/0.5). Live signals are gated by a confidence model and no-position checks, with periodic retraining to adapt.

Interpretability comes from exporting an interactive HTML heatmap (U-matrix style intensity), helping developers see dense clusters vs unfamiliar zones and avoid low-similarity trades.

πŸ‘‰ Read | VPS | @mql5dev
πŸ‘1