MQL5 Algo Trading
579K subscribers
4.63K photos
7 videos
4.64K 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
Educational use only; not trading advice. EURUSD backtests under the stated conditions were unprofitable.

Strategy logic uses New York local time. The first 4H candle defines the initial high/low range. After that candle closes, the system waits for a 5-minute close outside the range, then a 5-minute close back inside. Close above high then back inside triggers a sell signal. Close below low then back inside triggers a buy signal.

A time filter invalidates signals if price remains above the high or below the low for more than 75 minutes, intended to avoid late entries after an extended move.

Correct broker time configuration is required. Parameters include winter/summer server GMT offsets, server switch dates for summer and winter time, and lot size. A single DST or offset mismatch can shift the entire session alignment.

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #Strategy
❀27πŸ‘Œ3⚑1πŸŽ‰1
A Python-based Strategy Tester is extended toward MetaTrader 5 parity by adding sequential tick/bar playback, account and position monitoring, and reportable performance analytics.

Configuration is moved into JSON to mirror MT5 settings (symbols, timeframe, date range, modelling, deposit/leverage). The tester validates required keys and datatypes to prevent silent misconfiguration.

Four modelling modes are implemented: real broker ticks, synthetic ticks generated from M1 bars, new-bar execution (fast, least granular), and 1-minute OHLC (speed/accuracy compromise). A unified OnTick loop calls the EA callback per tick or per bar-open, while updating orders, positions, and account state.

The tester logs orders and deals, then produces an HTML report with core metrics (profit, win rates, drawdown, factors) and plots balance/equity curves, enabling practical st...

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #Strategy
❀42
Part 47 extends the prior liquidity sweep/BOS EA with a Nick Rypock Trailing Reverse (NRTR) system in MQL5.

NRTR signals come from an ATR-based channel. A buy triggers when an up-support level appears after being EMPTY_VALUE on the prior bar; a sell triggers on the first down-support. Optional hedging allows opposing exposure, with MaxPositions enforcing caps.

The implementation loads the iCustom NRTR indicator, copies multiple buffers with retries, and centralizes execution in OnTick with new-bar gating. It adds auto/fixed sizing based on balance, equity, or free margin, ATR or points SL/TP, trailing modes, reversal exits, and virtual SL/TP closures.

πŸ‘‰ Read | Signals | @mql5dev

#MQL5 #MT5 #Strategy
❀36πŸ‘6
Better MQL5 code often comes down to habits, not years of experience.

Strong forum culture matters: critique code only after understanding intent, and provide explanations that teach. Dropping unclear snippets encourages copy-paste fixes, spreads bad patterns, and leads to wrong answers and unfair reviews.

Adopt a growth mindset. Complex EAs, advanced math, and adaptive models become approachable through steady practice and reading real source code.

Keep code lean and intentional. Remove unused blocks and variables to reduce bugs, speed reviews, and make debugging easier.

Treat mistakes as training data. Try multiple approaches before posting, document what was attempted, then understand the fix to prevent repeats. Progress in algo trading development is incremental, built through iteration, experiments, and helping others.

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #Strategy
❀75πŸ‘9πŸ‘Œ6⚑4🀑4πŸ”₯2🀨1
This tool upgrades trendline analysis in MT5 by replacing ZigZag pivots with swing points extracted directly from raw price action. Swings are detected via local high/low dominance, then filtered by a minimum size threshold or ATR-adjusted volatility, keeping only meaningful structural turns.

Validated swings are ordered by time to preserve structural consistency and reduce repaint-like behavior. Trendlines are built only when swing relationships align with market direction: descending highs for resistance and ascending lows for support.

Candidate lines are scored by touch count, recency, and tolerance-based β€œrespect” checks, then only the most significant support and resistance rays are drawn. The result is a cleaner chart and a repeatable way to work with sloped structure, useful for discretionary structure reading and algorithmic context filters r...

πŸ‘‰ Read | Signals | @mql5dev

#MQL5 #MT5 #Strategy
❀30πŸ‘Œ2⚑1
Risk-management module update: new enums, structures, and constants added to support daily limits, position accounting, and dynamic per-trade risk.

Dynamic risk now adjusts assigned_percentage based on balance drawdown from an initial balance. Initial balance can be fixed (prop firm) or captured at startup (personal account). Thresholds must be sorted; a loop-free counter-based method requires ordered activation levels. A CHashMap approach is recommended to preserve key-value mapping during sorting.

Balance-check timing is configurable via enum: per-tick checks (accurate but noisy) or checks on trade close (lighter but less granular). Dynamic-risk modes include full custom strings, fixed numeric parameters (up to four steps, optimizer-friendly), or disabled.

Daily limit exceedance criteria are selectable: equity only, closed P/L only, or combined. Trade ac...

πŸ‘‰ Read | Calendar | @mql5dev

#MQL5 #MT5 #Strategy
❀35✍3πŸ‘2πŸ‘Œ2πŸ†2⚑1πŸ€”1
This article upgrades a liquidity-zone strategy that can signal both directions by adding a simple directional anchor: an EMA(50) trend filter. The goal is to treat liquidity zones as trend-continuation pullbacks, not reversal points, reducing low-probability countertrend trades.

Core rule set: place buy limits only when a demand zone forms above the EMA; place sell limits only when a supply zone forms below it. Profit targets are focused on recent swing highs/lows aligned with market structure.

On the MQL5 side, the filter is implemented as a dedicated, stateful module (TrendFilter.mqh) that owns the iMA handle, reads closed-bar values (shift 1), exposes β€œbuy allowed/sell allowed” permissions, initializes in OnInit, and releases resources in OnDeinit. This keeps OnTick clean, reusable, and safer during testing.

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #Strategy
❀42πŸ†3
Breakeven in MT5 is a practical stop-management technique: once price moves into profit by a defined threshold, Stop Loss is shifted to the entry price (optionally plus extra points) to avoid turning a winning move into a full loss.

The article outlines three activation models: fixed points, ATR-based distance that adapts to volatility, and Risk-Reward triggers that protect trades at milestones like 1:1.

On the implementation side, it builds a reusable CBreakEvenBase: a ticket registry with price_to_beat and breakeven_price, automatic vs manual modes, and OnTradeTransaction integration to track entries/exits and call CTrade::PositionModify safely.

The first derived class, CBreakEvenSimple, implements the fixed-points variant with two parameters (trigger distance and extra offset) using MqlParam-based configuration for extensibility.

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #Strategy
❀37πŸ‘2πŸ‘Œ2
A cyclical life-development model is being circulated as a numeric matrix (3, 7, 39, 49), positioned as a synthesized framework combining psychological and sociological views, with esoteric references. It is presented as conceptual rather than scientific.

The 3-year unit is described as a repeating learning loop: initial exposure, friction and correction, then integration and stable competence. The 7-year unit is framed as an identity shift that restructures priorities and values, not just skills.

Composite periods include 49 years as seven consecutive 7-year phases (from early dependency through social integration, crisis, responsibility, and meaning), and 39 years as 13 completed 3-year cycles, mapped to peak material/social consolidation with risk of stagnation without new goals.

The model treats crises as boundary conditions between cycles and ...

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #Strategy
❀32πŸ‘Œ2πŸ”₯1
Larry Williams’ Hidden Smash Day is treated as a two-step reversal: a β€œsmash” bar that hints at exhaustion, then a next-session confirmation that proves it. The pattern is defined by where the close lands inside the bar’s own range plus a close-to-close comparison, not by breaking obvious prior highs/lows.

Bullish setup: higher close than the prior bar, but the close sits in the bottom 25% of its range (optional filter: close below open). Bearish is the inverse, with the close in the top 25%.

The EA formalizes this into testable MQL5 rules: evaluate only on new-bar open, require confirmation by a full bar close beyond the smash bar’s high/low, support long/short/both modes, and enforce one position at a time. Risk is reproducible via structure-based or ATR-multiple stops, plus fixed lots or percent-risk sizing.

πŸ‘‰ Read | Freelance | @mql5dev

#MQL5 #MT5 #Strategy
❀40πŸ‘Œ3πŸ†2πŸ‘€2🀑1
Combining Moving Average trend direction with Average True Range can improve trade timing by aligning entries with prevailing momentum and current volatility.

Pivot Point levels add structured support and resistance zones that can be used to validate breakouts, fades, and stop placement around nearby levels.

Take Profit and Stop Loss lines help convert analysis into defined execution rules. Targets can be set to reflect ATR-based ranges, while stops can be placed beyond invalidation points to reduce noise-driven exits.

Market regime changes, scheduled news, and liquidity conditions should be evaluated before relying on static levels. Consistent position sizing and adherence to a written plan remain central to risk control.

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Strategy
❀41πŸ‘Œ4πŸ‘2
Coral Reef Optimization (CRO, 2014) models a 2D NΓ—M reef where each occupied cell holds a candidate solution with an objective-based fitness. Initialization uses rho0 to set starting occupancy, then iterates reproduction, settlement, cloning, and depredation until a stop criterion.

Core stages: broadcast spawning selects an Fb fraction for paired crossover (often averaging plus small noise). The remaining corals brood via mutation. Each larva attempts settlement up to k times, taking empty cells or replacing weaker incumbents. Asexual reproduction clones the top Fa fraction. Depredation removes the worst corals with probability Pd.

An updated CROm variant modifies destruction using inverse power law sampling near top solutions, targeting faster convergence on multimodal benchmarks.

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #Strategy
❀28πŸ€”2πŸ‘Œ2
Trend detection gets a practical upgrade by reworking the Abbe criterion for market data. The core idea is comparing dispersion of prices with dispersion of bar-to-bar changes: trends inflate overall spread while short-step movement stays relatively stable.

To reduce spike sensitivity on short windows, variance is replaced with robust estimates: median, MAD, and absolute differences. Trend β€œstrength” is then ranked using historical distributions (CDF), turning raw deviations into comparable probabilities.

Direction is handled separately with a Kendall-based measure, then combined with the robust Abbe signals for entry/exit rules. Further variants address edge anomalies, add a linearity ratio (net move vs total path), and explore hybrid non-parametric criteria using sorting and SMA-order comparisons to capture both direction and magnitude.

πŸ‘‰ Read | Calendar | @mql5dev

#MQL5 #MT5 #Strategy
❀45πŸ†5⚑4πŸ‘Œ4πŸ‘€4
Quantitative FX portfolios often fail on systemic correlation rather than individual trade logic. Trading multiple USD-cross pairs can concentrate risk on USD even when each setup appears independent. A single USD event can trigger clustered stop-outs across the book.

The Institutional Currency Exposure Monitor is an on-chart dashboard that aggregates every open position, decomposes each pair into base and quote legs, and computes true net exposure per currency in lots. Example: Long 1.0 EURUSD and Short 0.5 USDJPY yields separate net direction for EUR, USD, and JPY.

The display flags concentration risk by showing net long as positive and net short as negative. A configurable warning state highlights currencies exceeding a lot-based threshold.

Compatible with manual and automated positions, and supports both netting and hedging account modes. Dashbo...

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #Strategy
❀32πŸ‘Œ4🀯2πŸŽ‰2
Lead/lag analysis measures whether moves in one asset tend to precede moves in another, even when correlation or cointegration already exists. The practical target is low-frequency windows (1 minute and above), where fill quality and slippage are manageable and the edge comes from analysis, not routing latency.

A common method is cross-correlation on log-returns, shifting the leader series by N bars and looking for a statistically consistent peak. This can support mean-reversion setups in cointegrated pairs, and momentum signals in weaker relationships.

Implementation detail matters. SQL engines can be non-deterministic without explicit ordering, especially with columnar storage and parallel reads. Window functions must use OVER (ORDER BY time, row_id). Time-aligned JOINs are required before shifting, to avoid comparing mismatched sessions or missing...

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #Strategy
❀27πŸ‘Œ3
Singular Spectrum Analysis (SSA) is a time-series method for decomposing data into trend, periodic components, and noise without requiring stationarity. The workflow is deterministic and linear-algebra based.

Core stages: build a Hankel trajectory matrix from sliding windows, apply SVD to obtain rank-1 elementary matrices (eigentriples), group components into signal and noise, then reconstruct via diagonal averaging.

Forecasting uses a linear recurrence derived from selected singular vectors, applied to the reconstructed signal only. Practical notes: SSA often extracts cycles hidden by noise, but cannot reliably separate deterministic trends from stochastic drift (e.g., random walk).

In MQL5, Basic-SSA can be implemented with OpenBLAS SVD (SingularValueDecompositionDC); results align with SingularSpectrumAnalysisForecast, suggesting a similar baseli...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Strategy
❀54πŸ‘Œ5
StopLossManager.mqh defines a stop loss and trailing stop utility class for automated trading systems, with strict compilation settings and versioned module metadata.

The interface standardizes stop loss calculation through an enum-driven dispatcher supporting fixed pips, ATR-multiplier, swing high/low with buffer, and percent-of-price models. Results are returned as a structured payload containing normalized price, distance in points and pips, plus validity and error details.

Trailing logic is separated via a second enum and includes fixed-distance trailing, ATR-based trailing, step trailing, and breakeven-only behavior. The class also exposes take profit calculation by risk/reward ratio and conversion helpers for pips, points, and price, while accounting for symbol digits and broker stops-level constraints.

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #Strategy
❀31πŸ‘Œ4
Fractional differentiation solves a core preprocessing trade-off in financial ML: returns enforce stationarity but destroy price-level memory, while raw prices preserve context but break stationarity. By differencing with a real-valued d between 0 and 1, the series can pass stationarity tests while retaining more of the original structure needed for mean-reversion and trend models.

The method uses binomial-series weights generated efficiently via a recurrence. Two implementations matter: expanding windows can introduce artificial drift as the lookback grows; fixed-width fractional differentiation (FFD) truncates weights by a threshold, applies a consistent window, and avoids drift.

The practical workflow searches for the smallest d that achieves stationarity using the ADF test, typically via binary search, while monitoring correlation to quantify ret...

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #Strategy
❀40πŸ‘3πŸ†3πŸ€”2πŸ‘Œ2✍1
A common rule-based approach in indicator-driven trading uses arrow signals for entries and a central reference line for exits on an existing position.

An arrow is treated as a directional trigger to open a long or short trade. The middle line is then used as the close condition, typically when price crosses it or when the indicator state returns to neutral.

This setup separates entry logic from exit logic and can reduce churn from frequent signal flips. Practical use still requires clear definitions for confirmation, stop-loss placement, and behavior during ranging markets, since both arrows and midline crosses can lag or repaint depending on implementation.

πŸ‘‰ Read | AppStore | @mql5dev

#MQL5 #MT5 #Strategy
❀28πŸ‘Œ5✍3πŸ‘2
Markets behave less like Gaussian random walks and more like noisy fractal systems: heavy tails, volatility clustering, and scale invariance make linear risk metrics unreliable. Fractal tools model this β€œwild randomness” and explain why similar structures appear across timeframes.

The Hurst exponent quantifies long-memory (trend persistence vs mean reversion) and links directly to fractal dimension, giving a practical switch for trend-following or counter-trend logic. Multifractal methods (MF-DFA and variants) extend this by measuring how small and large moves scale differently; spectrum width can proxy complexity and tail risk.

Chaos and fractal market ideas frame prices as constrained by attractor-like regimes, with structure breaking during crises. For MT5 developers, these metrics can drive regime filters, adaptive stops/position sizing, and ML f...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Strategy
❀35πŸ‘5πŸ”₯2πŸ‘Œ2