MQL5 Algo Trading
574K subscribers
4.44K photos
7 videos
4.44K 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 Expert Advisor implements an opening-range breakout variant for 24-hour markets, tuned by default for XAUUSD. The chart timeframe is irrelevant; logic reads M1 and D1 directly, with M1 mainly useful for visual testing.

At the configured session start (08:00 London by default, mapped to server time with DST handling), the open is captured and entry levels are set using either a โ€œstretchโ€ metric from recent sessions or a multiple of daily ATR. If yesterdayโ€™s candle passes the selected contraction filter, buy-stop and sell-stop orders are placed around the open with opposite-side stops, OCO behavior, and timed order cancellation.

Filters include NR4, NR7, inside day + NR4, 3-bar narrowest range, combined modes, plus optional skip-after wide-range days.

Risk and execution controls cover % risk sizing, daily loss limits, max fills, spread/offset constraints, b...

๐Ÿ‘‰ Read | AppStore | @mql5dev
โค16๐Ÿ‘11๐Ÿ”ฅ10๐Ÿคฉ10๐Ÿ‘Œ1
The article argues that profitable algorithmic trading starts with a measurable edge, not indicator stacking and optimizer-driven curve fitting. It proposes a scientific workflow: detect a price pattern, validate it across symbols and scales, then quantify expected payoff after real trading costs.

Using block charts (price quantized into fixed-point moves), the author finds a consistent tendency: after moving N points, price is slightly more likely to continue than reverse. This โ€œtrend biasโ€ appears across FX, stocks, crypto, and commodities, but weakens at larger scales.

Key implementation risks are highlighted for MT5 robots: signals arrive only on 1โ€‘minute closes, creating entry/exit slippage versus the block close, and spreads/commissions can erase the edge. The suggested fix is to measure continuation probability, slippage distribution, and av...

๐Ÿ‘‰ Read | Calendar | @mql5dev
โค18๐Ÿ‘13๐Ÿคฉ10๐Ÿ”ฅ7๐Ÿ‘Œ1
Manual Trade Pad for MT4 is a chart-based trading panel packaged as an Expert Advisor, focused on manual execution and position management from the chart. It consolidates order entry, sizing, SL/TP setup, and trade management without relying on terminal order dialogs, and supports both live trading and visual historical testing with the same workflow.

Order entry is limited to market BUY/SELL, with Stop Loss defined in points and Take Profit optionally derived from a Risk/Reward ratio. Position sizing supports fixed lots or risk-percentage sizing, with volume normalized to broker min/max and lot-step constraints.

Trade management includes break-even moves with an optional offset, partial close with volume constraints, and bulk closing by direction or all managed trades. Trade ownership is scoped by symbol and Magic Number to avoid interfering with other EAs...

๐Ÿ‘‰ Read | Signals | @mql5dev
โค27๐Ÿ‘7๐Ÿ”ฅ7๐Ÿคฉ3๐Ÿคฏ2๐Ÿ‘จโ€๐Ÿ’ป2๐Ÿ‘Œ1
A combined momentum signal can be derived by tracking the slope direction of MACD, OsMA, AC, AO, and RVI at the same time.

When all five slopes are rising together, it indicates broad alignment across trend and momentum components, with reduced risk of acting on a single-indicator spike. When all five slopes are falling together, it suggests synchronized weakening across the same set.

Implementation typically requires consistent slope measurement per bar (e.g., current minus prior value), a shared lookback and timeframe, and strict handling of flat/near-zero changes to avoid noise. Confirmation rules should define whether โ€œsame timeโ€ means the current closed bar only or a multi-bar window.

๐Ÿ‘‰ Read | Calendar | @mql5dev
โค15๐Ÿ‘10๐Ÿคฉ8๐Ÿ”ฅ4โœ3๐Ÿ‘Œ1
A trend-following trading system can be built around ATR as a volatility-normalized control layer for entries, position sizing, and exits.

Signals typically combine a directional filter (moving average slope, breakout of recent highs/lows, or channel rules) with an ATR-based threshold to avoid noise. Stops can be set at Nร—ATR from entry and trailed using the same multiple, keeping risk proportional across regimes. Position size is commonly derived from account risk per trade divided by ATR distance to the stop.

Key implementation details include using consistent bar indexing, handling gaps, and separating signal generation from execution logic. Validation should cover walk-forward testing, transaction costs, and sensitivity to ATR period and multiplier.

๐Ÿ‘‰ Read | NeuroBook | @mql5dev
โค18๐Ÿ‘14๐Ÿ”ฅ10๐Ÿคฉ6๐Ÿ‘Œ2๐Ÿค1
A good trading system starts with a clearly defined edge, expressed as explicit entry and exit rules that can be executed without interpretation. Signals should be based on measurable conditions, with fixed handling for gaps, slippage, and spread to avoid distorted backtests.

Risk management is mandatory: position sizing, maximum loss per trade, daily and weekly drawdown limits, and rules for stopping after regime changes. Performance evaluation should include out-of-sample testing, forward testing, and robustness checks across instruments and timeframes.

Execution details matter. Order types, latency sensitivity, and broker constraints should be accounted for. Ongoing monitoring should focus on degradation of expectancy, variance shifts, and adherence to the plan, with changes controlled through versioned updates and repeatable validation.

๐Ÿ‘‰ Read | VPS | @mql5dev
๐Ÿ‘15โค9๐Ÿ”ฅ6๐Ÿ‘จโ€๐Ÿ’ป5๐Ÿค4๐ŸŽ‰1๐Ÿ‘Œ1
Gold Fractal Breakout EA for MT5 uses confirmed swing highs/lows to stage Buy Stop and Sell Stop entries. Swing detection is implemented via strict neighbor-bar comparisons, not the built-in fractals indicator. Ownership is filtered by symbol plus magic number, with exits managed through percentage-based rules.

Signal data is always read from H1 via an internal constant, regardless of the chart or tester timeframe. Scans are throttled (default 15 minutes, tick-driven), while position management runs on every tick. Default entry offsets are negative, placing buy entries below swing highs and sell entries above swing lows, but orders still must satisfy stop-order validity and broker stop-distance rules.

Key constraints: pending โ€œexpiry hoursโ€ is calculated but orders are submitted as GTC, so time-based expiration is not implemented. Any open position on the s...

๐Ÿ‘‰ Read | VPS | @mql5dev
โค30๐Ÿ”ฅ8๐Ÿ‘7๐Ÿคฉ4๐Ÿ‘€1
MQL4TradeCompat is a compatibility framework that recreates the classic MQL4 order-centric trading model on top of the native MQL5 execution architecture. It keeps legacy code working with familiar MQL4-style functions while translating operations into Position, Order, Deal, and History APIs.

The facade CMQL4TradeCompat exposes an MQL4-compatible interface and dispatches requests to native trade calls. CLiveTradeInfo acts as a live trade repository, aggregating positions and pending orders into a single collection with MQL4-style indexing, ticket selection, snapshot caching, and chronological ordering. CHistoryTradeInfo reconstructs historical trades from deal chains, including closed-trade aggregation, pending-order history, and profit, commission, swap, and weighted close-price calculations.

Core mapping routes OrderSelect through live/history repositorie...

๐Ÿ‘‰ Read | Quotes | @mql5dev
โค16๐Ÿ‘9๐Ÿ”ฅ7๐Ÿคฉ4๐Ÿ‘Œ1
GDS Renko Trade Manager is an MT5 Expert Advisor focused on stop-loss management for positions opened manually. It builds a fixed-size Renko stream per symbol from broker Bid ticks and advances logic only on completed bricks. No entries are generated, no pending orders are placed, and positions are not closed by this release. Existing TP values remain unchanged when SL is modified.

Core functions include break-even after N favorable completed bricks (optional offset) and Renko-based trailing after M bricks at a configurable gap, without intentional stop loosening. Positions can be filtered by verified manual origin or by exact positive Magic Number. A dashboard tracks BUY/SELL tickets, broker SL, thresholds, and brick progress, with an inset of recent completed bricks.

Operational controls include monitor-only mode by default, single-instance locking per accou...

๐Ÿ‘‰ Read | AlgoBook | @mql5dev
โค14๐Ÿ‘10๐Ÿ”ฅ8๐Ÿคฉ3๐Ÿ‘Œ2
Standalone drawdowns and correlation matrices cannot identify which configuration is responsible for a portfolioโ€™s maximum drawdown. This script computes attribution from daily results and prints a full report in the Experts tab.

Key metrics include drawdown added via leave-one-out, the configurationโ€™s share of the portfolioโ€™s worst peak-to-trough window, and an Euler variance share Cov(x_i,P)/Var(P) shown alongside net profit share. A composite A+ to F score evaluates drawdown compression, risk spread, drag-free share, and return-to-drawdown, then issues KEEP, REDUCE, or REMOVE with recommendations.

Data sources are selectable: a reproducible demo portfolio (12 configs, 520 days), live account deals grouped by magic number (optionally symbol), or CSV input (Date,Config,Profit) with automatic separator and flexible number parsing.

Tuning inputs cover m...

๐Ÿ‘‰ Read | CodeBase | @mql5dev
โค11๐Ÿ‘7๐Ÿคฉ7๐Ÿ”ฅ4๐Ÿ‘Œ2
Randomness can be treated as a testable null hypothesis, not a default assumption. Typical targets include PRNG output and discretized market returns, where the goal is to detect deviations from IID uniform behavior.

A practical approach uses a chi-square test over overlapping s-chains. Counts are collected for (s+1)-tuples across an alphabet of size N, then observed transition frequencies are compared to conditional expectations vi_/N. Under H0, the statistic converges to chi-square with N^s*(N-1) degrees of freedom and is consistent against homogeneous ergodic Markov alternatives of order s.

For market data, a quantile transform helps remove drift by enforcing near-uniform state frequencies, isolating transition structure. On ~1,000 daily EURUSD observations (to 2026-04-03), results were: s=1 p=0.98, s=2 p=0.41, s=3 p=0.02, indicating dependence...

๐Ÿ‘‰ Read | NeuroBook | @mql5dev
๐Ÿ‘12โค10๐Ÿ”ฅ5๐Ÿคฉ4๐Ÿ‘Œ1
S3CE-Net reframes market data as an event stream: irregular tick-level impulses in price, volume, and liquidity that often precede visible trends. Instead of waiting for candlestick patterns, it targets early precursors using spike-guided attention.

The architecture combines SSAM to prioritize meaningful micro-events and suppress noise, with STFS to preserve broader context by sampling across time and the feature axis. For market vectors, โ€œspatialโ€ sampling is redefined as random feature subset selection based on functional relationships, not index proximity.

The implementation in MQL5 uses OpenCL kernels to generate five parallel views (global, temporal, feature, plus two alternatives) and produces separate forecasts per view to avoid averaging away weak but actionable signals. Training stability comes from triplet loss and label-smoothed cross-entropy, improvin...

๐Ÿ‘‰ Read | Forum | @mql5dev
๐Ÿ‘9โค6๐Ÿ”ฅ4โšก2๐Ÿคฉ2๐Ÿ‘Œ1
Part 18 extends the multi-symbol architecture with a shared indicator cache to remove duplicated handle management across strategy nodes.

Multi-symbol EAs often recreate identical MA/ATR indicators per module, repeating BarsCalculated(), Refresh(), buffer reads, error handling, and release paths. When requests match on type, symbol, timeframe, and inputs, this causes duplicate work and unclear ownership during partial init and shutdown.

The cache centralizes creation, readiness gating, data access, and lifetime. Consumers request MA or ATR via a full-parameter identity key; hits reuse an existing entry, misses create a new Standard Library CiMA/CiATR object. Each entry tracks references and request counts, and Release(entry&) applies reference counting with final FullRelease() on last consumer.

Strategy nodes keep independent signal and position state, bu...

๐Ÿ‘‰ Read | VPS | @mql5dev
โค7๐Ÿ‘6๐Ÿ”ฅ3๐Ÿคฉ3๐Ÿ‘Œ1๐Ÿ˜ˆ1
Hermes Agent proposes a tighter alternative to RDP for MQL5 maintenance: a private Telegram bot triggers only explicitly enabled MetaTrader 5 MCP operations on the Windows machine where MT5 is installed (build 6060+).

Requests flow from Telegram to a gateway that validates user IDs, then Hermes maps the message into MCP tool parameters, executes the call in the local terminal, and returns structured output. Terminal logs, compiler diagnostics, and Strategy Tester results remain the source of truth.

The setup emphasizes reproducibility and control: pin the Hermes revision, record versions, keep MT5 running, and start with read-only tools for market data or account history before enabling MetaEditor compile or Strategy Tester jobs. Trading tools stay disabled, and a per-server confirmation gate can require approval for non-read-only actions.

๐Ÿ‘‰ Read | AlgoBook | @mql5dev
๐Ÿ‘13โค7๐Ÿ”ฅ5๐Ÿ‘Œ1๐Ÿ‘จโ€๐Ÿ’ป1
ATR Monitor adds a compact panel that compares the current Day, Week, and Month ranges against each timeframeโ€™s built-in ATR. It also reports whether price is currently above or below each periodโ€™s open. The three rows are shown on any chart timeframe.

Columns include ATR (pips), Range (high minus low, pips), ATR% (Range/ATR*100), and From open (current minus open, pips). ATR% uses the full highโ€“low range, while From open is a separate direction readout with positive/negative coloring and neutral near zero. Readings at or above MaxATRPercent are highlighted; the default threshold is 100% and does not cap the displayed value.

ATR is calculated on the current forming candle (shift 0) for each timeframe and updates on ticks, so it changes during the period. Period boundaries follow broker candles. Range and ATR differ because ATR uses true range and can incl...

๐Ÿ‘‰ Read | Freelance | @mql5dev
โค5๐Ÿ‘4๐Ÿ”ฅ4๐Ÿ‘Œ1
PDF files can render cleanly while carrying structural defects. The content may be correct, while xref offsets, stream /Length, and startxref silently drift after minor edits.

Viewers typically seek from EOF to startxref, jump to xref, read offsets, then locate objects. When these bookkeeping steps fail, many implementations switch to repair mode by scanning for โ€œN 0 objโ€ and rebuilding indexes, often without visible errors unless warnings are enabled.

A practical validator can focus on four generator-critical checks: header at byte 0, startxref landing on โ€œxrefโ€, 20-byte xref entries resolving to โ€œi 0 objโ€, and /Length reaching endstream. Passing these checks is necessary, not sufficient, but it reduces reliance on viewer recovery behavior.

๐Ÿ‘‰ Read | Forum | @mql5dev
โค12๐Ÿ‘8๐Ÿคฉ4๐Ÿ”ฅ2๐Ÿ‘Œ1
A combined setup of sloping native MT4 indicators focuses on trend confirmation, filtering, and timing without adding custom code. Typical combinations use Moving Averages for directional bias, MACD main line slope for momentum, and ADX for trend strength. RSI slope can serve as a secondary filter to reduce entries during range conditions.

Parameter alignment matters more than the indicator count. Smoothing periods should be coordinated so signals do not lag excessively, and slope thresholds should be defined to avoid reacting to noise. Validation should include sideways-market performance, spread impact, and consistent rules for entry, exit, and invalidation.

๐Ÿ‘‰ Read | Freelance | @mql5dev
๐Ÿ‘6๐Ÿคฉ5โค4๐Ÿ‘Œ1
MetaTrader 5 โ€œHistory Qualityโ€ can show 100% in real-tick mode even when large parts of a test actually ran on generated ticks. The key is that History Quality is derived from M1 bar data, while the Strategy Tester journal reports what happened minute-by-minute: real ticks accepted, or minutes marked โ€œabsentโ€/โ€œdiscardedโ€ and replaced with generated ticks.

The tester runs as a mixed stream across the period: accepted broker ticks where they match M1 bars, otherwise synthetic ticks built from each minute bar. Tick files on disk only confirm downloads, not usability for a specific range.

A practical workflow emerges: use the journal line โ€œticks data begins fromโ€ (repeat tests until it stabilizes), and validate from inside an EA by detecting spread changes within a minute and timing patterns that differ between real and generated ticks.

๐Ÿ‘‰ Read | Calendar | @mql5dev
โค14๐Ÿ‘11๐Ÿคฉ6๐Ÿ”ฅ4๐Ÿ‘Œ1
A symbol-agnostic Expert Advisor that trades only the chart instrument, with a hard cap of one position per week. All decisions are derived from closed D1 candles using server time, regardless of the chart timeframe.

Entry rule: evaluated once per week on Monday close. A long is allowed only when Mondayโ€™s close is strictly below the previous trading session close (typically Friday). No other condition can create entries.

Exit rule: any open position is closed at Wednesdayโ€™s daily close, executed on the first tick of the next D1 session. If that close is missed, the next available daily close triggers the exit.

Risk controls: a mandatory percentage stop is placed on entry, widened if required by the symbol minimum stop distance. After 5 failed SL apply/modify attempts, the system issues an immediate market close. No take-profit is used.

Optional entry rest...

๐Ÿ‘‰ Read | AppStore | @mql5dev
๐Ÿ‘8โค7๐Ÿ”ฅ3๐Ÿคฉ2๐Ÿ‘Œ1
Multi-timeframe analysis on MT5 becomes inefficient when charts are switched repeatedly and historical alignment is done manually. Side-by-side charts help, but time positions drift between M1/M5/M15/H1 views.

A prototype synchronization script addresses this by using a timestamp as the shared reference, not bar indexes. It takes the current chartโ€™s first visible bar (minus one), extracts its time, iterates open charts via ChartFirst/ChartNext, filters by ChartSymbol()==_Symbol, and maps the timestamp per timeframe with iBarShift().

Each target chart disables autoscroll, moves to the end, reads visible bar count, computes displacement, calls ChartNavigate(), then redraws. Result: approximate time alignment across same-symbol charts, with known limits around candle intervals and missing history.

๐Ÿ‘‰ Read | Docs | @mql5dev
โค19๐Ÿ‘18๐Ÿ”ฅ8๐Ÿ‘Œ1
ATR Monitor adds a compact volatility and direction panel for Day, Week, and Month on any chart. It compares each periodโ€™s current highโ€“low range with that timeframeโ€™s built-in ATR and shows whether price is trading above or below the period open.

The table reports ATR (pips), Range (pips), ATR % (Range/ATR*100), and From open (pips). ATR % uses the full highโ€“low distance, while From open is directional, with positive and negative values color-coded and near-zero treated as neutral. Readings at or above MaxATRPercent are highlighted; default is 100% and affects highlighting only.

ATRPeriod defaults to 14 and is applied separately to D/W/M. Values use the current forming candle (shift 0), so ATR and range update during the period and follow broker candle boundaries. Range is highโ€“low, while ATR uses true range and can reflect gaps.

Panel position, size, a...

๐Ÿ‘‰ Read | CodeBase | @mql5dev
๐Ÿ‘10๐Ÿ”ฅ6โค4๐Ÿคฉ3๐Ÿ‘Œ1