MQL5 Algo Trading
574K subscribers
4.44K photos
7 videos
4.45K 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
Session filters in EAs are defined in server time, and brokers use different time zones and DST rules. A fixed β€œ10:00–13:00” window only stays aligned with London or New York while the server offset stays stable, which fails during the US/EU DST gap weeks.

A clock-audit tool can infer the server offset from symbol history instead of relying on broker notes. The weekly FX/CME close is 17:00 America/New_York; comparing that instant (converted to UTC with US DST rules) to the last H1 bar before each weekend/holiday gap yields one offset measurement per week. Over ~60 weeks this produces a sequence that detects clock moves, dates the switch between closes, and classifies the regime as fixed, US, EU, mixed, or untested.

Output includes irregular closes (for example early US holiday metals closes), counts of Sunday bars (relevant for D1 candles), and projections ...

πŸ‘‰ Read | Freelance | @mql5dev
πŸ‘9❀7πŸ”₯4🀩2πŸ‘Œ2
Indicator readings like determinism, persistence entropy, or time-reversal asymmetry remain uninterpretable without a null model that preserves the relevant structure. Bar shuffling is typically the wrong null for indicators because it destroys arrival order and autocorrelation.

Surrogate testing keeps amplitude distribution and/or power spectrum while removing higher-order structure. Four nulls are outlined: FT (linear Gaussian), AAFT and IAAFT (static monotone transform of a linear process), and BLOCK (stationary bootstrap with finite dependence length). Each null answers a different β€œby chance” question.

Implementation notes: spectral surrogates require FFT on arbitrary lengths, handled via Bluestein chirp-z to avoid zero padding or truncation. IAAFT stops on rank fixed points to ensure exact amplitude matching, leaving residual spectral error ...

πŸ‘‰ Read | Quotes | @mql5dev
❀19πŸ‘9🀩7πŸ”₯5πŸ‘Œ2πŸŽ‰1
Many funded challenges fail due to violations of the daily loss rule. DailyLossGuard automates enforcement by tracking daily P/L on every tick against a configured limit, based on a percentage of day-start balance or a fixed amount.

On breach, it can close all open positions immediately, trigger an alert and push notification, and display a persistent BREACHED status panel until the next trading day. A Magic Number filter allows protection for a single EA or the entire account.

A top-center dashboard shows daily P/L, limit, and ARMED/BREACHED state, with automatic recovery on timeframe changes and chart resizes. Intended for prop-firm and funded accounts, multi-EA setups, and manual trading requiring a strict daily stop.

Due to platform API constraints, it cannot prevent other EAs from sending new orders; it reacts by closing positions and notifying instan...

πŸ‘‰ Read | Quotes | @mql5dev
πŸ‘9🀩8❀7πŸ”₯5πŸ‘Œ2
Multi-timeframe dashboards often emit conflicting forecasts for the same price window. Weighted voting forces agreement but provides no error guarantee.

Forecast reconciliation treats coherence as a linear constraint. When targets are linearly related by construction, an orthogonal projection can enforce consistency without increasing total squared error under the chosen metric, given a coherent truth.

An MQL5 implementation builds a summing matrix for two cases: timeframe aggregation on one symbol, and cross-currency identities in log space. Independent models per node are reconciled into a coherent set.

Weighting matters. Options range from identity and structural diagonals to MinT covariance-based schemes with correlation shrinkage. Walk-forward tests measure squared error only; results do not imply a trading edge.

πŸ‘‰ Read | AppStore | @mql5dev
πŸ‘19❀8πŸ”₯8🀩7πŸ‘¨β€πŸ’»2πŸ‘Œ1
A script exports the full trading specification for each symbol into a CSV file.

The output includes digits, point, tick size/value, volume min/max/step, contract size, stops and freeze levels, current spread, spread type (floating or fixed), allowed filling modes, execution mode, trade mode, initial margin, swap long/short, and profit currency.

These parameters commonly change between brokers or instruments and can cause Expert Advisors to fail without clear errors. Volume step, filling mode, and stops level are frequent sources of silent order rejections. A one-time export makes incompatibilities visible before placing the first trade.

Inputs cover Market Watch only or all broker symbols, optional use of the common Files folder, and a configurable file name (empty for automatic naming). Symbols not in Market Watch are added temporarily for reading, t...

πŸ‘‰ Read | Signals | @mql5dev
❀12πŸ‘11πŸ”₯8🀩6⚑2πŸ‘Œ2
Manual Trade Pad for MT5 is a chart-based manual trading panel built as an MQL5 EA for order execution and basic position management directly from the terminal. It runs in two modes: Live Market for manual trading, and Strategy Tester for manual historical testing and workflow practice. No external DLLs, libraries, indicators, or custom GUI frameworks are required.

Core functions include BUY/SELL market orders with automatic Stop Loss and optional Take Profit based on a configurable Risk/Reward ratio. Position sizing supports fixed lot input or risk-percentage sizing, with volume normalized to broker constraints and validated against symbol stop-level rules.

Trade management covers Break-Even with offset, partial close with step/min volume checks, and closing by direction (BUY, SELL, or all managed). Scope is limited to the chart symbol and a configured Magic Nu...

πŸ‘‰ Read | Docs | @mql5dev
❀24πŸ‘11🀩8πŸ”₯4πŸ‘Œ2πŸ‘€2
AI agents and other automated systems execute trades at machine speed, while platform safety settings can miss operational errors. AgentGuard adds an independent risk layer by polling all open positions every five seconds and enforcing four hard limits.

Controls include maximum total volume, maximum position count, mandatory stop-loss on every position, and a daily-loss circuit breaker that closes all positions and remains locked until the next trading day.

The tool operates alongside any EA, manual trading, or AI agent. It evaluates compliance only, regardless of how a position was opened. A status panel and intervention alerts provide visibility, with a monitor-only mode for calibration. No DLLs. Free. Risk management only; no signal generation.

πŸ‘‰ Read | VPS | @mql5dev
❀18πŸ”₯11πŸ‘9🀩4πŸ‘Œ2
Broker Basket Preflight is a standalone MT5 script intended to verify a broker’s multi-symbol setup before portfolio EA work. It reads the exact symbols currently selected in Market Watch and writes a diagnostic report to the Experts journal. The source includes an MIT license and relies on no external libraries, DLLs, or network calls.

The script is installed by copying BrokerBasketPreflight.mq5 into MQL5/Scripts, compiling, then running it from a separate chart. InpSymbols can be left empty to test the chart symbol, or set to a 1–64 entry comma-separated basket using broker-exact names. Unknown, unselected, empty, and duplicate entries are skipped independently.

Output covers symbol specification and quote integrity: contract size, volume limits/step, point/tick sizes, digits, stops/freeze distances, calc/trade modes, execution and filling policies, p...

πŸ‘‰ Read | Forum | @mql5dev
❀19πŸ‘13🀩5πŸ”₯2
Portfolio Allocation Planner is a free open-source MT5 utility for checking whether target weights are feasible under broker minimum lots. It converts an explicit notional budget and percentage weights into a dashboard showing minimum-lot notional, lots rounded down, resulting allocation, target shortfall, and per-row status. Snapshots can be recalculated on demand, inspected via hover details, paginated for larger baskets, and optionally exported to CSV.

Setup: copy PortfolioAllocationPlanner.mq5 to MQL5/Experts, compile, select exact broker symbols in Market Watch, then attach to a separate chart. Configure InpBudget, InpBudgetCurrency, InpSymbols, and matching InpWeightsPct (not normalized; total > 0 and <= 100). It is an interface EA with no trading; no account data is read and no orders are sent.

Notional is computed as Ask Γ— contract size with explici...

πŸ‘‰ Read | AlgoBook | @mql5dev
❀19πŸ‘11🀩9πŸ”₯4
SEW ResNet concepts were implemented for MQL5 time-series work using a spiking ResNeXt baseline with energy-balanced learning. The design targets bursty market streams by using discrete spikes, adaptive thresholds, and gating to reduce sensitivity to noise while staying responsive under volatility.

Core modules include Spike ResNeXt Bottleneck and Spike ResNeXt Residual blocks, assembled via programmatic layer creation with convolution, normalization, spiking activation, and grouped convolutions. A zero-input check skips compute during low-activity intervals.

To capture cross-feature dependencies, a second Bottleneck operates on a transposed tensor per time step, while residual usage is limited to avoid over-amplification. Multi-stream fusion avoids element-wise multiplication due to blocked gradients; normalized summation plus spiking activation ...

πŸ‘‰ Read | AppStore | @mql5dev
πŸ”₯10πŸ‘9❀8🀩2
Part V adds persistence to the Supply/Demand Zone Manager so zone state survives EA or terminal restarts per symbol+timeframe.

A plain-data snapshot (SZonePersist) stores identity, geometry/timing, scores/telemetry, lifecycle flags, interaction history, and user anchors. Runtime behavior stays in CZone; persistence only captures durable state.

Startup flow restores saved properties, rebuilds CZone instances from records, runs existing relevance checks, then reconciles chart rectangles. User zones restore left anchor and price bounds; right edge remains framework-managed and extends at runtime.

Persistence uses Terminal\Common\Files\DynamicSR\V5 with filenames derived from symbol+timeframe. Changes mark a dirty flag; SavePersistState writes snapshots via CZonePersistence.

Scope note: restart-safe only. No atomic writes, checksums, or crash-safe transact...

πŸ‘‰ Read | NeuroBook | @mql5dev
❀16πŸ‘11🀩7πŸ”₯6
Part 86 extends the double-bottom pattern tool with library-wide validation. A new VALIDATE ALL action reuses the existing ValidateDoubleBottom() rule engine to classify every stored sample into INVALID, CANDIDATE, CONFIRMED, or FAILED, while keeping single-sample validation and chart rendering separate for accurate visual review.

The batch run works on stored candle arrays (symbol/timeframe included), supports non-consecutive sample IDs, and produces a consolidated UTF-8 CSV without modifying original SAMPLE_<ID>.csv files. The report embeds totals, validator settings, schema/revision metadata, and one detailed row per sample (indices, prices, score, reason), preserving 17-digit floating-point precision.

Export adds defensive engineering: per-run filenames, temp-file write + byte-for-byte readback verification, explicit status accounting, and error diagnos...

πŸ‘‰ Read | Quotes | @mql5dev
πŸ‘11❀10🀩4πŸ”₯2😁1
This article implements Variational Mode Decomposition (VMD) for MetaTrader 5 as a rigorously causal tool, not a hindsight-heavy chart smoother. It contrasts VMD with MAs, FFT, and EMD, then frames VMD as an explicit optimization solved by ADMM: K modes that sum to price, each constrained to be narrowband around an estimated center frequency.

Key engineering details: FFT is done once in/out of the loop; ADMM updates are closed-form Wiener filters in the frequency domain; windows are mirrored to reduce boundary discontinuities; analytic-signal handling is implemented correctly; log-prices and mean removal prevent the DC spike from corrupting modes; rolling buffers keep memory small enough for per-bar execution.

The indicator plots a denoised signal, trend mode, and a β€œrandom wander” band, plus per-mode periods, energy shares, and solve-quality flags. Cruci...

πŸ‘‰ Read | AlgoBook | @mql5dev
πŸ‘10❀8πŸ”₯6πŸŽ‰2🀩2
MITP (Multi-Indicator Trend Painter) is a trend-following indicator that aggregates up to 32 independent signals, including ALMA, AO, MACD (line and histogram), PPO (line and histogram), RSI MA, CCI MA, Fisher, KAMA, True Strength Index, Trend Strength Index, RCI Ribbon, Chop Zone, and others. Each component can be enabled or disabled in inputs.

Each enabled indicator maintains its own trigger. When it turns bullish, the candle high is stored as a buy trigger; when bearish, the candle low becomes a sell trigger. A state flips to BUY or SELL only after a candle closes beyond the stored trigger while the condition remains valid. If the indicator reverses, the pending trigger is dropped and recreated on a subsequent flip. Neutral readings keep the current state.

A general trigger is created only when all enabled indicators align in BUY or SELL on a clos...

πŸ‘‰ Read | Signals | @mql5dev
πŸ‘14πŸ”₯7❀6
This article frames price, returns, and equity curves as random processes: functions indexed by time, where a chart is just one sample path. The practical goal is separating structure from noise using definitions that make assumptions explicit and testable.

It introduces cross-sections, trajectories, and finite-dimensional distributions as the core way to reason about increments, autocovariance, and autocorrelation without β€œinfinite-dimensional” machinery. Key diagnostics become time-dependent functions: mean, variance, covariance, and correlation.

The classification focuses on what matters for modeling: discrete vs continuous time, discrete vs continuous state space, stationarity (strict vs wide-sense), stationary/independent/uncorrelated increments, ergodicity as a justification for backtests, and Markov structure as β€œmemory length,” including the tric...

πŸ‘‰ Read | AlgoBook | @mql5dev
πŸ‘19❀9πŸ”₯5🀩3
RiskLotCalculator is an MT5 script that calculates position size so a stop loss hit matches a defined account risk percentage. After attaching it to a chart, set risk percent and stop loss distance in points; a chart panel displays the computed lot size along with money at risk and required margin.

The script uses OrderCalcProfit() to estimate the loss for 1.0 lot from entry to stop loss, relying on platform handling of tick value, contract size, and account currency. This keeps the logic consistent across forex, gold, indices, and crypto without per-symbol parameters.

Risk amount is derived from the selected base (equity, balance, or free margin) multiplied by the risk percent. The resulting volume is floored to the symbol’s volume step and constrained to min/max lot to avoid exceeding the requested risk. Warnings are shown if broker minimum volume imp...

πŸ‘‰ Read | NeuroBook | @mql5dev
❀14πŸ‘10πŸ”₯6🀩4πŸ‘¨β€πŸ’»2✍1⚑1
This piece adds a proper feature-screening stage to MT5-style pipelines, focusing on overlapping forward returns where standard permutation tests break. Shuffling the target assumes observations are exchangeable; with 20-bar overlapping labels and persistent features, it produces extreme false positives even on true nulls.

A calibrated null is built with resampling that preserves dependence: circular shifts (optionally constrained to hour-of-day) behave near the nominal error rate, while stationary bootstrap requires explicitly chosen block lengths and can be badly oversized.

The implemented three-gate screen separates concerns: (1) stationarity via paired ADF+KPSS to avoid single-test blind spots, plus rolling stability diagnostics; (2) entropy as a cheap variance filter to save compute; (3) mutual information with Westfall–Young family-wise correct...

πŸ‘‰ Read | NeuroBook | @mql5dev
πŸ‘12❀5πŸ”₯4
Option chains contain more information than a single implied volatility: the volatility smile encodes a full risk-neutral terminal distribution, often with far fatter tails than lognormal. The article turns that into actionable percentiles by recovering density from call-price curvature (Breeden–Litzenberger), then publishing the 5–95% band.

Because second derivatives amplify bad quotes, the pipeline focuses on robustness: derive the forward from put-call parity (median near-ATM), convert to a Black-76 forward framework, fit a smooth IV curve in log-moneyness, reprice a dense strike grid, then finite-difference to density. It reports diagnostics instead of hiding flaws: negative probability mass, convexity violations, parity spread, and strike coverage.

Implementation is split cleanly: Python writes a small JSON feed per ETF; MQL5 reads it to draw lev...

πŸ‘‰ Read | Forum | @mql5dev
❀12πŸ‘9πŸ”₯5🀩2
MetaTrader 5 tick volume is a per-bar quote-change counter. It reflects time-of-day effects, is incomplete mid-bar, and loses intra-bar timing. A more direct activity measure can be built from inter-quote durations.

The approach uses time between consecutive quote changes, removes the diurnal profile in fixed time bins with interpolation, then models remaining clustering via an Engle-Russell ACD recursion. The output is a per-quote activity ratio: 1 equals normal for that hour, 2 implies double the expected quote pace, 0.5 half.

Implementation details include folding same-millisecond bursts into one event and resetting after long gaps (default 5 minutes). Calibration is pure MQL5 and reports out-of-sample likelihood gains versus a rhythm-only baseline across EURUSD, GBPUSD, USDJPY, XAUUSD, US30, SPX500, with modest but statistically significant inc...

πŸ‘‰ Read | Docs | @mql5dev
❀14πŸ‘10πŸ”₯3🀩3
Bridging β€œdraw this level/pitchfork/fib” from natural language to deterministic EA logic hinges on one contract: a native chart object with a structured, unique name. Producer programs (indicators/scripts) create standard MT5 objects and encode direction, event type (TOUCH/BREAK/ZONE), role, and an ID in the object name so AIObjectTrader can recognize and evaluate them.

Two lifecycles are compared: one-shot scripts that place an HLINE or FIBOTIMES and exit, and a persistent indicator that maintains an OBJ_PITCHFORK while preserving a stable object identity during anchor updates.

AIObjectTrader scans chart objects, performs partial name recognition, dispatches supported geometry (HLINE/TREND/PITCHFORK/RECTANGLE), and tracks per-bar signals. Key boundaries remain: incomplete protocol validation, weak cross-restart identity/ownership, timing approximations, an...

πŸ‘‰ Read | Signals | @mql5dev
πŸ‘16❀9🀩5⚑4πŸ”₯3
This stage extends the double-bottom toolkit from reviewing recorded examples to scanning chart history using reference-guided matching. A candidate must pass strict geometry (separation, depth, symmetry, neckline) and also resemble previously validated library samples.

The search normalizes the price path between the two lows into a fixed-length close/low profile, resampled to a set number of points and scaled by pattern depth. Similarity is computed via RMSE and converted to a bounded score; the mean of the top neighbors must exceed a configurable threshold. Results are labeled CANDIDATE/CONFIRMED/FAILED based on post-formation closes, not trade outcomes.

The EA scans completed bars on the attached symbol/timeframe, filters duplicates, renders selected detections on-chart, and exports REFERENCE_MATCHES.csv with settings, counts, structural metrics, and th...

πŸ‘‰ Read | AlgoBook | @mql5dev
πŸ‘24🀩15❀14πŸ”₯11πŸŽ‰2πŸ‘¨β€πŸ’»1πŸ‘€1