MQL5 Algo Trading
586K subscribers
4.89K photos
7 videos
4.89K 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
Correlation Matrix Dashboard adds a live cross-symbol correlation grid directly on the chart to validate whether a basket is actually diversified. It calculates rolling Pearson correlations from closed-bar returns over a fixed lookback, updating once per new bar to avoid tick-by-tick CPU load on multi-chart setups.

The matrix lists basket symbols on rows and columns. Off-diagonal cells show coefficients from -1.00 to 1.00, with “--” on the diagonal. Shading ranges from neutral near zero to green for positive correlation and red for inverse correlation. Symmetry across the diagonal is expected and acts as a quick consistency check.

Optional alerts trigger when |correlation| crosses a threshold, then re-arm only after dropping back by a hysteresis margin to prevent repeated firing.

Key inputs cover symbol list, calculation timeframe, lookback bars, r...

👉 Read | AlgoBook | @mql5dev
❤15👍10🔥8🤩6😐2
A read-only terminal indicator adds an equity drawdown panel focused on current account state rather than balance. It tracks distance from the equity peak, the deepest drawdown recorded, closed P/L for today, week, and month, and attributes open floating results to the active Expert Advisor via magic numbers.

Rendering is done on a single canvas using the standard Canvas library, with antialiased shapes, smooth transitions, and 1 Hz equity sampling for the last 2.5 minutes. The header supports drag-to-move and a collapse button that reduces the view to drawdown and floating P/L.

Peak equity starts at attach time and updates on new highs. State persists via terminal global variables per account and server. Bonus credit is excluded. Deposits and withdrawals are detected from deal history and rescale the peak to keep drawdown percentage consistent acros...

👉 Read | VPS | @mql5dev
❤10🔥10👍8🤩6
Trade Pad consolidates manual order entry into a single on-chart panel: BUY, SELL, lot control, and four management actions for open positions. UI feedback is immediate via canvas rendering, with each operation confirmed on the panel and written to the journal. The panel can be collapsed into a compact bar showing floating result and dragged by its header.

BUY/SELL place market orders at the current lot, with live Bid/Ask and spread shown. Lot step changes follow the symbol’s volume step and respect min/max, with margin and point value displayed. CLOSE ALL, CLOSE PROFIT, and CLOSE LOSS use a second-click confirmation that arms for three seconds. BREAKEVEN moves stop loss to entry for profitable positions.

Safety controls include click-only execution, disabled state when covered or outside the chart, broker stop-level validation, and terminal trading-stat...

👉 Read | Calendar | @mql5dev
👍17❤9🤩8🔥5👨‍💻1👀1
InfoPanel is a compact chart overlay for tracking key session stats at a glance. It displays the current symbol, time remaining to the close of the active candle, current spread in points, daily ATR in points, and today’s range as a percentage of the daily ATR.

Visual cues are included: spread switches to red when it widens, and the range-used value switches to gold when it exceeds 100%. Inputs cover ATR period, chart corner selection, X/Y offsets, font size, and text color.

The indicator runs on any symbol and timeframe. Resource usage is minimal, using a 1-second timer and four text labels. It produces no signals and is intended for information only.

Deployment: copy InfoPanel.mq5 to MQL5\Indicators, compile in MetaEditor, then attach to a chart and adjust Inputs as needed.

👉 Read | Docs | @mql5dev
👍10❤4🔥4🤩4
Session Clock is a compact chart panel that shows which major FX sessions are currently open, time until the next session opens, and the remaining time on the active candle. It uses a 24-hour GMT dial with Sydney, Tokyo, London, and New York rendered as arcs; open sessions are highlighted while closed sessions are dimmed, with a GMT-driven hand for current time.

The panel includes a central candle countdown with a progress ring, plus a per-session legend listing hours and live open/close countdowns. When the market is closed, the countdown switches to time until the next trading session for the symbol.

Additional readouts include current spread versus an average since load, today’s range versus the 14-day average daily range, and GMT versus server time. Daylight saving time adjusts automatically per region (Europe, US, Australia; Tokyo fixed), verified ...

👉 Read | AppStore | @mql5dev
❤12👍9🤩9🔥8
Order blocks matter only while they hold. A static box does not show whether price already revisited it multiple times or closed through it. This indicator tracks each zone bar by bar, using the chart timeframe or a higher one, and marks zones as fresh, tested, or broken with an explicit visit count.

A zone starts “fresh” in full color. The first return marks it “tested” and lightens the fill; each later return increments the count. A visit is one entry event, not per-bar time spent inside. Break rules are close-based: demand breaks on a close below the bottom, supply breaks on a close above the top; wicks alone do not break.

Block detection uses a block candle plus a run (default five candles), with minimum move and minimum real-body filters, and sizing normalized by average ranges to avoid symbol-specific tuning. Overlapping zones are merged per si...

👉 Read | AppStore | @mql5dev
❤9👍6🔥5🤩5
Framework updates extend the initial CAppliedPrice and CSma set with EMA, SMMA, and LWMA modules. CSma gets a boundary-condition fix for the “exactly N bars” case that previously caused an array out of range on the next tick.

A common CSmoothingBase is introduced to unify buffers, period validation, and an onCalculate contract. The indicator now selects the smoothing method at runtime via an ENUM_MA_METHOD input, instantiating the chosen smoother dynamically through a base-class pointer.

EMA is added using the standard recurrence with a precomputed smoothing factor and a source-based seed. Plot labels are moved from compile-time properties to PlotIndexSetString, producing method-aware labels like EMA(14). SMMA is positioned as Wilder-style exponential smoothing with alpha = 1/period, alongside cost and weighting comparisons across methods.

👉 Read | Calendar | @mql5dev
❤11🤩8🔥7👍6
HistoryExportTester exports Strategy Tester price history to CSV: closed bars for any timeframe and optional tick-by-tick data.

Tester exports are useful because chart history is capped by the “Max bars in chart” setting. The tester is not, allowing multi-year M1 bars or full real-tick periods in a single run.

Usage: select the EA in Strategy Tester, pick symbol and date range. The test timeframe is irrelevant; the export timeframe is an input. For bars, any model works and “1 minute OHLC” is fastest. For ticks, use “Every tick based on real ticks”, otherwise ticks are generated. Output goes to Terminal\Common\Files, or the agent’s MQL5\Files if common folder is disabled.

Files: <symbol>_<timeframe>_bars.csv (time, OHLC, tick_volume, real_volume, spread), closed bars only. <symbol>_ticks.csv (time_msc, time, bid, ask, last, volume, flags).

A gap report lists g...

👉 Read | Quotes | @mql5dev
❤7🔥6🤩4👍1
Clipping was added as a first-class rendering constraint, targeting UI separation issues seen in dashboards: overflowing list rows, plot lines crossing axes, and text escaping button bounds. The mechanism limits drawing by a boundary owned by another widget, rather than modifying the shape.

The implementation reuses per-pixel coverage already produced by the rasterizer. Clip coverage and shape coverage are multiplied in the inner Fill loop, enabling anti-aliased rectangular and path clips, nesting via repeated multiplication, and predictable artifacts such as edge darkening from conflation in self-clips, thin geometry, and deep clip stacks.

Supporting pieces include SCairoRect for bounds, NaN-safe emptiness checks, half-open containment, rectangle intersection/union, exact path bounds from flattened vertices, and hit-testing using the same scanline crossing...

👉 Read | Freelance | @mql5dev
❤15🔥9👍7🤩4👨‍💻1
An educational example implements an opening-candle setup around the New York session open. The EA waits for the M5 bar aligned to 09:30 New York time (often 16:30 server time on NY-close brokers). A trade triggers when the candle body exceeds total wick size and tick volume is above 1.5x the 20-bar average, then a single position is opened in the candle direction.

Risk controls are straightforward: one trade per day, at most one open position, fixed SL/TP in price units (defaults 30/120, scaled by symbol price), and a time-based forced close. Position sizing can be risk-based via stop distance or fixed-lot, with margin-aware downscaling. No martingale, grid, averaging, or hedging logic is used.

Backtest notes: Strategy Tester results on USTEC M5 (every tick, 2025) show 91 trades, net +2,559 on 10,000 deposit with 100 risk per trade, PF 1.41, 29.7% win rate...

👉 Read | Docs | @mql5dev
👍9❤7🔥5🤩3🎉2
Multi-currency EAs are not a “trade more symbols” problem. Concurrent EURUSD and GBPUSD exposure concentrates USD risk, so portfolio allocation, correlation control, and unified limits become mandatory.

MetaTrader 5 build 6060 adds an AI Assistant in MetaEditor with MCP support. It can generate MQL5, compile, fix errors, and run Strategy Tester passes, turning EA prototyping into an iterative research loop with logged decisions.

A prototype portfolio EA was assembled: S1 breakout, S2 mean-reversion, and an experimental S6 pair module (disabled). Supporting scripts computed correlations, regime stats, and spread screening. Backtests produced mixed results, with the assistant rejecting weak configurations and fixing self-introduced defects.

Key outcome: a reproducible framework with risk layers and audit requirements, not a verified profitable system.

👉 Read | Docs | @mql5dev
👍13❤12🤩6🔥5🏆2
RoundNumbers plots horizontal price levels at round-number increments around the current visible range, such as 1.1000/1.1050 on EUR/USD, 2650.00 on gold, or 30500 on an index. These levels often align with clustered orders and can highlight areas where price action changes pace.

The indicator renders a dotted minor grid line at each step and a thicker solid line at every tenth step for major figures. Step size can be fixed or calculated automatically from the chart zoom, keeping the number of lines on screen under control. Levels update with scrolling and rescaling, and only the visible area is processed to limit resource use.

Configuration includes fixed step (0 for automatic), maximum on-screen lines for auto mode, and styling for minor/major lines. Installation: copy RoundNumbers.mq5 to MQL5\Indicators, compile, then attach to a chart. This is a ...

👉 Read | Freelance | @mql5dev
👍9❤4🔥2🤩1👀1
Part 3 adds an alert layer to the existing managed-trendline lifecycle, reusing state transitions instead of re-detecting market events. Touch, bounce, break, and resurrection alerts are emitted only when the state machine moves between specific states, keeping lifecycle logic as the single source of truth.

The design records transitions inside CManagedTrendline (previous state + pending-change flag), then CTrendlineManager translates supported transitions into alert events and forwards them to a dedicated CTrendlineAlert component.

CTrendlineAlert focuses on filtering and delivery: per-event toggles, separate switches for manual vs auto-generated lines, and independent popup/push channels. Messages are standardized with symbol, timeframe, source, direction from slope, price context at dispatch, and object name, enabling actionable notifications w...

👉 Read | NeuroBook | @mql5dev
❤13👍9🤩5🔥4
MA Toolkit provides a reference implementation of SMA, EMA, and LWMA with explicit calculations instead of relying on built-in averaging calls. SMA uses the arithmetic mean of the last N prices, EMA applies the smoothing factor 2/(N+1) and initializes from the first historical price, and LWMA weights the newest bar at N down to 1 for the oldest.

Two lines are plotted simultaneously: a configurable fast MA and a slow MA. The fast line is slope-colored with a flat-threshold option, while the slow line can be hidden without disabling crossover logic. Crossover arrows mark fast/slow intersections, and an optional alert triggers once per bar based on the last closed candle only.

Computation is optimized to update only new and forming bars. Inputs cover MA types, periods, applied price, arrow offset, panel text, and display toggles. Notes include EMA histo...

👉 Read | Freelance | @mql5dev
👍7❤5🤩5🔥3
CDropList implements a drop-down list for MQL5 charts as a composite control, wrapping multiple chart objects behind a single API. It coordinates creation, positioning, visibility, and deletion for the main block (border, background, label, chosen item, button) and the opened list (background, arrows, item cells).

Lifecycle is handled via Create() and Destroy(), with CreateDrop()/DestroyDrop() controlling the opened state. Object naming is isolated through a required unique prefix to avoid collisions across instances.

Item management keeps m_items_names and m_current_mode consistent through AddItem(), DeleteItem(), and SelectedItem(). Layout and appearance changes go through Refresh(), which updates only changed properties and closes any open list to avoid stale geometry.

ChartEvents() integrates with OnChartEvent(), returning explicit action codes fo...

👉 Read | Signals | @mql5dev
👍13🤩12❤7🔥5
Position Tool adds a Long/Short Position drawing to MetaTrader 5 with visual trade planning and automatic position sizing. It renders entry, stop, and target zones and recalculates risk metrics on every mouse drag, including lot size, cash risk, projected reward, reward-to-risk, point distance, and margin impact.

P/L per lot is derived from OrderCalcProfit(), keeping calculations consistent across Forex, metals, indices, and crypto CFDs, regardless of account currency. Volume is rounded down to the symbol’s step to prevent configured risk from being exceeded, with a MIN LOT > RISK warning when applicable.

On attach, it initializes at current price with a 1x ATR(14) stop and a 2:1 target. Entry moves the whole structure; entry endpoints adjust width. Dragging target across entry flips Long/Short automatically. Controls include mirror (Long/Short) and ...

👉 Read | CodeBase | @mql5dev
❤6🔥6👍5🤩4🤓2
Stop-out risk is the one exit an EA cannot control when stop loss is missing or distant. The margin level is visible, but the price distance to stop-out and the effect of a new order are not. Grid and averaging systems need that threshold, and common linear estimates break on FX conversion and on margin behavior.

CStopOutGuard models positions for one symbol and computes the first tick-grid bid where the account model reaches the stop-out level. It uses OrderCalcProfit() and OrderCalcMargin(), scans within ±50% of current bid, then refines with bisection. Results include SOG_OUT_OF_RANGE and SOG_ALREADY_BELOW.

Tester runs on MetaQuotes-Demo showed key details: USDJPY profit conversion depends on the valuation price, margin tiers increase per-lot cost with total side volume, and Strategy Tester kept margin fixed at fill-time for open positions. A recorder...

👉 Read | Forum | @mql5dev
❤14👍7🤩6🔥5
Previous Day High, Low, and Close levels remain common intraday reference points. The prior day’s High and Low define the range extremes, while the Close indicates where the session settled. Price frequently reacts around these areas, making them practical for breakout, reversal, and target planning.

The indicator reads daily bars and draws PDH/PDL/PDC using chart objects rather than buffers. Levels are rebuilt only on the arrival of a new daily bar, which keeps runtime overhead low. Current-day levels can be extended right; historical levels are rendered as day-length segments when InpDaysBack is greater than 1. Labels print the level name and price at the left edge.

Key inputs include toggles for High/Low/Close, DaysBack (1–100), right extension, per-level colors, styles (dash for High/Low, dot for Close), width, and label settings. Operation follows br...

👉 Read | NeuroBook | @mql5dev
❤6👍6🔥6🤩4⚡2
Native SFTP over SSH-2 is implemented directly in MQL5 sockets, removing the need for external tools like WinSCP scripts. The client targets SFTP v3 with X25519, Ed25519 host keys, AES-128-CTR, HMAC-SHA2-256, and no compression, and rejects servers that disable required algorithms.

Security is enforced with host key fingerprint pinning and signature verification during KEX. Strict key exchange is advertised to mitigate Terrapin, but not required. Packet handling validates lengths before MAC checks and performs constant-time MAC comparison.

A reporting EA writes daily CSVs locally, while a separate service uploads completed files via a temp “.part” flow, logs SHA-256 and timings, and applies exponential backoff. Strategy Tester edge cases (missing OnTradeTransaction close) are handled via end-of-test reconciliation keyed by opening deals.

👉 Read | VPS | @mql5dev
👍12🤩12❤9🔥5
This article adapts the Bi-directional Adaptive Temporal (BAT) architecture from event-based vision to financial markets, treating ticks and microstructure reactions as an asynchronous event stream rather than fixed “frames”. Raw events are packed into voxel-style temporal layers so a model can operate on a dense, structured tensor instead of noisy irregular updates.

Key building blocks include multiscale encoding to capture micro-moves and regime shifts, bidirectional temporal correlation to align past and future segments, and adaptive temporal sampling to change the step size as volatility accelerates or slows. Spatially adaptive aggregation filters inconsistent signals into a stable motion feature, then iterative refinement progressively sharpens the movement estimate.

On the implementation side, a top-level MQL5 object (CNeuronBAT) integrates ...

👉 Read | Docs | @mql5dev
👍18🤩9❤8🔥8
This article implements a dead man’s switch for MetaTrader 5 EAs that fail silently: the host EA periodically sends a compact “health beat” to an external relay, while a separate guardian EA polls the relay and runs an independent state machine.

Unlike a simple “I’m alive” ping, the beat includes actionable vitals: health flags, tick age, AutoTrading/trading readiness indicators, and position metrics for a magic number. The relay timestamps beats on its own monotonic clock, persists state across restarts, tracks sequence gaps, and treats boot-id changes as clean restarts.

The guardian distinguishes “relay unreachable” from “host dead,” confirms over multiple polls, latches DEAD until rearmed by a run of advancing sequences, and can alert or execute breakeven/flatten using live PositionsTotal()/POSITION_MAGIC. A disarm/arm endpoint supports planned maintenan...

👉 Read | AlgoBook | @mql5dev
👍25❤10🔥5🤩5