MQL5 Algo Trading
581K subscribers
4.71K photos
7 videos
4.71K 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
The CalculateLot function computes position volume using a fixed risk percentage of account balance, producing a lot size aligned with broker limits and symbol specifics.

Inputs typically include the risk percent, with internal reads for ACCOUNT_BALANCE, SYMBOL_TRADE_TICK_VALUE, plus VOLUME_MIN, VOLUME_MAX, and VOLUME_STEP for the current symbol.

Processing flow: derive the risk amount in deposit currency, convert it to volume using tick value, then normalize the result by rounding to the nearest VOLUME_STEP.

Validation clamps the final value to VOLUME_MIN/VOLUME_MAX. If the raw calculation is outside limits, the function returns the nearest allowed minLot or maxLot.

Typical usage patterns include direct calls from an Expert Advisor and script execution with explicit error checking and parameter validation.

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #EA
❀29πŸ‘4😁4🀨2πŸ‘Œ1
Frontend EA A is a single MT5 EA that focuses on chart UI cleanup plus a compact quick-trading layer. Default grid, volumes, ticker bar, and the native one-click panel are hidden on load, replaced by larger custom price and time scales designed for readability.

The price scale uses round-number steps (1/2/2.5/5 Γ— 10^k). The time scale prints the date once per day at 00:00 and shows time elsewhere. A compact tiled mode limits labels to 5 price levels and 3 time labels. Auto-padding around Bid and endpoint labels is in progress.

Trading controls include top-left BUY/SELL with an editable volume box persisted via GlobalVariable. Open positions render as entry-price plates with price, signed volume, and live PnL including swap and commission, refreshed at 1 Hz. Plates merge for overlapping entries and support one-click close per cluster.

Included indicators: H1...

πŸ‘‰ Read | Forum | @mql5dev

#MQL5 #MT5 #EA
❀28πŸ‘5πŸ€”3πŸ†2πŸ‘Œ1
This article builds a Liquidity Spectrum Volume Profile indicator for MetaTrader 5 that shows where volume concentrates across price, not just per bar. The design makes clear assumptions: binning uses candle close to assign volume, prefers tick volume with a fallback to real volume, and always operates on explicitly copied history for consistent recalculation.

Implementation centers on three engineering problems. First, reliably collecting a fixed lookback dataset via CopyHigh/CopyLow/CopyClose and CopyTickVolume, with safety checks for missing history. Second, scanning that window for the highest high/lowest low, splitting the range into equal price bins, accumulating volume per bin (with slight bin overlap to avoid boundary misses), then normalizing widths against the maximum bin. Third, rendering stable chart objects: rectangles for bins and horizont...

πŸ‘‰ Read | Calendar | @mql5dev

#MQL5 #MT5 #Indicator
❀36πŸ‘4✍2πŸ†2πŸ‘Œ1
Recurrence Quantification Analysis (RQA) brings nonlinear dynamics into MetaTrader 5 by measuring whether price revisits prior states and how those recurrences are structured. It converts closes into time-delay embedded vectors, builds a thresholded recurrence matrix using selectable distance norms (Euclidean, Chebyshev, Manhattan), then derives metrics like RR, DET, LAM, ENTR, and TREND to quantify similarity, determinism, consolidation, complexity, and drift.

The implementation focuses on reuse: a modular MQL5 library plus a facade API, a rolling-window engine that outputs a time series of metrics, and an indicator that plots live values on-chart for any symbol/timeframe.

A key engineering feature is automatic epsilon selection, including a target-recurrence-rate method using bisection with subsampled distance estimates, avoiding repeated full m...

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀58πŸ‘9πŸ‘Œ7✍1
Trade evaluation based only on win rate and net profit misses execution quality. A script is available that rebuilds historical positions and calculates excursion and time-based return metrics, exporting results to a CSV compatible with Excel.

Metrics include MAE/MFE in points to quantify adverse and favorable movement during each trade, plus forward returns at fixed horizons (T+30m, T+1h, T+4h, T+12h, T+1d, T+1w). When a horizon is not available, the output is n/a. A 1-week forward worst-case adverse move (T+1w MIN) is also reported, returning 0 when no adverse movement occurs.

Output columns cover position metadata, timestamps, duration, prices, PnL in $ and points, MAE/MFE, forward returns, and forward risk. Calculations use M1 OHLC data; insufficient M1 history can produce zeros in some fields.

πŸ‘‰ Read | AppStore | @mql5dev

#MQL5 #MT5 #script
❀37πŸ‘Œ2
Open-source MQL5 order execution library and demo EA for MT5 adds configurable retry logic, separate requote vs rejection handling, and slippage measurement in pips with violation detection. SL/TP values are normalized to broker stop levels, and fill policy is auto-detected across FOK, IOC, and RETURN.

Supports market and pending orders, plus position operations including close, partial close, SL/TP modification, and close-all-by-magic. Execution reporting includes success rate, average slippage, average execution time, and volume, with 10 human-readable result states and optional verbose logging.

Demo EA provides a chart dashboard with BUY/SELL/CLOSE ALL controls, live color-coded metrics, gauges, and a stats reset function. Two files placed in one folder compile without additional setup. Compatible with all brokers, instruments, and timeframes.

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #EA
❀30πŸ‘5πŸ‘Œ2
Supertrend is an ATR-based trend-following indicator that plots a trailing support/resistance line on the main chart. The line switches state with price direction, allowing trend alignment without additional oscillator panels.

This MetaTrader 5 custom implementation provides the full Supertrend band logic with two ATR modes: the built-in iATR calculation or a manual Simple Moving Average of True Range. Both approaches adjust band width with volatility and keep bands fixed once price has moved away, reducing noise during sustained moves.

Trend reversals can optionally print arrows at the crossover bar: upward for bullish flips and downward for bearish flips. Inputs cover ATR period, ATR multiplier, ATR method selection, and signal visibility.

Use is intended for trend identification and testing; signals should be validated in a demo environment befor...

πŸ‘‰ Read | Freelance | @mql5dev

#MQL5 #MT5 #Indicator
❀39πŸ‘Œ4⚑1
The article outlines two non-standard money-management techniques aimed at improving exit quality and stabilizing performance in MetaTrader systems.

First, it proposes partial position closing driven by the previous bar’s impulse size. A power function maps last-bar movement (in points) to the volume to close, with parameters chosen so developers tune behavior via intuitive anchors rather than raw coefficients. The goal is to harvest rollbacks after strong candles and reduce spread impact when the final exit is uncertain.

Second, it describes a hybrid lot-variation model combining martingale and reverse-martingale logic based on equity β€œwaves.” Lots are increased during drawdown phases and reduced during recovery, constrained within a min/max corridor and pulled back toward the midpoint to avoid sticking at extremes. Practical value depends on markets domin...

πŸ‘‰ Read | Forum | @mql5dev

#MQL5 #MT5 #EA
❀46πŸ‘Œ6πŸ‘5
ПанСль Β«ΠšΠ°Π»ΡŒΠΊΡƒΠ»ΡΡ‚ΠΎΡ€ коррСляции» прСдставляСт собой ΠΈΠ½Π΄ΠΈΠΊΠ°Ρ‚ΠΎΡ€ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ Ρ‚Π°Π±Π»ΠΈΡ†Ρ‹ для ΠΎΡ†Π΅Π½ΠΊΠΈ взаимосвязСй Π²Π°Π»ΡŽΡ‚Π½Ρ‹Ρ… ΠΏΠ°Ρ€ ΠΈ Π²Ρ‹Π±ΠΎΡ€Π° Ρ‚ΠΎΡ‡Π΅ΠΊ Π²Ρ…ΠΎΠ΄Π° Π±Π΅Π· Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎΠ³ΠΎ Π½Π°Π±ΠΎΡ€Π° инструмСнтов. ΠŸΠΎΠ΄Ρ…ΠΎΠ΄ ΠΎΡ€ΠΈΠ΅Π½Ρ‚ΠΈΡ€ΠΎΠ²Π°Π½ Π² ΠΏΠ΅Ρ€Π²ΡƒΡŽ ΠΎΡ‡Π΅Ρ€Π΅Π΄ΡŒ Π½Π° кросс-курсы.

ΠŸΡ€ΠΈ Π·Π°ΠΊΡ€Π΅ΠΏΠ»Π΅Π½ΠΈΠΈ ΠΏΠ°Π½Π΅Π»ΠΈ Π½Π° Π³Ρ€Π°Ρ„ΠΈΠΊΠ΅ EURJPY ΡΡ€Π°Π²Π½ΠΈΠ²Π°ΡŽΡ‚ΡΡ EURUSD ΠΈ USDJPY. Если Π² Ρ‚Π°Π±Π»ΠΈΡ†Π΅ Π²Ρ‹ΡˆΠ΅ находится EURUSD, кросс, ΠΊΠ°ΠΊ ΠΏΡ€Π°Π²ΠΈΠ»ΠΎ, повторяСт Π΅Π³ΠΎ Π΄Π²ΠΈΠΆΠ΅Π½ΠΈΠ΅. Если Π²Ρ‹ΡˆΠ΅ USDJPY, кросс Ρ‡Π°Ρ‰Π΅ слСдуСт Π·Π° этой ΠΏΠ°Ρ€ΠΎΠΉ. Π‘ΠΈΠ³Π½Π°Π»ΠΎΠΌ считаСтся ΠΌΠΎΠΌΠ΅Π½Ρ‚, ΠΊΠΎΠ³Π΄Π° основныС ΠΏΠ°Ρ€Ρ‹ ΠΌΠ΅Π½ΡΡŽΡ‚ΡΡ мСстами Π² Ρ‚Π°Π±Π»ΠΈΡ†Π΅, послС Ρ‡Π΅Π³ΠΎ открываСтся сдСлка ΠΏΠΎ кроссу.

Π Π΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡƒΠ΅ΠΌΡ‹Π΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹: Ρ‚Π°ΠΉΠΌΡ„Ρ€Π΅ΠΉΠΌ H4, Π³Π»ΡƒΠ±ΠΈΠ½Π° расчСта 10 Π±Π°Ρ€ΠΎΠ². НаиболСС подходящиС кроссы: GBPCHF, EURCHF, GBPCAD, EURCAD, AUDCHF, AUDJPY, EURJPY, GBPJPY, NZDJPY, NZDCHF. Π’Π°ΠΊΠΈΠ΅ кроссы Ρ„ΠΎΡ€ΠΌΠΈΡ€ΡƒΡŽΡ‚ΡΡ ΠΈΠ· Π²Π°Π»ΡŽΡ‚ с прямыми ΠΈ ΠΎΠ±Ρ€Π°Ρ‚Π½Ρ‹ΠΌΠΈ ΠΊΠΎΡ‚ΠΈΡ€ΠΎΠ²ΠΊΠ°ΠΌΠΈ ΠΈ ΠΎΠ±Ρ‹Ρ‡Π½ΠΎ ΠΏΠΎΠ²Ρ‚ΠΎΡ€ΡΡŽΡ‚ Π΄ΠΈΠ½Π°ΠΌΠΈΠΊΡƒ ΠΎΠ΄Π½ΠΎΠΉ ΠΈΠ· Π±Π°Π·ΠΎΠ²Ρ‹Ρ… ΠΏΠ°Ρ€.

πŸ‘‰ Read | Freelance | @mql5dev

#MQL4 #MT4 #Indicator
❀35✍6πŸ‘Œ4🀑2
DoEasy’s next step toward Depth of Market in MT5 starts by modeling a single DOM entry as a first-class library object fed by MarketBookGet() on OnBookEvent() updates.

The article implements an abstract DOM order class backed by MqlBookInfo fields (type, price, volume, volume with extended precision) and adds an explicit side flag (Buy/Sell) to quickly split demand vs supply regardless of market/limit type.

Four derived classes represent the concrete book types (buy, buy market, sell, sell market), while the base class provides property enums, sorting criteria, full/partial comparison, and structured logging.

A test EA subscribes to book events, snapshots the book into a price-sorted list, and validates handling by printing the best bid/ask and dumping the first snapshot to the journal.

πŸ‘‰ Read | Forum | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀66πŸ‘8πŸ‘Œ4πŸ†4
An updated Rex indicator variant is available with an added Donchian-style channel layer. The channel is calculated from recent period highs and lows and plotted around the Rex output to provide a volatility-based envelope.

This extension is intended to help flag potential overbought and oversold conditions when values approach or exceed the channel boundaries. Persistent compression inside the channel can be treated as a possible ranging or low-momentum zone.

Usage remains consistent with standard Rex workflows, with the channel serving as an additional context filter rather than a standalone signal.

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL5 #MT5 #Indicator
❀38✍2πŸ‘Œ2πŸ‘€2
CFTC COT and TFF reports remain underused inputs for FX modeling. They aggregate futures positioning by participant type and expose shifts in institutional risk, with TFF separating leveraged funds, asset managers, and dealers.

A practical workflow merges weekly positioning with MT5 quotes and derived features such as volatility, moving averages, and position deltas. Python tooling typically relies on requests plus pandas for report ingestion, local caching to reduce reload time, and MT5 APIs for historical bars.

Model output targets a 24h return estimate and can drive automated execution in MetaTrader 5 via rule gates on forecast magnitude and confidence. Key constraints include Tuesday-as-of data, Friday release latency, and evolving behavior from systematic strategies using the same reports.

πŸ‘‰ Read | Forum | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀30πŸ‘4πŸ‘Œ3⚑2
Single backtest equity is path-dependent. The same trade set can produce materially different drawdowns when reordered, including margin-call outcomes despite positive expectancy.

MonteCarlo_RiskAssessor.mq5 runs 1000 bootstrap resamples of historical trade P&L from trades.csv, building synthetic equity curves from the same outcomes. Output includes a 5/25/50/75/95 percentile fan chart via CCanvas plus CSV export of percentile curves and summary metrics.

Key metrics: median max drawdown, 95th-percentile stress drawdown, 5% VaR on final equity, and probability of breaching a configurable ruin threshold. Optional execution stress applies per-trade commission and conservative slippage.

Operational notes: script mode (OnStart), reads from MQL5\Files, supports single-column P&L or date+P&L, and typically needs profit-column remap for Strategy Tester ex...

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀36✍6πŸ‘4πŸ‘Œ3
The article walks through a practical MT5 + Python workflow that keeps research and execution connected: pull market data from the terminal, validate it visually, test statistical ideas, then move toward deployable models.

Setup focuses on reproducibility: isolate dependencies with venv, point MetaEditor to the virtual-env interpreter, and use a standard data stack (NumPy, Pandas, Matplotlib/Seaborn, scikit-learn, TA). Time handling is treated as critical engineering: MT5 timestamps are UTC, so Python datetime must be explicitly UTC to avoid silent bias.

On data and hypotheses, it shows how to request H1 EURUSD history, plot price with volume cleanly, then quantify β€œtrend continuation” using shifted returns and Pearson correlation. Results reject bar-to-bar momentum and reveal weak, structured mean reversion when averaging over mid-size windows, motivat...

πŸ‘‰ Read | Signals | @mql5dev

#MQL5 #MT5 #Python
❀64πŸ‘9πŸ‘Œ6πŸ†3✍2
Most retail algos still hardcode lookback periods such as RSI(14) or MA(20). This assumes cycle length is constant. In live markets the dominant cycle contracts or expands with liquidity and regime changes, so static windows create phase lag and systematic late entries.

A DSP approach replaces fixed periods with cycle estimation via a rolling Discrete Fourier Transform. The scan measures amplitudes across frequencies, isolates the dominant component, and keeps its phase aligned with current price action. Peaks and troughs are identified by the extracted wave rather than by delayed crossovers.

Implementation details matter. Naive DFT is CPU heavy, so practical engines rely on tight loops and array-level memory handling to keep latency low. The extracted dominant frequency can then be fed back into an EA to adapt indicator periods dynamically and re...

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀48⚑6πŸ‘5πŸ‘Œ4✍3πŸ”₯1
Algorithmic trading systems need fast feedback loops. With higher trade frequency, data becomes stale quickly, and manual journaling adds latency and errors.

MetaTrader 5 ships with native SQLite support, turning the journal into an in-terminal component. Queries run in milliseconds, stats update automatically, and analysis stays next to execution.

A practical β€œminimum working set” is a three-table schema: DEALS (trade history), SIGNALS (indicator/system signals), EVENTS (macroeconomic context). Indexed fields like symbol, magic, and time keep analytics responsive.

In MQL5, DatabaseOpen/Execute/Close covers most use cases. Prepared statements plus transactions materially improve throughput and reduce risk versus ad-hoc SQL or spreadsheet pipelines.

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀55πŸ‘12πŸ‘Œ6✍4πŸ‘€4πŸ”₯3🀝3
The December 2020 issue of TASC featured John Ehlers’ MyRsi with Noise Elimination Technology (NET). The design applies a Kendall-style autocorrelation approach to reduce noise and suppress low-quality RSI swings.

This variant allows selecting the input price series instead of relying on a fixed close, enabling alignment with different data conventions such as typical price or weighted close.

Operationally it can be treated like a standard RSI, with the added NET line as a second confirmation layer. In comparative chart reviews, the NET line often reacts earlier while keeping fewer false transitions, which can improve signal clarity when combined with traditional RSI thresholds.

πŸ‘‰ Read | AlgoBook | @mql5dev

#MQL4 #MT4 #Indicator
❀43πŸ‘4⚑3πŸŽ‰2πŸ‘Œ2πŸ€”1
Moving MQL5 workloads from CPU to GPU with OpenCL only pays off when the problem is naturally parallel and executed in large batches. Otherwise, kernel launch, data transfers, and synchronization overhead can erase any gains and add architectural complexity.

A disciplined OpenCL setup matters: create and reuse the context, compile kernels once, reuse buffers, and avoid frequent CPU↔GPU exchanges. GPU performance is often limited by memory behavior, so minimizing global memory traffic and reducing tiny kernel launches is key.

A matrix-multiplication example contrasts a naive GPU kernel (one thread per output) with an optimized tiled version using local workgroups and shared local memory. On RTX 4060, global groups ran ~38 ms vs ~11 ms with local groups; Iris Xe improved ~213 ms to ~45 ms. Initialization cost (up to ~99 ms) makes batching essential for...

πŸ‘‰ Read | Forum | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀32πŸ‘Œ3
Fractional differentiation (FFD) is brought from an AFML-style Python pipeline into MetaTrader 5 with a production-ready MQL5 design: precompute the weight vector once, use a bounded lookback window, and compute each new value as a single dot product.

The core is a header-only CFFDEngine class that avoids per-tick allocation, minimizes CopyClose overhead, and supports both EA and indicator workflows. A companion FFD custom indicator wraps the engine and uses prev_calculated to recompute only new/changed bars, keeping runtime O(width) per bar.

Key implementation details include threshold-terminated weight generation (no fixed cap), safe log handling to match Python outputs, and new-bar timing to avoid look-ahead bias. A validation script confirms numerical parity with Python to ~1e-12, enabling reliable reuse of offline-optimized d values in live t...

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀38⚑5πŸ‘Œ4πŸ‘3
RSI confirmation often sits in a separate subwindow, forcing attention shifts during execution-heavy workflows such as scalping or manual trade management.

A chart-embedded RSI panel addresses this by attaching directly to the active price level and updating on every tick. It renders the current RSI value, a state label (OVERBOUGHT/OVERSOLD/NEUTRAL), and a slope-derived strength rating (WEAK/STRONG/EXTREME), with optional Bid/Ask anchoring.

Implementation centers on MQL5 chart objects plus ChartTimePriceToXY for time/price-to-pixel mapping. Position clamping keeps the panel on-screen during zoom, scroll, resize, and timeframe changes. RSI handle lifecycle is managed in OnInit/OnDeinit; CopyBuffer feeds updates; alert spam is avoided via state flags.

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Indicator
❀63πŸ‘Œ11⚑1😈1