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
VelaMayor MTF is a multi-timeframe visualization indicator for MetaTrader 5, aimed at workflows based on multi-timeframe analysis, SMC, price action, and ICT.

It renders the last X candles from a selected higher timeframe (H1/H4/D1) directly on the active execution chart (M1/M5/M15), reducing the need to switch charts while keeping higher-timeframe structure visible.

Rendering supports independent border and fill colors for candle bodies, improving contrast across light and dark themes. Periods are drawn as separate boxes limited to the candles that formed within each timeframe interval, avoiding full-block stretches and preserving spacing between periods.

Wicks are centered and detached to maintain clean boundaries. Candle 0 updates tick-by-tick. Auto-recovery uses chart events and a timer to restore objects after timeframe changes or reconnects. O...

πŸ‘‰ Read | AlgoBook | @mql5dev
❀21πŸ‘15🀩11πŸ”₯5πŸ‘Œ1
Margin Risk Simulator estimates where the current symbol would hit the broker’s margin call and stop out levels, and answers two scaling questions: the margin level after adding X lots, and the maximum extra volume that keeps margin above a chosen safety level. It is analysis-only and never sends, modifies, or closes orders.

Runs as an Expert Advisor to access OrderCalcProfit and OrderCalcMargin; Algo Trading does not need to be enabled. It draws margin call and stop out price lines in both directions, supports netting and hedging, and reads broker thresholds and modes (percent or money) from account properties.

What-if mode adds hypothetical volume at the current price, recalculates levels, and shows dashed lines for the updated thresholds. Max extra volume is rounded to broker steps/limits and requires non-negative free margin. Pending limit/stop orders b...

πŸ‘‰ Read | CodeBase | @mql5dev
❀14πŸ‘12πŸ”₯10🀩8πŸ‘Œ1
GridPro Panel is an open-source grid trading EA for MetaTrader 5 with an on-chart control panel and full MQL5 source. All entry, averaging, and exit rules are visible in code rather than hidden in a compiled file. It targets hedging accounts and will refuse to run on netting margin mode.

The grid supports both sides or a single direction, managing buys and sells as separate baskets. First entry can be immediate or gated by a selectable signal (MA cross, RSI, Bollinger return, Stochastic). Subsequent levels follow fixed-point steps or ATR-based steps, with optional step expansion. Lot sizing supports fixed, multiplier, or arithmetic increase, with caps and optional balance scaling.

Basket exits include money TP, points-from-average TP, trailing money TP, and optional basket SL. Risk controls cover account drawdown stop, daily loss/profit limits, max lots, mar...

πŸ‘‰ Read | AlgoBook | @mql5dev
❀22πŸ‘12πŸ”₯7🀩7πŸ†2πŸ‘Œ1
Indicator update focused on session structure and repeatable statistics.

Asian, London, and New York session high/low boxes are plotted in broker server time, including optional 50% midlines and configurable start/end inputs. Overnight sessions are supported and the tool runs on any symbol and timeframe.

ICT killzones can be shaded in the background, with default windows set to London 07:00–10:00 and New York 12:00–15:00 (server time). Liquidity sweep markers flag cases where price wicks through the Asian high/low and closes back inside the range.

Breakout alerts are provided via popup and push notifications, limited to once per session per side to avoid repeated triggering. A compact statistics panel reports average session range in pips over a configurable number of days.

Operation requires M1 history for accurate box building; allow data to down...

πŸ‘‰ Read | VPS | @mql5dev
❀15πŸ‘11🀩9πŸ”₯5
Buffer Inspector Kb is a utility script for determining which indicator buffer contains a usable signal when wiring indicators into Expert Advisors or alert logic.

After being attached to a chart with indicators already loaded, it enumerates every buffer of every indicator, including calculation and color-index buffers that are not visible in the Data Window. It classifies each buffer as arrows, line, color index, empty, and prints the buffer numbers on-chart near the latest arrow marks. A full report is written on the chart and to the Experts journal.

The Data Window only lists drawn buffers, so hidden color buffers can shift the effective numbering used by iCustom. The script reads buffers via CopyBuffer, so the displayed indices match what an EA must use. It reads closed bars only and warns when visible arrows are likely drawn as objects, which cann...

πŸ‘‰ Read | Freelance | @mql5dev
❀15πŸ‘8πŸ”₯8🀩2πŸ‘Œ1
Risk logic in FixedMACrossover_Part6.mq5 has grown into a 1,000+ line file where roughly 100 lines cover the MA crossover and the rest is safety machinery. Reuse across EAs has required copying large blocks, with validation and configuration spread across init code.

A refactor moves risk management into four headers under MQL5\Include\Risk Management\: shared types/conversions plus three classes by scope: trade (CTradeRisk), basket (CBasketRisk), account (CPortfolioRisk). Trade and basket tiers use config structs with defaults and validation; account keeps setter-style limits disabled until set. EAs include only needed tiers.

Behavior changes are limited: trade-tier checks run before basket/account gates, symbol volume specs with max < min are rejected, logs/comments differ, and inputs validate before indicator handles.

The shared file centralizes a moneyA...

πŸ‘‰ Read | Calendar | @mql5dev
❀10πŸ‘7πŸ”₯7🀩4😁2πŸŽ‰1πŸ†1
Part 2 extends Prop Firm Guard with a persisted daily session baseline, preventing balance reference drift after EA restart or reattachment. A session requires explicit trader confirmation before the starting balance becomes authoritative, and the same confirmed values must restore for the same account and session day.

A daily session model is added via enums for lifecycle state and load results, plus an SDailySession structure stored in SQLite. The session key is derived from a configurable reset hour and minute in broker server time, producing a stable session-date key across rollovers.

SQLite gains a daily_sessions table keyed by account, server, and sessionDate, with consistency checks and UPSERT-based updates. Startup restores an existing session or creates an awaiting-confirmation session without auto-accepting current balance.

Money handling adds ac...

πŸ‘‰ Read | Forum | @mql5dev
❀10πŸ‘10🀩7πŸ’―3πŸ”₯2πŸ†1😈1
S3CE-Net reframes market data as an event stream: sparse, meaningful spikes instead of fixed-interval bars. Built on SEW-ResNet, it adds SSAM spatiotemporal attention to connect causal event dependencies and STFS to adapt features across time and space, aiming to separate structure from noise and reduce reaction to insignificant fluctuations.

The practical focus is implementing SSAM for real-time use in MetaTrader 5 via OpenCL. A CNeuronSSAM layer wraps GPU kernels with neural β€œplumbing”: Q/K/V projection, multi-head attention output, residual path, and normalization, plus an intra-frame relative position bias to emphasize local relationships (useful for price levels, volume clusters, order-flow segments).

Key engineering choices target determinism and speed: static submodules avoid dynamic allocation, buffers are preplanned for OpenCL, temporary sco...

πŸ‘‰ Read | NeuroBook | @mql5dev
❀12πŸ‘10πŸ”₯5🀩2πŸ‘Œ1
Multi-timeframe scanners and high-frequency EA rules implicitly run hundreds of hypothesis tests, so β€œ5% significance” guarantees a steady stream of false signals even with zero edge. The article reframes this as an online multiple-testing problem where decisions are irrevocable and the number of tests is unknown.

It ports online false discovery rate control into pure MQL5 using LORD3, LORD++ and SAFFRON. These methods manage an alpha-wealth budget that is spent on each test and partially refilled by accepted signals, preventing endless overtrading on noise while keeping better power than Bonferroni-style gating.

A key implementation point is p-value validity in a live stream. The design uses rule β€œfirings” (not every bar), enforces a strict evidence/outcome window separation, and generates causal p-values via a stationary block bootstrap to preser...

πŸ‘‰ Read | CodeBase | @mql5dev
❀13🀩9πŸ‘7πŸ”₯1πŸ‘Œ1
A multi-symbol EA often keeps per-symbol globals and grows through duplication: separate bar times, magic numbers, failure flags, position checks, and event wiring. Adding instruments increases coupling between symbol state and MT5 event logic, which makes lifecycle paths fragile and hard to extend.

A scalable structure is an owning portfolio manager plus independent strategy nodes. Each CStrategyNode encapsulates one symbol-timeframe identity, including completed-bar gating, trading state, diagnostics, and permissions. CPortfolioManager routes OnTimer and trade-transaction events without touching node internals.

CArrayObj with FreeMode(true) provides an explicit ownership contract. Allocate an unowned node, Initialize() it, then Add() becomes the commit point where the collection assumes deletion responsibility. Failures before Add() must delete locally; Delete...

πŸ‘‰ Read | Forum | @mql5dev
❀10πŸ‘7πŸ”₯4🀩3πŸ‘Œ2
QCL Smoothed Heikin Ashi for MT4 renders calculated candles directly in the main chart window, using a two-stage smoothing pipeline. The first pass smooths price inputs, then a second pass smooths the derived Heikin Ashi OHLC, allowing separate periods and methods for each stage.

The implementation supports SMA, EMA, SMMA, and LWMA via a custom MovingAverage routine, maintaining intermediate arrays for base, HA, and final smoothed values. Only four indicator buffers are registered for the output OHLC; all other arrays remain internal.

Candles are drawn with per-bar chart objects and color-coded for bullish, bearish, or neutral states. Output values are synthetic and should not be treated as executable prices; the active bar can repaint until close.

πŸ‘‰ Read | Calendar | @mql5dev
❀13πŸ”₯5πŸ‘4🀩2πŸ‘Œ2πŸ‘¨β€πŸ’»2
This scalper EA is designed for M1 execution and depends on consistently tight spreads and fast order routing. An ECN environment with low commissions and minimal slippage is typically required to keep transaction costs predictable.

Hosting should be handled on a VPS located close to the broker’s trading servers, targeting up to 1 ms latency. Stable connectivity, low jitter, and uninterrupted uptime are critical, as brief delays can materially affect fills, stop execution, and overall results.

πŸ‘‰ Read | Signals | @mql5dev
❀11πŸ”₯4🀩2πŸ‘Œ2πŸ‘1
This article builds an MQL5 library for agent-based markets that lets strategies be tested on price series with known ground truth, avoiding the ambiguity of optimizing on real EURUSD history where β€œedge” can be pure search luck.

At its core is the Minority Game: agents pick buy/sell from fixed strategy tables and only learn which table to trust. Market quality is measured with volatility per agent (vs coin-flip baseline) and state-conditional predictability, then validated against the model’s published phase transition.

To make the synthetic series resemble real assets, the library adds a β€œsit out” option (grand canonical variant), producing variable participation, fat tails, and volatility clustering. A dedicated stylized-facts analyzer outputs assertable statistics (kurtosis, Ljung-Box, Hill tail index, variance ratio), enabling reproducible che...

πŸ‘‰ Read | Docs | @mql5dev
❀8πŸ‘5πŸ”₯5🀩2πŸ‘Œ2
StopDistance is an indicator that measures per-bar volatility as (High βˆ’ Low) in symbol points and visualizes it in a separate window. It adds an SMA or EMA of the range and a computed stop distance equal to average range multiplied by a configurable factor.

The goal is operational: quantify how far a symbol typically moves within one bar on the current timeframe, using the same unit used by stop-loss fields and many EAs. Unlike ATR, gaps between bars are excluded, so the metric reflects in-bar movement only.

Display logic is straightforward: blue histogram for each bar’s range, red line for the average over Period bars, and a green dashed line for Average Γ— StopFactor. Stops set below the average often sit inside normal bar noise.

For automation, three buffers are exposed for iCustom/CopyBuffer: range (0), average (1), suggested stop (2), all in ...

πŸ‘‰ Read | VPS | @mql5dev
❀13πŸ”₯5πŸ‘3🀩2πŸ‘Œ2
MQL5 can’t catch many critical VM faults (zero-divide, out-of-range, null access), so robust EAs need prevention, not recovery after the fact. This framework adds an exception-like discipline using precondition guards, typed error objects, cooperative TRY/CATCH macros, and consistent propagation.

Core pieces: CException as a structured error container (type, code, severity, context, timestamp), CResult<T> for explicit success/failure returns, CExceptionStack for manual call traces, and CLogger for durable terminal+file diagnostics.

Safety is enforced via GUARD_* (return Fail early) and CHECK_* (signal a THROW inside TRY). number<T> and array<T> wrappers validate division and indexing before execution. Practical benefit: predictable control flow and debuggable failures in complex trading systemsβ€”if wrappers/guards are used consistently.

πŸ‘‰ Read | Signals | @mql5dev
❀19πŸ‘7🀩5πŸ‘Œ3πŸ”₯2
ExportBars is a utility script for exporting bar history for any symbol and timeframe into a CSV ready for external analysis. The output is designed to load with a plain pandas.read_csv() call, without specifying encoding, separators, or date formats.

Default MQL5 file output creates friction: UTF-16 requires explicit encoding in pandas, timestamps come out as β€œYYYY.MM.DD HH:MM” and need a custom parser, and price formatting may vary by row if symbol digits are not enforced. ExportBars fixes these issues at the source.

The CSV is single-byte text, with one header row: time, open, high, low, close, tick_volume, spread, real_volume. Time is ISO 8601 β€œYYYY-MM-DD HH:MM:SS” in server time. Prices are formatted using SYMBOL_DIGITS and never in scientific notation. Rows are oldest-first, matching chart order.

Inputs include symbol, timeframe, last-N vs date-...

πŸ‘‰ Read | CodeBase | @mql5dev
❀13🀩5πŸ‘4πŸ‘Œ3πŸ”₯2
A practical way to expand EURUSD D1 direction models beyond classic TA features is to derive deterministic nonlinear features by mapping OHLC onto an elliptic curve (secp256k1). Each price is hashed (SHA-256) and converted to a valid curve point via try-and-increment; the number of attempts (nonce) becomes a feature, alongside x-bit statistics and curve point arithmetic such as Open+Close and High+Low.

The study builds 96 features (EC, TA, and cross-features) over multiple lookbacks and trains CatBoost with a strict time split, evaluated by AUC. On 2,000 daily candles, EC+TA improves test AUC to 0.6508 vs 0.5992 for TA alone, with x_slope and oc_x ranking among the most useful additions.

The key constraint is regime dependence: cross-validation averages do not consistently beat the baseline. The actionable takeaway is gating EC features with a tre...

πŸ‘‰ Read | NeuroBook | @mql5dev
🀩11❀9πŸ‘5πŸ‘Œ3πŸ”₯2
Most horizontal lines at prior highs are subjective. A higher-confidence level is a price band repeatedly validated by clustered pivots and repeated retests. This indicator aggregates recent swing highs/lows, groups nearby pivots into adaptive-width channels, assigns a score, and renders the strongest as background bands across the chart.

Pivots default to 10 bars left/right, taken from wicks or bodies, and remain eligible for 290 bars. Channel width is capped at 5% of the last 300 bars’ range, scaling with volatility. Scoring adds 20 points per pivot plus 1 point per bar whose high/low falls inside the band. Selection keeps the best, discards overlapping candidates, and repeats up to 10 channels, drawing the top 6 by default.

Channels update only on confirmed pivots; live ticks do not rewrite history. Bands switch role in real time based on current ...

πŸ‘‰ Read | Freelance | @mql5dev
πŸ‘12❀10🀩7πŸ”₯2πŸ‘Œ2😁1
A set of EA input defaults defines an EMA-based signal on M15 using closed bars. Fast and slow EMA periods are set to 10 and 30, with the signal timeframe fixed to M15.

Trading is restricted to a WIB session window from 19 to 22. Position sizing uses a fixed 0.01 lot.

Risk parameters specify 70 points stop loss and 200 points take profit. The system limits exposure to 1 maximum open position.

Execution and filtering settings include a spread cap of 100 points, with 0 disabling the filter. Order tracking uses magic number 20260909, and maximum slippage is set to 10.

πŸ‘‰ Read | CodeBase | @mql5dev
❀16πŸ‘14πŸ”₯4πŸ‘4🀩1
QCL Heikin Flow for MT5 implements a two-stage smoothing pipeline for Heikin Ashi output. Stage one applies a selectable MA (EMA/SMA/SMMA/LWMA) to the underlying OHLC series. Stage two rebuilds Heikin Ashi values and smooths them again using an independent period and method, reducing short-term oscillation in candle bodies and wicks.

The indicator separates rendering into three DRAW_CANDLES plots: bullish, bearish, and neutral, each with its own buffer set. Calculation buffers are kept distinct from display buffers, and arrays are indexed chronologically (0 as oldest) to simplify iterative MA state.

Parameter validation caps periods to 1..10000. The MovingAverage routine handles EMA and other methods with partial-window seeding to avoid undefined startup values.

πŸ‘‰ Read | AlgoBook | @mql5dev
❀12🀩12πŸ”₯6πŸ‘4⚑1πŸ‘Œ1
A standalone market-structure indicator for SMC-style analysis, built on a pullback swing detector and extended with structure state, validated extremes, and event tracking.

Two layers are processed per closed bar: a non-repainting pullback zig-zag that outputs alternating confirmed swings, then a structure engine that maintains exactly one active high, one active low, and a trend state (None/Up/Down). Structure is seeded from the first pullback high/low; after that, pullbacks only provide references.

Events are derived from one rule: closes break levels (BoS or CHoCH depending on trend), while wicks create pending sweep candidates. A sweep (x) is only confirmed when the next break occurs on the opposite side, and can relocate the prior structure point. Extremes are confirmed via IDM: after a break, the latest qualifying pullback becomes the referenc...

πŸ‘‰ Read | NeuroBook | @mql5dev
πŸ‘22❀17πŸ”₯9🀩7✍2πŸ‘Œ1