MQL5 Algo Trading
579K subscribers
4.64K photos
7 videos
4.65K 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
Inversion Fair Value Gaps adds automated fair value gap detection with bar-close confirmation and no repaint behavior.

Gaps are tracked until a candle body closes through the zone, marking an inversion event. After inversion, the tool monitors for bounce reactions off the inverted area and generates signals.

Options include a midline, filled-zone removal, and adjustable color settings for zones and markers. Alert routing is supported via popup, sound, push notification, e-mail, and Telegram.

πŸ‘‰ Read | Docs | @mql5dev
❀37πŸ‘17🀩11πŸ”₯9✍8πŸ‘4πŸ‘¨β€πŸ’»4
Entry/exit points remain the core problem in algorithmic trading because recognizable patterns are usually visible only after the move. Trend and flat regimes are easy to label visually, but unreliable as predictive signals without quantified probabilities.

Price formation can be described via market vs limit orders. Limit orders populate the order book, market orders consume it. Spread is the gap between best bid/ask. Stop Loss/Take Profit placement creates distributed trigger levels that can amplify acceleration or reversal.

From a probabilistic view, discrete ticks imply a random process where expected payoff for random entries converges to zero, excluding spread. Expected value and profit factor can be expressed through conditional events: closing by stops vs signals, with nested probabilities per stop configuration.

Regime detection can be fr...

πŸ‘‰ Read | AlgoBook | @mql5dev
❀78πŸ‘23πŸ”₯15🀩10πŸ‘€7πŸ‘Œ6πŸ‘¨β€πŸ’»2
ZoneUS30 is a simplified Expert Advisor focused on the US30 index and limited to SELL-only execution. The logic targets overextended upside moves where price may revert toward a prior reference area, triggering entries when internal conditions align.

The model combines mean-reversion behavior with the practical impact of swap. When a broker pays positive overnight swap on US30 shorts, holding positions across multiple sessions can add carry while waiting for a correction, without treating swap as the primary edge.

Trading is closer to swing or position holding than scalping, with some trades lasting days. The public build exposes only two inputs: lot size and the signal timeframe; remaining parameters are fixed.

Key risk: this is counter-trend selling in strong uptrends, with potential for extended adverse movement. Swap terms can change by broker rules an...

πŸ‘‰ Read | CodeBase | @mql5dev
❀43πŸ‘7πŸ”₯5⚑3🀩3πŸ‘Œ2
RSI Exhaustion Reversal - EURUSD is an open-source MQL5 Expert Advisor built for strategy research, historical testing, and education. It is restricted to the MetaTrader 5 Strategy Tester and will not place trades when attached to a regular chart. Full source code is included for inspection and modification.

The strategy targets EURUSD on M5 with SELL-only logic. It watches RSI(14) for an overbought exhaustion condition around level 65 during the 14:00–18:00 broker/server-time session. Before entry, spread is checked against volatility using a max Spread/ATR ratio of 0.15.

Risk controls use ATR(14) to size SL and TP at 4x ATR, cap position duration to 96 candles, and enforce a single concurrent position. User inputs are limited to internal timeframe, fixed lot size, and magic number.

Backtests are recommended on real ticks where available; results vary by broke...

πŸ‘‰ Read | VPS | @mql5dev
❀19πŸ‘11πŸ”₯5🀩4πŸ‘Œ2πŸ‘¨β€πŸ’»1
An Adaptive Kalman Trend Filter indicator is designed to reduce short-term price noise and present a clearer view of the underlying trend. It applies Kalman-style state estimation to smooth input data while retaining enough responsiveness to reflect meaningful movement.

The adaptive component modifies the filter’s sensitivity as volatility and market structure change. In lower-noise phases it can prioritize smoothness; during faster moves it can react sooner to shifts in direction.

Typical usage focuses on trend bias, momentum change points, and timing confirmations when combined with risk rules and other signals. As with any filter, parameter selection and out-of-sample checks remain critical to avoid overfitting.

πŸ‘‰ Read | Signals | @mql5dev
❀31πŸ”₯5🀩4πŸ‘3πŸ‘Œ3πŸ‘¨β€πŸ’»2
A specification panel reflects the broker’s current contract report. Broker Contract Change Watch logs when selected contract properties differ from the last saved observation, with a baseline stored per account server, login, and chart symbol.

Watched fields include digits, point size, minimum tick, contract size, volume min/max/step and directional limit, stops and freeze levels. It also tracks trading and execution modes, filling flags and allowed order flags, plus swap mode, long/short swap values, and the triple-swap weekday.

After reattachment or terminal restart, the next valid observation is compared to the saved baseline. A compact panel shows the latest change, volume settings, and stop restrictions. CSV output records local time, property, previous value, and new value. Spread and currency-converted tick value are excluded to avoid routine marke...

πŸ‘‰ Read | CodeBase | @mql5dev
❀19πŸ‘8🀩3πŸ”₯2⚑1πŸŽ‰1πŸ‘Œ1
MetaTrader 5 EAs often keep critical strategy state only in RAM (grid depth, recovery steps, daily counters, online-trained model weights). After a terminal restart, the EA can mismanage existing positions because its internal context is gone.

A common persistence bug is overwriting the live state file: a crash mid-write truncates it, leaving β€œvalid-looking” but wrong data. The proposed fix is atomic-style saving: write to a temporary file, flush/close it, then replace the live file using FileMove, without DLLs.

To detect silent damage from edits or partial copies, the file includes a header with a magic identifier, a format version, and a checksum. On load, the store rebuilds a canonical body and verifies the checksum, returning an empty state if integrity fails.

Beyond scalars, the utility persists double arrays, making it practical to restore rolling statisti...

πŸ‘‰ Read | Forum | @mql5dev
❀19πŸ‘7🀩3πŸ‘Œ1πŸ†1
Refactor proposal for MQL5 divergence logic: extract oscillator, pivot detection, divergence classification, and state tracking from Adaptive SuperTrend into a reusable header, DivergenceEngine.mqh.

The module owns settings, optional RSI handle, buffers, and state (last pivots, divergence type, bars-since). Public access stays narrow: last divergence type, age, oscillator value, reset, and required lookback.

Integration pattern stays consistent across indicators and EAs: init engine, compute lookback, resize buffers, seed boundary at limit+1, refresh RSI buffer if selected, run a backward per-bar loop calling CalculateOscillator and DetectDivergence, then query and act outside the engine, and release on deinit.

Demonstration case uses Parabolic SAR: adapt its Acceleration Factor when an opposing divergence is recent, highlighting reuse without coupling to ...

πŸ‘‰ Read | AlgoBook | @mql5dev
❀18πŸ‘5πŸ”₯2🀩2πŸŽ‰1πŸ‘Œ1
ST-Expert reframes forecasting as a spatiotemporal problem: price history plus a dynamic network of cross-asset links. Using a Mixture of Experts, it shifts weight between specialist blocks as market drivers change, improving resilience, and exposing which relationships influenced a signal.

The article moves from concept to MQL5 implementation by integrating ST-Expert components into Extralonger’s three-route Transformer (temporal, spatial, mixed). A key idea is replacing classic Self-Attention’s Query/Key logits with a graphon-derived connectivity graph, keeping only Value paths.

A new CNeuronGraphAttention module builds attention from ST-Expert graphs, applies SoftMax to produce interpretable weights, and uses residual paths to retain contextβ€”aiming for fewer noise-driven signals when correlations break or rotate.

πŸ‘‰ Read | Docs | @mql5dev
❀16πŸ‘4πŸ”₯2🀩2⚑1πŸ‘Œ1πŸ†1
Media is too big
VIEW IN TELEGRAM
With Model Context Protocol (MCP), AI can work directly with MetaTrader 5 data and tools β€” turning the built-in AI Assistant into an agent capable of handling complex, multi-step tasks.

Analyze markets and trading history, review open positions, work with charts, test and optimize Expert Advisors, and perform supported trading operations β€” all through natural-language instructions.

Instead of manually collecting data and switching between tools, simply describe what you want to achieve and let the AI Assistant coordinate the necessary steps.

Watch the video to see how MCP works in MetaTrader 5 and explore practical AI workflows for trading, analysis, and algorithmic development.

Discuss the video:
πŸ‘‰ MQL5.community for traders
πŸ‘‰ MetaQuotes official YouTube channel
❀28πŸ‘4πŸ”₯4🀩4πŸ€”1πŸ‘Œ1πŸ†1
Running one strategy across multiple symbols and hours creates separate variants, and account-level metrics can hide where performance differs. A dashboard script addresses this by grouping closed deals by symbol and UTC closing hour, then computing win rate and payoff-based edge ratio per cell.

The pipeline reduces each deal to symbol, close-hour, and net profit, aggregates into symbol-hour cells, and renders two CCanvas heatmaps: win rate and edge ratio. Undefined ratios (all wins or all losses) are explicitly flagged and shown as neutral cells, not zero.

Breakeven deals count toward volume but are excluded from win/loss buckets to avoid ratio distortion and divide-by-zero. An Experts-tab table lists best and worst symbol-hour combinations by win rate with minimum-trade filtering. Limitations include linear scans, fixed color boundaries, server-time a...

πŸ‘‰ Read | AppStore | @mql5dev
❀18πŸ‘6🀩2πŸ‘Œ2πŸ‘€2⚑1πŸ”₯1
Adaptive EA design using random graph theory instead of a fixed market map.

A state-transition network encodes each closed bar via EMA spread/ATR, ATR regime, and optional RSI buckets, producing 45 states. Transitions update a decayed, Laplace-smoothed Markov matrix. A k-step matrix power yields the distribution k bars ahead, converted into a bounded directional expectation plus an entropy-based confidence gate.

A second outcome graph manages exits as an R-multiple random walk across milestones. Smoothed survival probabilities trigger closes when the next hop becomes unlikely.

A structural filter binarizes edges above a uniform baseline, measures clustering, then compares it to an Erdos–Renyi G(n,p) null via z-score. Near-zero separation is treated as a β€œstay flat” condition.

πŸ‘‰ Read | AppStore | @mql5dev
❀20πŸ‘5πŸ”₯4⚑2🀩2πŸ‘Œ2πŸ‘€1
Markov chains offer a practical way to model market uncertainty by turning price behavior into discrete states and estimating transition probabilities between them. The key constraint is β€œmemorylessness”: forecasts depend only on the current state, which can still work well for changing, nonstationary conditions.

The article shows two implementations: a simple 3-state regime model (down/flat/up) using a transition matrix, and a richer chain built from price differences bucketed into multiple states. Forecasts can be generated step-by-step via vector–matrix multiplication, with accuracy degrading as multi-step probabilities flatten.

It also extends beyond forecasting: a 2-state win/loss chain updates in real time to adjust expected value and win probability after each trade, enabling adaptive position sizing and risk-aware scenario planning in MT5 s...

πŸ‘‰ Read | Freelance | @mql5dev
❀16πŸ”₯9🀩4πŸ‘Œ2πŸ‘€1
MetaTrader 5 Build 6060 adds an AI Assistant plus MCP support as a native natural-language access layer for development, debugging, chart interaction, testing, and permission-controlled terminal actions. This reduces reliance on WebRequest, local middleware, external APIs, JSON parsing, and related credential and lifecycle management.

MCP changes the integration path, not MQL5 responsibilities. The assistant can generate and review code, but a compiled EA still enforces deterministic signal, risk, execution, and logging rules. Trading permissions remain bounded by terminal AI/MCP settings and separate EA-level switches.

A reference EA, MCP_Accessibility_Assistant.mq5, is built around explicit state output (BUY SETUP, SELL SETUP, WAIT, DATA ERROR), confirmation gating, and audit logging. It uses closed-bar EMA crossover signals, ATR-based stops, reward-to...

πŸ‘‰ Read | VPS | @mql5dev
❀28πŸ‘8πŸ”₯7πŸ‘¨β€πŸ’»4🀩3πŸŽ‰1πŸ‘Œ1
Many EAs persist state in terminal global variables (balances, locks, heartbeats, last trade times). Over time this builds up, while the F3 viewer remains unsorted, unfiltered, and provides no backup. After a restart, diagnosing unexpected behavior often depends on identifying which variable was read.

Global Variable Inspector addresses this with snapshot-based inspection. It filters and sorts variables by name, then prints name, value, last access time, and age to the Experts journal. Whole-number values between years 2000–2100 are additionally rendered as dates to expose timestamp usage. Snapshots can also be exported to CSV, deleted with a mandatory backup step, or restored later via import.

Notable behavior: reading a variable updates its access time and extends expiry. The script avoids refreshing non-matching entries by collecting names and access times...

πŸ‘‰ Read | VPS | @mql5dev
❀19πŸ‘8🀩6πŸ”₯5πŸ‘Œ2⚑1✍1
SensibleGuide_MTF_H1 is an H1 indicator that gates signals through multi-timeframe confluence and explicit risk constraints. Trend is scored via EMA alignment (10/20/50/100/200) with an optional minimum alignment threshold before any setup is considered.

Higher-timeframe modules load closed-bar data only and compute EMA bias plus confirmed swing points for H4, D1, and W1. The CHtf layer refreshes rates and EMA buffers, confirms swings with strength-based validation, and uses binary search to reference the last closed bar at a given H1 close time, supporting non-repainting decisions.

Support/resistance is aggregated into a capped level list: round numbers, H1 swings, long EMAs, Bollinger bands, Fibonacci from the screening timeframe, higher-TF EMAs/swings, and previous day levels. A k...

πŸ‘‰ Read | Calendar | @mql5dev
❀13πŸ‘11🀩7πŸ”₯6🀯2πŸ‘Œ2✍1
Symbol Spec Auditor consolidates contract specification details that affect risk and trading cost into a single on-chart panel. It converts key inputs into money per 1.00 lot in the account currency, then flags broker settings that can break lot sizing or order management without any journal errors.

The panel covers point and tick metrics, contract size, spread cost, margin, swap, volume constraints, execution and filling policies, GTC behavior, stops and freeze levels, and today’s trading sessions. Values that cannot be computed are marked n/a with the reason, and warning rows are highlighted with a one-line consequence.

Common triggers include non-standard contract sizes (e.g., XAUUSD 1 oz vs 100 oz), cent-denominated accounting, tick size not matching point, minimum volume/step forcing rounding, close-only modes, end-of-day order deletion, and unu...

πŸ‘‰ Read | Calendar | @mql5dev
❀23🀩8πŸ”₯5πŸ‘4πŸ‘Œ3✍1
Spread Profile by Hour builds an hourly spread distribution from the broker’s own tick history and presents the median and 90th percentile across 24 server-time hours. Instead of a single per-bar spread value, it aggregates every bid/ask quote over the last N calendar days (excluding today), making rollover, session opens, and news-prone hours visible in the data.

Two sampling modes are supported: tick count (each quote once) and time-weighted (each quote weighted by how long it remained valid, capped at 60 seconds). A weekday filter allows isolating specific days.

A cost view maps median spread to a typical stop size in points, showing the spread as a percentage of 1R per hour, plus an account-currency estimate per 1.00 lot based on tick value and tick size. Current hour highlighting and a live spread line help with intraday context.

Optional CSV exp...

πŸ‘‰ Read | VPS | @mql5dev
❀18πŸ‘7πŸ”₯4🀩4πŸ‘Œ4✍1πŸ’”1
Market Session Pro+ v3 expands coverage to 24 markets, up from the original 12, targeting session-driven short-term price moves such as Gold scalping.

The indicator renders market open and optional close times directly in the chart window. Built-in sessions include New York, Shanghai, Euronext, Tokyo, Shenzhen, Mumbai, Hong Kong, London, Toronto, Zurich, Frankfurt, and Sydney, plus two configurable custom markets.

Session schedules are defined in UTC with per-market offsets and per-region DST rules. Broker GMT offset can be auto-detected or set manually, including minute-level adjustment. Countdowns use server time so timing matches the plotted lines. Weekend handling and sessions crossing midnight are supported.

Visuals include configurable vertical lines, optional session boxes, edge markers, labels with countdowns, hover tooltips, and a sortable i...

πŸ‘‰ Read | AlgoBook | @mql5dev
❀22πŸ‘5πŸ”₯5✍3πŸ‘Œ3⚑1🀩1
GBPJPY β€œMonday” EA: one scheduled long trade per week with fully readable source and no indicators, optimization, or bar-based logic. It runs on a 1-second timer and uses only server day/time, so timeframe selection (M1 to H1) does not affect execution.

Rules are fixed: Monday only, buy at 11:00 server time and close at 23:00 the same day. Positions are flat before rollover to avoid swap. Server time assumes GMT+2 winter and GMT+3 summer; on startup the EA prints the broker offset for manual hour adjustment.

Backtest (2022-01-01 to 2026-09-17): +52.9% on a 10k account at 0.2 lot, 11.2% annualized after $6/lot fees, 7.05% max drawdown, PF 1.86, 59.1% win rate, 242 trades. Profitability persisted with entry shifted across 09:00–13:00.

Guards: skip if spread > 1.5 pips; block entry if margin level would drop below 300%. No stop loss; risk is the full 12-hour mo...

πŸ‘‰ Read | CodeBase | @mql5dev
❀35πŸ‘8🀩4πŸ‘3πŸ‘Œ2✍1πŸ”₯1