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
An MT5 Fibonacci retracement indicator for XAUUSD, FX, indices, and any symbol, drawing levels on the last confirmed leg. Swings are confirmed using a configurable swing length, requiring closed bars on the right side before a high/low is accepted. The most recent two confirmed swings define the active leg; direction is derived from which swing came first.

Retracements include 23.6, 38.2, 50.0, 61.8, and 78.6, with 61.8 in a separate color and optional 127.2/161.8 extensions. Level prices can be printed beside each line, with configurable style, width, and right-side extension.

Options include scanning a fixed bar window or forcing β€œlast completed leg” logic, plus an optional 61.8 touch alert firing once per bar. Three hidden buffers are provided for automation: swing high, swing low, and direction (1/-1), updated on the last bar and readable via iCustom...

πŸ‘‰ Read | Freelance | @mql5dev
πŸ‘25❀16🀩13πŸ”₯7πŸ’―1πŸ‘€1
An MT5 EA implements a two moving average crossover entry on the last closed bar. Default parameters are EMA 20 vs EMA 50 on close, with configurable method and applied price. On a confirmed cross it opens a single position in the cross direction, with optional reverse signals.

Trade management supports stop loss and take profit in points, and an option to close on the opposite cross. A breakeven module can move SL to entry plus an offset after a defined profit distance, respecting broker stop levels.

Position sizing supports fixed lots or risk-based lots (percent of balance or equity). Risk modes require SL enabled. The EA enforces a max concurrent position count, checks free margin before sending orders, and limits actions to its own symbol/magic positions. Points must be adjusted to symbol digits (e.g., XAUUSD 2 vs 3 decimals). Range conditions will prod...

πŸ‘‰ Read | CodeBase | @mql5dev
❀29πŸ‘17🀩13πŸ”₯11πŸ’―4πŸ‘2πŸ‘Œ2
A risk calculator indicator can be used to quantify position risk and adjust exposure by changing stop-loss distance.

After loading the indicator, a red stop line is plotted at a default offset of 300 pips from the current price.

To change the stop level, double-click the red line to activate selection, then click and hold to drag it to the intended stop-loss price.

Once the stop line is placed, the tool updates and displays the corresponding position size (lot value) based on the configured risk parameters.

πŸ‘‰ Read | Forum | @mql5dev
❀21πŸ‘15🀩12πŸ”₯6πŸ‘2πŸ’―2πŸ‘€1
Daily rollover often brings a short liquidity gap where bid-ask spreads can expand 5x to 15x within seconds while mid-price remains stable. That behavior can trigger pending Buy Stops, hit tight stops on shorts, or push floating equity below a daily loss limit around midnight.

Broker Rollover Spread Logger records rollover spreads tick-by-tick and provides an EA pause signal via iCustom. On attach, it seeds a daytime baseline from up to 240 historical bars outside the rollover window, capping seeding spreads at 50 points to avoid skew. During normal hours the baseline is maintained with an outlier-filtered exponential average.

During the configured window, any tick exceeding InpSpikeMultiplier (default 3.0x baseline) and InpMinSpikePts sets Buffer 0 to 1.0 on bar 0. Buffers: 0 guard flag (BLOCK/SAFE), 1 current spread points, 2 peak spread for the active o...

πŸ‘‰ Read | AlgoBook | @mql5dev
❀21🀩13πŸ”₯12πŸ‘11πŸ‘¨β€πŸ’»3⚑1
This article fixes a common MT5 pitfall: creating subwindows and objects from an indicator without properly tying their lifecycle to the indicator instance. MT5 blocks adding the same indicator twice, but changing inputs allows new instancesβ€”revealing orphaned subwindows when an indicator is removed.

The solution is explicit cleanup using ChartIndicatorDelete, with consistent naming shared across files via an include header to keep maintenance manageable as the project grows.

It then hardens behavior with chart events: enable object-deletion notifications, detect CHARTEVENT_OBJECT_DELETE, and react deterministically (remove the indicator that owns the deleted object). Unique, traceable object names plus a simple comparison operator prevent collisions with user-created objects and make ownership checks reliable.

πŸ‘‰ Read | NeuroBook | @mql5dev
❀16🀩14πŸ‘13πŸ”₯8⚑5😈1
Scalping EAs often look stable in the MT5 Strategy Tester but fail live because execution is shaped by microstructure friction: spread expansion, latency-driven price drift, and order-book slippage. On small targets, these costs can consume nearly all edge and flip expectancy after commission.

The article presents a pre-trade gatekeeper (CFrictionGuard) that blocks orders when observable conditions imply poor execution. Instead of a static spread limit, it combines tick-based price velocity, tick arrival rate, and adaptive spread anomaly detection (Welford variance transitioning to EWMA) into a Friction Ratio that compares total costs to projected short-horizon movement.

Implementation focuses on deterministic OnTick performance: pre-allocated ring buffers, single-pass statistics, a four-regime state machine (optimal/moderate/locked/spike), and safety ...

πŸ‘‰ Read | Quotes | @mql5dev
🀩15❀13πŸ‘12πŸ”₯5😁3
Gradient support is added by replacing a constant ARGB fill with a paint abstraction that can be queried per pixel. The rasterizer keeps the existing edge coverage mask and asks Paint::ColorAt(x,y) when compositing.

Paint.mqh defines a minimal base class with one virtual method and a virtual destructor. Solid color becomes the simplest paint implementation, not a renderer special-case. Fill keeps the old uint overload by wrapping it in a reusable solid paint instance.

Most gradient logic is isolated outside Raster.mqh. Gradients share a stop list (positions 0..1 plus ARGB) stored as parallel arrays, kept sorted on insertion to avoid per-pixel sorting. Sampling clamps to pad-extend, supports hard edges via duplicate positions, and interpolates alpha along with RGB.

πŸ‘‰ Read | VPS | @mql5dev
πŸ‘23❀8🀩7πŸ”₯5
Rolling forecast filters in MQL5 can be built around Diebold–Mariano with HAC long-run variance, short-sample correction (HLN), and Clark–West for nested AR benchmarks.

A practical implementation scores forecasts only after the h-bar horizon closes, handles overlapping errors, and converts one-sided p-values into a trade gate. Output includes an EA, indicator, and per-bar CSV for replay and audit.

Tests on XAUUSD, EURUSD, GBPUSD (H1/M15, h=3, 250-bar rolling window) show all three models (EMA slope, linear regression channel, AR(3) on 300 bars) had higher full-sample RMSE than a zero-return random walk. The random walk was significantly more accurate in most comparisons. Gating reduced exposure sharply; profitability was not established as statistically significant under these settings.

πŸ‘‰ Read | VPS | @mql5dev
❀12πŸ”₯9πŸ‘8🀩6
Most MQL5 monitoring ends at terminal logs and Strategy Tester reports. Once an EA depends on external services, correlating decisions and latency across processes becomes manual and unreliable.

A native OpenTelemetry OTLP tracer for MQL5 is implemented as a client-only design. It generates W3C trace IDs/span IDs, produces nanosecond-formatted timestamps, and exports OTLP/HTTP JSON via WebRequest(), with no gRPC or protobuf dependency.

Instrumentation is layered: core clock/IDs/sampler, tracer with span stack and RAII scope guard, and an exporter with a bounded ring queue plus retry/backoff. OnTimer() performs blocking WebRequest() calls; spans enqueue without blocking, overwriting the oldest on overflow.

An EMA-cross EA and a Python scoring service share trace context via the traceparent header, allowing Jaeger to render one end-to-end timeline per b...

πŸ‘‰ Read | AppStore | @mql5dev
πŸ‘12❀11πŸ”₯7🀩7✍1
Order block detection for XAUUSD and any symbol: the zone is defined as the last opposite candle before a structure break. Last bearish candle before a close above a confirmed swing high, or last bullish candle before a close below a confirmed swing low. The zone can be drawn as full range (high to low) or body only.

Leg validation uses an impulse filter: at least one candle body in the leg must exceed a configurable ATR multiple (default ATR 14, multiplier 1.0). This reduces zones created by slow drift. Swings are confirmed only after bars on both sides close, so zones appear with a delay and do not repaint.

Zone lifecycle: fresh zones are highlighted, tested zones are dimmed on first return, and zones are removed when a candle closes through them. History scan defaults to 1500 bars, with limits for maximum live bullish/bearish zones and optional re...

πŸ‘‰ Read | NeuroBook | @mql5dev
❀9πŸ‘8🀩7πŸ”₯5
Chimp Optimization Algorithm (ChOA) extends GWO by using four leaders (attacker, barrier, chaser, driver) and updating each agent from all four simultaneously. A β€œsocial motivation” term adds optional chaotic jumps, but this component is often harmful in continuous search.

A continuous BChimp implementation reuses the ChOA core and focuses on coefficient dynamics. The published binary variant can hide issues because sigmoid thresholding collapses scale and sign.

A key defect is bias in A: using Ak = f(2*c1gk*rand - 1) yields E[Ak] = f(c1gk - 1), creating systematic drift toward bounds and diagonal motion. Fixing this with Ak = f*c1gk*(2*rand - 1) restores zero-mean steps and stable convergence.

The tested setup keeps four-leader elitism, resamples coefficients per coordinate, and drops chaotic replacement for continuous benchmarks.

πŸ‘‰ Read | AppStore | @mql5dev
πŸ‘16❀10🀩8πŸ”₯4✍3πŸ†1
G7 Pro Trade Manager & Prop Firm Equity Protector is an on-chart trade management utility for manual trading on MetaTrader 5, focused on fast execution and rule-based risk controls. The interface runs directly on the chart and supports scalping and funded-account workflows.

Core functions include one-click BUY/SELL with pre-set SL/TP in pips and an on-chart lot sizer. Automated management covers breakeven moves after a configurable profit threshold, plus trailing stops that activate and follow price by defined distances.

For prop-firm style limits, a daily drawdown circuit breaker tracks the day’s starting balance versus live equity. When the configured loss threshold is hit, positions can be force-closed and trading locked until the next day. Emergency actions include breakeven-all, partial close, close-profit only, and close-all. Configuration supports symbol...

πŸ‘‰ Read | Docs | @mql5dev
πŸ‘11❀10πŸ”₯7🀩2
An MLP gate can be trained directly inside an MQL5 Expert Advisor to avoid the Python export workflow and its operational failures: scaler mismatches, feature drift, missing weight files, and tester discrepancies.

The design targets a compact 2-class MLP (ReLU + softmax) retrained every N bars on the current symbol/timeframe, using only closed-bar inference (shift=1). Behavior when untrained is controlled via InpMlpFailOpen.

Integration keeps the existing pipeline intact: RSI divergence generates direction, HTF filter validates context, and the MLP acts as the final accept/reject step based on P(up)βˆ’P(down) exceeding InpMlpThreshold for the candidate direction. Features are local (RSI, ATR, EMA(50), session sin/cos), with labels built from forward movement over InpMlpHorizon without live-edge leakage.

Trade-offs: CPU cost in tester/optimizer, seed determi...

πŸ‘‰ Read | Docs | @mql5dev
❀13πŸ”₯13πŸ‘8🀩3πŸ‘¨β€πŸ’»2
Smart Money Concepts workflows often require monitoring several timeframes and maintaining consistent zone markup. G7 Institutional SMC Radar is an MT5 indicator focused on XAUUSD scalping and prop-firm style execution, providing automated zone detection and a confluence-style confidence readout for manual decisions.

The tool auto-draws bullish/bearish Fair Value Gaps and ICT Order Blocks, extends them forward, and removes zones after mitigation to reduce chart clutter. A heads-up display outputs a 0–100 confidence score based on structural alignment between detected zones.

A background DXY correlation module is included to help validate directional bias. Recommended attachment is M15 or H1, then waiting for higher confidence readings (for example, 70%+) before executing manual entries. The package is positioned as an analytical dashboard rather than an a...

πŸ‘‰ Read | Freelance | @mql5dev
πŸ‘43πŸ”₯28❀21🀩18πŸ‘€6⚑1πŸ‘Ύ1
G7 FVG OB Confluence AutoTrader is an MT5 algorithmic trading utility built around strict OB/FVG overlap validation. Trade signals are only considered when an institutional Order Block and an unmitigated 3-bar Fair Value Gap coincide at the same price structure, with configurable overlap tolerance.

The engine scans M15 order blocks via impulse displacement (>1.6x ATR) and tracks active imbalances. A 6-factor on-chart score (0–100%) aggregates NY-session USD news filtering, DXY correlation alignment, imbalance status, liquidity sweep detection, order block state, and an overall weighted confidence with score capping on structural conflicts.

Execution is handled from a chart HUD with one-click buy/sell, lot sizing, SL/TP edits, auto-exec toggling, breakeven-all, and close-all. Risk controls include daily loss shutdown, daily profit lock, spread filt...

πŸ‘‰ Read | Quotes | @mql5dev
πŸ‘37πŸ”₯33❀28🀩22⚑3
This article tackles a common MT5 usability problem: users delete a chart object created by an indicator, and earlier implementations removed the entire program. The proposed approach keeps the indicator running and automatically recreates the missing object.

It starts with a minimal fix: listen for object-deletion events and rebuild the object. Testing reveals subtle issues: repeated pointer initialization can leak memory, and OnDeinit can accidentally trigger recreation via queued events. The corrected version guards pointer reuse and disables event handling during shutdown.

A more practical refinement stores key object state (position and size) inside the object-managing class. When deletion is detected, the indicator restores the object using saved properties, balancing effort against fidelity.

πŸ‘‰ Read | Calendar | @mql5dev
πŸ‘47❀43πŸ”₯30🀩27⚑3✍1πŸ€”1
G7 Account Inspector Pro is an on-chart account diagnostics and risk auditing dashboard for MetaTrader 5. It targets prop firm evaluation workflows, EA-driven trading, and discretionary portfolio monitoring with real-time performance and exposure metrics.

The interface toggles between a compact HUD and a full multi-column panel. It also calculates an account health score (0–100) based on core factors such as profit factor, max drawdown, win rate, and return-to-risk, with letter-grade output.

Behavioral metrics cover execution mix (EA vs manual via magic number), grid-style exposure, scalping turnover, lot sizing variance, and overnight/weekend holding. A compliance auditor tracks daily and total drawdown against configurable limits, with CSV export for historical reviews.

Key inputs include initial panel state, chart anchoring and offsets, daily/tot...

πŸ‘‰ Read | AppStore | @mql5dev
πŸ‘42🀩39❀28πŸ”₯26
Time-based OHLC appeared as a storage and reporting compromise when trades were sparse. As activity grew, bars and candlesticks added High/Low while keeping data volume manageable, scaling cleanly across timeframes.

In signal processing, Nyquist-Shannon shows that undersampling a periodic signal destroys frequency and amplitude information. Similar loss can occur when market data is sampled by clock time instead of event intensity.

Exchange pricing is discrete by tick and lot, but price is not driven by time. It reacts to trades, order book updates, and participant repricing. Fixed time bars therefore bundle a variable number of market events, making volatility and pattern statistics non-stationary across instruments and across years with different microstructure and algo participation.

πŸ‘‰ Read | Signals | @mql5dev
❀64πŸ‘40πŸ”₯38🀩32πŸ‘¨β€πŸ’»8πŸ†3πŸ‘€2
Trading sessions are rendered as rectangles from configured start to end hours, spanning the highest high and lowest low printed within each session. Labels can be enabled to show the session name plus its high above the box and low below it; New York labels sit inside the box due to overlap with London.

Sessions in progress expand as new highs or lows are formed. Hours are defined in broker server time (whole hours), not local time or GMT. Defaults target common GMT+2/GMT+3 servers with US DST: Tokyo 02–11, London 10–19, New York 15–24 (server time).

Sessions may cross midnight by setting an end hour lower than the start. Rendering is limited to M1–H1; H4+ is skipped. Non-trading days are ignored, historical boxes do not repaint, and all chart objects are removed on indicator unload. Optional fill draws behind candles; otherwise outlines are used.

πŸ‘‰ Read | VPS | @mql5dev
❀45πŸ”₯39πŸ‘26🀩7πŸ‘Œ5✍3πŸ‘¨β€πŸ’»2
Session Ranges + ADR Panel consolidates key intraday context: session highs/lows for Asia, London, and New York, current-day movement versus Average Daily Range, remaining time on the active candle, and live spread. Session boxes include high, low, and range labels, with overlap visibility and a distinct London/New York overlap color.

High/low calculations are sourced from a lower timeframe (default M5) for precision on M1–H1 charts, with optional hiding above a chosen timeframe. Sessions can cross midnight, and completed session boxes remain fixed with no repainting; only the active session expands as new extremes print.

The ADR panel tracks the last N completed days, today’s range, % of ADR with 70%/100% thresholds, and ADR remaining. Updates run every second, even without ticks. Units support pips, points, or raw price with auto pip sizing and optional...

πŸ‘‰ Read | VPS | @mql5dev
❀38πŸ”₯10🀩10πŸ‘9πŸ‘Œ3πŸ‘€1