MQL5 Algo Trading
489K subscribers
3.09K photos
3.09K 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
Profit_and_Loss_Positions is a utility module for calculating aggregate P/L across open positions with optional filtering by position side and Magic Number. Intended for integration into MT5 codebases where consistent P/L aggregation is required.

Core API: Profit_Position(string p_l, string type_pl, long magicNumber). Parameter p_l selects calculation mode ("Profit" or "Loss"). Parameter type_pl filters positions by "All", "Buy", or "Sell". Parameter magicNumber filters by identifier; 0 processes all positions. The function returns the total amount in deposit currency.

Typical uses include real-time monitoring, strategy performance checks, and tighter risk control. In automated systems, it can support risk modules, reporting, and rule-based closing conditions.

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #EA
❀28πŸ‘Œ3πŸ‘2
This series builds a retail-friendly statistical arbitrage workflow in MT5, starting with correlation, cointegration, and stationarity testing (Engle-Granger/Johansen, ADF, KPSS) using Python libraries to keep the focus on practical interpretation.

It then moves into production concerns: storing market data in MT5’s built-in SQLite via an MQL5 Service, plus screening/scoring baskets by objective metrics like cointegration strength, weight stability, and mean-reversion half-life.

For live monitoring, it applies RWEC, IS/OOS ADF, Chow, and CUSUM to detect drift, rebalance needs, and structural breaks.

The key upgrade is architectural: keep SQLite for trade-state and transactions (OLTP), but offload heavy historical analytics (OLAP) to DuckDBβ€”an embedded, zero-admin engine that scales on a laptop and integrates cleanly with SQLite, Pandas/Arrow, and CS...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀31πŸ‘Œ3
This article upgrades a swing-point trendline breakout concept into a full parallel-channel scanner that tracks both rails, so upside and downside breakouts are treated symmetrically instead of being missed on the β€œunwatched” side.

Channels are built from structurally meaningful swing highs/lows, filtered with ATR to ignore noise. The upper rail is defined by consecutive swing highs, and the lower rail is a true parallel projection to preserve slope consistency. The channel recalculates on completed bars to stay aligned with live structure without unstable repaint behavior.

Breakouts require a candle close beyond a boundary plus optional volatility/threshold checks, with an optional retest state machine (neutral β†’ pending β†’ confirmed β†’ expired). Confirmed signals are stored and plotted as non-repainting markers, separated from adaptive channel redraws fo...

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀42✍1πŸ‘Œ1🀝1
Part 21 upgrades an MQL5 canvas regression/correlation tool into a dual-theme visualizer, adding a cyberpunk mode aimed at improving readability during long sessions and night trading. The classic layout stays available, with a header button to switch themes without duplicating rendering logic.

The implementation centers on theme state, a glowIntensity input, a color palette, and an animation frame counter. A BlendColors utility enables smooth gradients and glow transitions, while timer-driven redraws power pulsing borders, twinkling stars, and animated grids.

Rendering is decomposed into focused functions: starfield background, holographic border with sine-based phase, gradient header with text glow, neon points, anti-aliased regression line centering, glass-morphism stats/legend panels, and neon resize indicators. The result is a more interactiv...

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀46⚑8πŸ‘3✍1
Modify_Orders.mqh targets automated management of positions and pending orders in MetaTrader 5 EAs and indicators. The file provides two functions focused on routine modification of Stop Loss, Take Profit, and pending order prices, with configurable value calculation in pips or absolute prices.

Modify_Position() updates SL/TP for open positions using filtering by symbol and Magic Number, plus selectable modes such as All, Buy, Sell, and profitability-based subsets. Positions are scanned in reverse order, checked for type and profit state, then new levels are calculated either by Price mode (direct assignment) or Value mode (Price Β± Value Γ— Point) and sent via OrderSend().

Modify_Order() updates pending Stop/Limit orders with filtering by symbol, Magic Number, and order type string cross-checked against the actual system type. The logic preserves unchanged ...

πŸ‘‰ Read | Forum | @mql5dev

#MQL5 #MT5 #EA
❀36πŸ‘Œ2
DoEasy’s graphics layer is refactored around a new β€œgraphical element” concept: a lightweight base canvas object that matches the library’s object model better than the previously started form class. The goal is a clean hierarchy (base object β†’ canvas element β†’ form/window composites) that makes objects easier to find, sort, and manage during rendering.

Core changes include rebuilding the common GBaseObj to store shared metadata (type, chart/subwindow, prefixed naming, Y-shift), then adding CGCnvElement backed by CCanvas. The element implements property storage, comparisons for sorting, hit-testing for bounds vs active area, creation via bitmap label, move/resize, and opacity control.

Select.mqh is extended to sort/search these elements. A test EA creates multiple elements and handles click events by cycling transparency, demonstrating event-driven int...

πŸ‘‰ Read | Signals | @mql5dev

#MQL5 #MT5 #Indicator
❀60✍3πŸ‘Œ3⚑2
VR Breakdown Level outlines an automated breakout approach based on prior period extremes. The lookback period used to compute reference levels is user-defined in the robot settings.

At the start of each new period, the robot records the previous period’s High and Low. When price reaches the prior High, a buy is opened; when price reaches the prior Low, a sell is opened. Trade volume is set via inputs.

Each position is immediately protected with user-defined Stop Loss and Take Profit. Exits occur only via SL or TP, with no additional closing rules.

The same logic can be implemented using pending BUY STOP and SELL STOP orders, with the added requirement to cancel the opposite order after entry. Market-entry logic based on internally tracked levels avoids publishing intended entry prices to the broker in advance.

πŸ‘‰ Read | VPS | @mql5dev

#MQL4 #MT4 #EA
❀33✍2πŸ‘Œ2
Modern Time Panel is a lightweight on-chart dashboard for MetaTrader 5 focused on time visibility and bar timing. It consolidates key session and candle metrics into a compact panel designed for consistent readability.

The core function is a live candle countdown to the next bar open. It updates once per second via an OnTimer-based loop, keeping the timer accurate even during low-tick periods and high volatility.

It also shows local time and broker/server time side by side to help align execution with session schedules. The panel is anchored to the top-right to avoid interfering with price action.

Configuration includes X/Y offsets, separate header/body background colors, text colors, and font family and size for dark or light templates. Suitable for short timeframes where bar close timing matters, and higher timeframes where session synchronization ...

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #Indicator
❀22πŸ†4πŸŽ‰3πŸ‘€2πŸ‘Œ1
VR Breakdown Level describes a rules-based breakout system that trades a prior period’s extremes. The lookback period used to calculate the reference levels is configurable in the robot settings.

At the start of each new period, the robot captures the previous period High and Low. A trade triggers when price reaches a stored level: a buy is opened on a break above the prior High, and a sell is opened on a break below the prior Low. Order size is set by the user.

Risk parameters are applied uniformly. Each position is opened with predefined Stop Loss and Take Profit values, and exits occur only through those levels.

The same logic can be implemented with BUY STOP and SELL STOP pending orders, with the added requirement to cancel the opposite order after entry. Using internal trigger levels avoids publishing intended entry prices to the broker.

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #EA
❀32✍2πŸ‘Œ2πŸ‘€2
The article begins a graphics layer for an MQL5 library, building custom UI elements on CCanvas. The design targets composite components with arbitrary hierarchies, where every visual element shares consistent coordinates, sizing, IDs, and interaction flags.

A key improvement is throttling canvas redraws to ~16 ms to avoid invisible overpainting and reduce CPU load. Utility code is also refined with a Pause method overload that supports timing without extra logging state.

Input handling is formalized via a CMouseState service. It encodes mouse buttons plus Shift/Ctrl and wheel events as bit flags, and adds a second byte for cursor position relative to a form (inside, active area, edges, control zones). This compact state feeds OnChartEvent processing.

On top of a CObject-derived base graphical class, a CForm implements a movable bitmap-label canvas, activ...

πŸ‘‰ Read | Forum | @mql5dev

#MQL5 #MT5 #Indicator
❀56πŸ‘Œ2πŸ‘€2πŸ”₯1
A scheduled trade execution expert is designed to open and close positions at predefined day/time values and operates only on the chart symbol where it is attached.

Order entry settings include day, hour, and minute for opening, plus direction selection (buy, sell) and lot size. Risk controls support optional take profit and stop loss defined in pips, with 0 disabling each level. Filtering is available via a magic number to manage only specific positions.

Order exit settings provide day, hour, and minute for closing. Closing behavior can be limited to positions opened by the expert or expanded to close all open positions on the account at the configured time.

πŸ‘‰ Read | Signals | @mql5dev

#MQL4 #MT4 #EA
❀28πŸ‘Œ2πŸ‘€2
This article shows how to add dynamic voice alerts to MetaTrader 5 EAs using a local text-to-speech pipeline, avoiding the limitations of pre-recorded WAV notifications.

An MQL5 Expert Advisor formats market events (signals, prices, time, ATR, margin/trade status) into text and sends it via WebRequest HTTP POST to a localhost Python service. The Python side exposes a simple /speak endpoint, queues incoming messages, and speaks them sequentially to prevent overlaps and thread-related crashes.

A moving-average crossover EA demonstrates the pattern, including a TestMode that speaks on each new bar and practical error handling for common WebRequest failures. This design improves accessibility, reduces alert maintenance, and stays fully local for low latency and privacy.

πŸ‘‰ Read | Signals | @mql5dev

#MQL5 #MT5 #EA
❀23✍2πŸ‘2πŸ‘Œ2πŸ‘€2
Rising and falling wedges remain widely used for framing entries and risk, but manual detection is inconsistent and slow under live conditions. Objective rules are required to avoid bias and missed formations.

A wedge is defined by converging trendlines with directional compression. Valid structures require confirmed swing highs/lows, multiple touches on both boundaries, and measurable slope convergence. Rising wedges have positive slopes with the lower line steeper; falling wedges have negative slopes with the upper line steeper. Breakout direction confirms or invalidates the setup.

An MQL5 indicator can formalize this: non-repainting pivot confirmation, slope and apex validation, overlap prevention, and per-bar monitoring for breakout or failure. Modular classes for pivots and wedges plus event-driven OnCalculate updates keep performance stable and...

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #Indicator
❀29πŸ‘Œ2πŸ‘€2😱1
Financial market series are nonlinear, high-volatility signals where linear statistical models often break under regime shifts, liquidity shocks, and event-driven discontinuities.

Attraos applies a chaos-theory view: observed prices are treated as low-dimensional projections of a higher-dimensional deterministic system. Phase space reconstruction (Takens) is used to recover latent dynamics via embedding dimension d and delay Ο„, then improve long-horizon stability by controlling attractor deviation.

Architecture notes: PSR selects d and Ο„; MDMU segments tensors and filters uninformative components; LMA uses diagonal state matrices with polynomial projections; DP uses exponential matrix discretization; frequency-domain local evolution amplifies relevant spectral components.

Implementation focus in MQL5/OpenCL centers on diagonal matrices stored as vectors...

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀62✍7πŸ‘Œ7πŸŽ‰2πŸ‘Ύ2πŸ‘€1
Moving-average setups remain a practical way to filter trend direction on a selected timeframe. A common approach uses two moving averages, typically a faster line and a slower line, to separate momentum from background direction.

Key parameters are the MA type, period length, applied price, and shift. Adjustments should be tested per instrument and volatility regime, since the same settings rarely perform consistently across markets.

This two-MA trend filter can be combined with other signals such as volatility bands, momentum oscillators, or session filters to reduce low-quality entries. Validation should include spread and slippage assumptions, with separate checks for ranging conditions.

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Indicator
❀34πŸ‘Œ2πŸ‘€2
Previous Day High/Low/Close indicator plots the prior session’s High, Low, and Close directly on the chart. Each day’s levels are drawn as horizontal lines limited to that day’s range, while yesterday’s lines extend into the current session as active reference levels. Older sessions can be displayed up to 50 days back using a dotted style for separation.

Levels are sourced from the Daily timeframe, so accuracy is independent of the chart timeframe. H1 and H4 tend to show interactions most clearly. PDH is a resistance reference, PDL is a support reference, and PDC often behaves like an early-session pivot.

Optional alerts can trigger once per day when price touches any of yesterday’s levels, with configurable popup/push behavior, tolerance handling, and automatic reset at midnight server time. Non-trading days are skipped automatically.

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Indicator
❀29πŸ‘Œ3πŸ‘Ύ3πŸ‘2πŸ‘€2😁1
Multi-pair EAs often fail not on signal quality, but on hidden duplication of risk when several instruments move together. This article shifts the design from per-symbol logic to portfolio-aware execution by embedding real-time cross-pair correlation checks before any order is placed.

The EA maintains a centralized symbol model with synchronized close-price buffers, computes a Pearson correlation matrix (stored efficiently as a flattened array), and refreshes it on new bars with a timer fallback. Signals come from MA crossovers with an added directional bias filter.

Trade approval becomes a final β€œrisk gate”: existing positions are scanned against correlation strength and direction to block trades that would amplify exposure through positive correlation or create mirror exposure via negative correlation. A heatmap visualizes the matrix for fast validatio...

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #EA
❀17πŸ‘Œ3πŸ‘€2✍1
On Friday, March 6, 2026, a new version of MetaTrader 4 will be released. The update includes several important security improvements, bug fixes, and platform stability enhancements.

The update will be distributed via Live Update.

Discuss the update...
❀28πŸ‘5πŸ”₯5πŸŽ‰4πŸ†4πŸ‘Œ1
Moving-average crossovers work in trends but fail in ranges due to repeated crossings and whipsaws. Common fixes like longer periods or RSI/ADX filters are heuristic and often reduce responsiveness.

ALGLIB is available in MetaTrader 5 via the Standard Library port, providing optimized routines for statistics, filtering, SVD/SSA, and splines using CRowDouble/CMatrixDouble with conversions to MQL5 arrays.

A baseline EMA crossover can be preprocessed with ALGLIB SMA/EMA/LRMA, SSA trend reconstruction (window + rank), and cubic-spline derivative zero-crossings. Testing can run all variants in one indicator with a bounded lookback to control SSA cost, then compare signal density and timing under trend vs range conditions.

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀67πŸ‘Œ7⚑4πŸ‘€2
An extended version of the Limit Channels indicator adds a β€œstates” display alongside the channel levels.

States are rendered as a colored histogram and derived from three nested level groups. Level 3 uses the outer bands and represents the slowest state. Level 2 uses the middle bands. Level 1 uses the inner bands and represents the fastest state.

The level grouping is a suggested approach for interpreting multi-level channel structures. Additional combinations can be derived from the available six levels, depending on the chosen strategy and timeframe.

Color transitions in the histogram can be monitored as potential signals, with confirmation logic left to the implementation.

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL4 #MT4 #Indicator
❀30πŸ‘2πŸŽ‰2πŸ‘€2πŸ”₯1πŸ‘Œ1
This article moves Attraos from theory into an MT5-ready implementation, building a CNeuronAttraos object that encapsulates Phase Space Reconstruction without extra compute by reshaping 1D buffers into lagged state vectors.

The design is modular: many static internal objects handle parameter generation, normalization, state updates, and storage, while only four components contain trainable weights, simplifying Save/Load and reducing disk usage.

Trainable matrices (state transition and residual paths) are produced via a compact two-layer scheme using a convolutional layer to replicate parameters across the full sequence, improving backprop efficiency and enabling stable fixed initialization.

Forward pass combines normalized inputs, state-space dynamics via the Multi-Resolution Dynamic Memory Unit, residual connections, and an OpenCL parallel-scan kernel ...

πŸ‘‰ Read | AppStore | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀22πŸ‘3πŸ‘€2✍1πŸ‘Œ1