MQL5 Algo Trading
553K subscribers
4K photos
6 videos
4K 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
Grid and martingale often look profitable in backtests because results are dominated by completed cycles. Profit factor and expected payoff can be positive per cycle while the equity curve trends up.

The failure mode is the same: an unfinished cycle appears when margin, max orders, or trend length breaks assumptions. One large adverse move offsets prior gains and closes the sequence at a net loss.

Simple MT5 EAs with fixed steps (grid) and recursive sizing (martingale) typically reproduce this behavior. Spread and execution costs then push the long-run outcome further negative, even when many cycles finish in profit.

The core math frames both as zero-expectancy without edge on direction, with blow-up risk concentrated in rare tails.

πŸ‘‰ Read | Freelance | @mql5dev
❀28πŸ‘7🀩5πŸ”₯3🀯1πŸ‘¨β€πŸ’»1
IronHawk Fibonacci Structure Map applies Fibonacci levels only to confirmed swing highs and lows, then validates those levels with higher-timeframe alignment. It calculates key retracement and extension levels and compares them across up to three timeframes.

When multiple Fibonacci references cluster within a volatility-adjusted distance, the tool groups them into a confluence zone using ATR-based rules. Levels include 23.6, 38.2, 50, 61.8, 78.6, 127.2, and 161.8. Zones are context markers, not trade signals, and are intended to focus attention on price reaction.

Additional outputs include basic market-structure context, Premium/Discount around the active swing, and the nearest level with distance from current price. Configuration covers timeframe selection, lookback, swing depth, per-level toggles, ATR period, cluster sizing, minimum overlaps, view ...

πŸ‘‰ Read | CodeBase | @mql5dev
❀23πŸ‘11πŸ”₯3🀩2πŸ‘Œ2🀣2
Work described: pattern search in FX data, automated generation of Expert Advisors, and measurement of how long detected patterns remain statistically usable.

Method focus is brute-force coefficient search versus neural-network map search. Both reduce to selecting parameter bytes, but brute force keeps a fixed algorithm and varies a simple coefficient array, while NN varies a larger strategy representation with higher compute and stronger dependence on implementation quality.

Core model uses a bounded multidimensional Taylor polynomial over recent candles, with inputs based on (Close[i]-Open[i]). Positive output maps to buy, negative to sell, with optional sign inversion and a tunable signal threshold.

Optimization is staged: first, coefficient arrays are ranked on next-bar direction metrics (expected payoff or profit factor). Second, full-period ...

πŸ‘‰ Read | AppStore | @mql5dev
❀79πŸ‘12🀯4πŸ”₯3🀩3πŸ‘2πŸ†2
A compact Renko context indicator displays the active Renko direction, count of consecutive confirmed bricks, fixed brick size, last confirmed Renko close, and the exact price level where a reversal becomes confirmed. It also reports the remaining distance to that reversal level measured in bricks, with an optional dashed horizontal line on the chart.

The internal model is built from recent tick history. Continuation confirms after price moves one full brick beyond the last Renko close. Reversal is confirmed only after a two-brick move against the current direction: for an UP run, reversal = last close βˆ’ 2Γ—brick size; for a DOWN run, reversal = last close + 2Γ—brick size.

The goal is to prevent treating minor counter-moves as reversals. No buy/sell signals are generated, and no prediction logic is included. Configuration covers brick size in points, tick...

πŸ‘‰ Read | AppStore | @mql5dev
❀26πŸ‘2πŸ‘Œ2⚑1🀩1
GDS Renko Bricks renders a fixed-size Renko view directly inside a standard MT5 chart window, without relying on offline charts or custom symbols. Brick formation is driven by tick data, producing completed bricks in real time.

The display keeps uniform brick width and hides the usual time scale, since construction is based on price movement. Reversals follow a two-brick logic consistent with classic Renko rules.

Configuration is minimal: a single Brick Size input. The selected chart timeframe acts only as a host and does not affect Renko generation. Example: on XAUUSD, Brick Size 1.00 produces $1 bricks. No DLLs or external libraries are required.

πŸ‘‰ Read | CodeBase | @mql5dev
❀22πŸ‘7πŸ‘Œ2πŸ‘¨β€πŸ’»2🀩1
System logic uses two internal Renko streams built from BID ticks. A slow stream defines direction, while a fast stream provides the entry trigger. Both apply classic two-brick reversal rules, and entries are permitted only when fast and slow directions match.

Exits are handled by a small target, stop, opposite fast Renko reversal, or a maximum holding time. After closing, a short cooldown in Renko bricks blocks immediate re-entry. Only one position per symbol is allowed, and a spread filter blocks entries when spread is large relative to the fast brick.

Default inputs: Fast 21, Slow 39, Entry Run 1, TP 1.4 fast bricks, SL 2.1, Max Hold 200 minutes, Cooldown 3, Max Spread Fraction 0.57, Lots 0.01.

Example tester run (XAUUSD, M1 host, real ticks, 2026-05-01 to 2026-08-24): 79 trades, +589.34 USD, PF 2.27, max DD 1.18%, win rate 64.56%. Historical demonstrat...

πŸ‘‰ Read | AlgoBook | @mql5dev
❀19πŸ‘8πŸ”₯2πŸ‘¨β€πŸ’»2⚑1πŸ‘Œ1
An EA implementation that constructs fixed-size Renko bricks directly from BID ticks, using classic two-brick reversal confirmation. A confirmed DOWN->UP reversal defines a support zone; a confirmed UP->DOWN reversal defines a resistance zone.

Entries require displacement: price must move away from the new zone before any retest qualifies. On a return to the zone, a completed Renko brick confirming rejection triggers an order. Each zone is tradable once, with a single active position per symbol. Exits occur via TP, SL, opposite reversal, or maximum holding time. A spread filter blocks trades when spread is large relative to brick size. No DLLs, external libraries, custom indicators, custom symbols, or offline Renko charts; the chart timeframe is only a host.

Defaults: Brick 18.0; Zone half width 1.65; Move away 0.90; Max age 53 bricks; TP 5.50; SL 2.90; Hold 6...

πŸ‘‰ Read | Forum | @mql5dev
❀22πŸ‘9πŸ”₯2πŸ‘¨β€πŸ’»2✍1πŸ€”1πŸ‘Œ1
This article connects sorting/searching basics to core data structures that make trading code faster and easier to reason about in MQL5: queues, as a foundation for later lists and trees.

It first builds a FIFO queue using a dynamic array with two operations: append at the end and restore from index 0. Removing index 0 triggers a shift, preserving insertion order and providing a clear β€œempty” return value.

It then upgrades to a circular queue (ring buffer) with fixed capacity, using read/write indices that wrap around. New data overwrites the oldest when full, avoiding costly shiftsβ€”ideal for sliding-window indicators like moving averages and other stream-processing tasks in MetaTrader 5.

πŸ‘‰ Read | AlgoBook | @mql5dev
❀17πŸ‘7πŸ”₯4⚑3🀩3
This article tackles a practical UI gap in MT5 replay/simulation: restoring deleted Stop Loss and Take Profit directly from the chart, without relying on terminal dialogs.

The approach uses a draggable price line and derives the intended SL/TP from context (position side and relative level), while snapping to the symbol’s tick size by reusing the existing mouse indicator’s normalized price.

On the EA side, two new events are added and routed through a single SL/TP modifier. A key detail is passing negative values to mean β€œkeep the current server-side value”, forcing a fresh PositionSelectByTicket and preventing accidental deletion of the other leg.

On the indicator side, interaction is rebuilt around C_Mouse instead of C_Terminal, with explicit hitboxes (e.g., close button) to make chart-only control deterministic for traders and developers.

πŸ‘‰ Read | NeuroBook | @mql5dev
❀15πŸ‘7πŸ”₯4😁1πŸ‘Œ1πŸ†1
MetaTrader 5’s History Navigator is extended from one-off date/time jumps into a persistent β€œhistorical bookmarks” system for repeatable chart research.

Each bookmark captures symbol, timeframe, timestamp (not bar index), plus a user-defined name and optional notes, so the original chart context can be reconstructed reliably even as history loads or shifts.

Persistence is handled by a dedicated CBookmarkStorage layer that serializes records to a small CSV file, validates input on load, and keeps UI logic out of file I/O. Updates are written immediately, with rollback on save failure to prevent memory/file divergence.

The existing NavigateToDateTime() engine is reused for both manual date navigation and bookmark recall, avoiding duplicated bar-search and chart-positioning logic while adding create/select/go-to/delete workflows in the dialog.

πŸ‘‰ Read | CodeBase | @mql5dev
❀20πŸ‘3🀩3πŸ†3πŸ‘Œ2
MT5 Strategy Tester covers automated backtests, but manual price-action review still lacks an interactive bar-by-bar replay mode. A replay tool can hide future candles, reveal one bar at a time, and allow decision-making without hindsight bias.

A practical MQL5 design uses DRAW_COLOR_CANDLES with buffers initialized to EMPTY_VALUE, then progressively filled to reveal candles. Controls include an ON/OFF toggle, a draggable vertical anchor for the start point, Play/Pause, and Buy/Sell for a single paper trade with Entry/SL/TP lines.

Core logic combines OnChartEvent() for UI and drag handling with OnTimer() for timed playback, viewport tracking, price line updates, and TP/SL monitoring. Deactivation restores original chart properties and removes all replay objects.

πŸ‘‰ Read | VPS | @mql5dev
❀19πŸ‘5πŸ”₯2πŸ‘Œ2
Part II extends queues into LIFO behavior by converting a FIFO implementation into a stack with minimal changes: only the read/remove point is adjusted, while insertion order stays intact.

It also notes that stacks mirror how CPUs manage call frames, which makes the data structure relevant beyond textbook exercises.

The text then moves from arrays to lists in MQL5. Because pointers to structures are restricted, classes are used to model nodes, enabling a singly linked list that behaves like a stack without relying on arrays.

Key takeaway: internal implementation can vary, but a stable interface determines usability and outcomes.

πŸ‘‰ Read | Signals | @mql5dev
❀11πŸ‘8🀩1πŸ‘Œ1
MetaTrader 5 ZOrder cannot be overridden in a reliable way, so the focus shifts to using the platform event sequence to identify the real click target.

A minimal indicator shows the pattern: CHARTEVENT_MOUSE_MOVE is emitted before CHARTEVENT_OBJECT_CLICK. With overlapping objects, this order remains consistent and can be used to gate interaction.

Code updates consolidate priorities: keep default 0 and add ePriorityNull for non-interactive objects. This requires recompilation and small fixes in classes such as C_ChartFloatingRAD.

Input handling is adjusted by adding a state flag in C_Terminal and checking validity on MOUSE_MOVE, then accepting OBJECT_CLICK only when the click is marked valid and the object name matches. This avoids foreground checks and reduces dependency on manual ZOrder management.

Next step prepares multi-position and pending-ord...

πŸ‘‰ Read | Quotes | @mql5dev
❀11πŸ‘8πŸ”₯3🀩1πŸ‘Œ1
Prop-firm sizing is a constrained optimization problem: the trade size must reflect both signal strength and the remaining daily/overall drawdown budget. Because these limits are path-dependent and sometimes expand with locked-in profit, static fractional or Kelly-based sizing cannot react correctly without live account state.

The refactor takes a previously firm-specific PropFirmAwareSizer and separates program terms from sizing math. A frozen PropFirmRuleSet captures variable rules (phase targets, fixed vs dynamic daily cap, news profit-credit haircut, drawdown basis, overnight policy). PropFirmAccountState becomes stateful and rule-driven, while pure functions stay unit-testable.

Key technical gain: correct handling of equity- vs balance-based drawdown checks, and explicit branching for dynamic daily limits. Validation compares the new implement...

πŸ‘‰ Read | Quotes | @mql5dev
❀13πŸ‘9🀩2πŸ”₯1πŸ‘1πŸ‘Œ1πŸ‘¨β€πŸ’»1
A trade management panel defines batch order actions with configurable entry count for BUY and SELL buttons, opening positions based on lot size and selected entries.

Risk and cleanup controls include Close Profit (closes all profitable orders), Close Loss (closes all losing orders), and Close ALL (closes every open order). Set All TP and Set All SL apply a single take-profit or stop-loss value across all active orders.

Operational tools include trailing stop on/off, Buy Pending and Sell Pending using an input price to place limit orders, and Delete Pending to remove all pending orders. Close Above and Close Below close orders based on a user-defined price threshold.

Key parameters cover trailing timer frequency, optional break-even for orders without SL, default trailing behavior, pending-order TP/SL in pips, and a lot size calculator using risk percent a...

πŸ‘‰ Read | VPS | @mql5dev
❀15πŸ‘8πŸ”₯2🀩1πŸ‘Œ1
Classic fixed-size Renko is generated internally from BID ticks, using the standard two-brick reversal rule. SuperTrend ATR and band values are computed from completed Renko bricks rather than time-based candles.

Trade entries are permitted only when the latest completed Renko brick direction matches the Renko-based SuperTrend direction. Position exits can be triggered by take-profit, stop-loss, a SuperTrend direction change, or a maximum holding-time limit. An optional short cooldown can be enforced before re-entry.

Risk controls include a strict one-position-per-symbol rule. The EA runs standalone with no external indicator, DLL, custom symbol, or offline chart requirement. A separate visual companion indicator is available at https://www.mql5.com/en/market/product/175340.

This is intended as an educational historical demonstration; default settings are not...

πŸ‘‰ Read | AppStore | @mql5dev
❀13πŸ‘6πŸ’―3πŸ‘Œ2
Spreads get checked routinely, swaps often get ignored. One overnight hold can exceed the entry spread, and long vs short swap can differ by an order of magnitude depending on the instrument.

A utility script prints swap cost in account currency within seconds. Per open position it shows tonight’s swap for the exact size, plus accumulated swap paid and holding days.

Per symbol (position symbols first, then visible Market Watch) it reports swap per night for 1.0 lot for long and short, the annualized cost using 360-day convention, the implied broker markup per side as (|long|+|short|)/2, and the triple-swap weekday.

Swap modes in points, deposit currency, or interest-rate formats are converted when reliable. Otherwise raw values are shown with currency notes or β€œn/a”. Optional inputs include Market Watch scanning, symbol cap, and an on-chart summary.

πŸ‘‰ Read | AppStore | @mql5dev
❀11πŸ‘7πŸ‘Œ2⚑1🀩1
Multi Timeframe Trend Matrix delivers a quick view of trend state from M5 through D1.

Each timeframe is computed from fast and slow EMAs, current price position, and ADX strength. Green tiles indicate price above both EMAs, fast EMA above slow EMA, and ADX at or above the configured threshold. Red tiles require the inverse conditions. Neutral tiles appear when neither full trend rule set is satisfied.

Implementation focuses on efficiency. Indicator handles are created once during initialization and reused. Panel updates run on a timer to keep charts responsive and prevent per-tick handle churn.

Key inputs cover fast/slow EMA periods, ADX period and minimum ADX, optional closed-bar confirmation, plus panel layout, colors, and refresh rate. This is an analysis dashboard only; it does not place trades or forecast results.

πŸ‘‰ Read | Freelance | @mql5dev
❀16πŸ‘7🀩2πŸ‘Œ1πŸ‘¨β€πŸ’»1
Market Structure Swing Map is a chart analysis tool designed to show price structure with minimal on-screen noise. It marks confirmed swing highs and swing lows, then classifies each new point versus the prior point of the same type as HH, HL, LH, or LL.

All calculations are based on closed candles. A swing is printed only after the configured number of candles confirms it on both sides, keeping past markings stable and avoiding forward-looking signals. An optional structure line can connect confirmed points to improve readability of the sequence.

Key settings include Swing Strength (confirmation candles per side), Maximum Bars (history scanned), optional swing price display, optional structure line, and alerts for newly confirmed structure points. The tool does not place, modify, or close trades.

πŸ‘‰ Read | AlgoBook | @mql5dev
❀26πŸ‘7πŸ”₯1🀩1πŸ‘Œ1πŸ†1
Session Liquidity Map visualizes intraday structure by drawing separate boxes for the Asia, London, and New York sessions, then marking the high and low formed within each defined window. Session times are configured in broker/server time to avoid implicit timezone conversions.

Each session range can print its size in points. High and low levels can be extended beyond the session close for follow-up liquidity reference. Historical boxes are supported, and the active session updates on every new candle.

Key inputs include start/end times per session, Lookback Days for history depth, Show Range Text for point display, and Extend High Low plus extension length. Daylight saving and local time are not adjusted automatically, so session windows should be aligned to the trading server clock.

πŸ‘‰ Read | AlgoBook | @mql5dev
❀17πŸ”₯3πŸ‘2πŸ‘¨β€πŸ’»2