MetaTrader 5 includes an economic calendar accessible from MQL5 via CalendarValueHistory(), but external tooling cannot query it. The Python MetaTrader5 package exposes market data and trading state, yet provides no calendar API, leaving research scripts, dashboards, bots, and spreadsheets blind to upcoming releases.
A read-only Expert Advisor can bridge this gap by exporting calendar data to a CSV file under MQL5\Files on a fixed interval. It never opens, closes, or modifies positions.
Key implementation points: UTF-8 output to preserve localized event names, chronological sorting across currencies, atomic write (build in memory, then write once), HTML entity decoding (e.g., S&P), and a freshness header with server time, event count, and UTC offset. Update time is taken from the trade server clock, not the last tick.
Inputs include currency filter, ho...
👉 Read | AlgoBook | @mql5dev
A read-only Expert Advisor can bridge this gap by exporting calendar data to a CSV file under MQL5\Files on a fixed interval. It never opens, closes, or modifies positions.
Key implementation points: UTF-8 output to preserve localized event names, chronological sorting across currencies, atomic write (build in memory, then write once), HTML entity decoding (e.g., S&P), and a freshness header with server time, event count, and UTC offset. Update time is taken from the trade server clock, not the last tick.
Inputs include currency filter, ho...
👉 Read | AlgoBook | @mql5dev
❤16👍5🤩2👌2🔥1
Trade Guardian is a defensive Expert Advisor designed for risk supervision rather than trade entry. It monitors existing positions and reacts when configured limits are breached. Each function is independent, and position closing is disabled by default to allow warning-only operation on live charts.
Stop-loss enforcement checks open positions on timer events and flags orders without a stop. If enabled, it places a stop at an ATR-based distance using the chart timeframe, respecting a minimum distance in points and the broker stop level. Stops are applied only to the chart symbol.
Risk limits include a daily loss cap referenced to the balance at the day’s start, auto-refreshed on each new day, and a total drawdown cap referenced to the equity peak. A cooldown can rebase the peak to current equity so the guard can re-arm, with rebase events logged.
Scope can ...
👉 Read | Forum | @mql5dev
Stop-loss enforcement checks open positions on timer events and flags orders without a stop. If enabled, it places a stop at an ATR-based distance using the chart timeframe, respecting a minimum distance in points and the broker stop level. Stops are applied only to the chart symbol.
Risk limits include a daily loss cap referenced to the balance at the day’s start, auto-refreshed on each new day, and a total drawdown cap referenced to the equity peak. A cooldown can rebase the peak to current equity so the guard can re-arm, with rebase events logged.
Scope can ...
👉 Read | Forum | @mql5dev
❤11👍7🤩3👌1
EOSA (Ebola Optimization Search Algorithm, 2021) is a bio-inspired metaheuristic derived from a SEIR-HDVQ epidemic model, mapping short-range transmission to exploitation and long-range transmission to exploration. Quarantine is used to reduce premature convergence by keeping part of the population static.
A literal implementation exposes issues in the paper’s core equations: missing direction vectors in movement updates, identical exploitation/exploration forms, and a bounds bug in initialization (L + rand(U+L) instead of L + rand(U-L)). These defects can cause non-improving motion and rapid population collapse.
A practical variant keeps the intended mechanics but simplifies to active agents only, adds directed moves, pBest memory, fitness-biased strategy selection, Lévy flights for global search, and a ρ schedule from 1.0 to 0.5, with boundary re...
👉 Read | NeuroBook | @mql5dev
A literal implementation exposes issues in the paper’s core equations: missing direction vectors in movement updates, identical exploitation/exploration forms, and a bounds bug in initialization (L + rand(U+L) instead of L + rand(U-L)). These defects can cause non-improving motion and rapid population collapse.
A practical variant keeps the intended mechanics but simplifies to active agents only, adds directed moves, pBest memory, fitness-biased strategy selection, Lévy flights for global search, and a ρ schedule from 1.0 to 0.5, with boundary re...
👉 Read | NeuroBook | @mql5dev
❤11👍5🤩2👌2🔥1
This article focuses on practical debugging in MQL5 using MetaEditor and the terminal logs, bridging the gap between basic syntax and building reliable Expert Advisors.
It breaks down compiler diagnostics (warnings vs errors, file/line/column navigation) and shows why fixing issues top-to-bottom reduces cascading messages, especially when porting MQL4 code with mismatched function signatures.
Runtime failures get equal attention: dynamic arrays without sizing, “array out of range” cases from unloaded history or off-by-one indexing, and silent logic bugs where an EA simply never trades.
The workflow starts from entry points (OnInit/OnStart, OnTick/OnCalculate, OnTimer), encourages structural analysis, buffer/property checks for indicators, and uses targeted Print/PrintFormat output to pinpoint control-flow mistakes like an accidental semicolon after a loop.
👉 Read | AlgoBook | @mql5dev
It breaks down compiler diagnostics (warnings vs errors, file/line/column navigation) and shows why fixing issues top-to-bottom reduces cascading messages, especially when porting MQL4 code with mismatched function signatures.
Runtime failures get equal attention: dynamic arrays without sizing, “array out of range” cases from unloaded history or off-by-one indexing, and silent logic bugs where an EA simply never trades.
The workflow starts from entry points (OnInit/OnStart, OnTick/OnCalculate, OnTimer), encourages structural analysis, buffer/property checks for indicators, and uses targeted Print/PrintFormat output to pinpoint control-flow mistakes like an accidental semicolon after a loop.
👉 Read | AlgoBook | @mql5dev
❤16👍4🤩3👨💻3👌1
This article builds a Fisher Transform–style oscillator for MetaTrader 5, showing how to turn recent price position into a bounded value, smooth it, clamp it near ±1 to keep the logarithm stable, then apply the log transform and recursive smoothing to make extremes and reversals visually sharp.
Key implementation work focuses on correctness in MQL5: preserving recursive state via a calculation buffer, handling series indexing consistently, guarding minimum bars and zero-range windows, and recalculating only new bars for performance.
For trading logic, the signal is not a threshold cross. It waits for the line to exceed an extreme (often ±1.5 to ±2) and then turn back toward zero on closed bars, enabling a non-repainting EA to act on confirmed peaks/troughs across symbols.
👉 Read | Forum | @mql5dev
Key implementation work focuses on correctness in MQL5: preserving recursive state via a calculation buffer, handling series indexing consistently, guarding minimum bars and zero-range windows, and recalculating only new bars for performance.
For trading logic, the signal is not a threshold cross. It waits for the line to exceed an extreme (often ±1.5 to ±2) and then turn back toward zero on closed bars, enabling a non-repainting EA to act on confirmed peaks/troughs across symbols.
👉 Read | Forum | @mql5dev
❤16👍9⚡3🔥2👌2🤩1
This article turns the reusable CSwingEngine into a double top/bottom detector that prioritizes market structure over chart “shapes”. The EA first confirms H4 trend (up for double top, down for double bottom) using labeled swings (HH/HL or LL/LH); if the context is range, it refuses to evaluate the pattern.
Validation is based on confirmed swing points: two matching swings with exactly one opposite swing between them, peaks/troughs within a configurable H4-ATR tolerance, a minimum pattern height in H4-ATR, and time width measured from swing timestamps. ATR is always taken from the swing timeframe to keep thresholds scaled to structure.
Execution is separated from detection via a three-state machine: scan, lock a single pattern once, then wait for a neckline break on the trading chart timeframe with expiry and “no re-entry” identity tracking. Entries add pra...
👉 Read | Calendar | @mql5dev
Validation is based on confirmed swing points: two matching swings with exactly one opposite swing between them, peaks/troughs within a configurable H4-ATR tolerance, a minimum pattern height in H4-ATR, and time width measured from swing timestamps. ATR is always taken from the swing timeframe to keep thresholds scaled to structure.
Execution is separated from detection via a three-state machine: scan, lock a single pattern once, then wait for a neckline break on the trading chart timeframe with expiry and “no re-entry” identity tracking. Entries add pra...
👉 Read | Calendar | @mql5dev
❤15👍8👌4🔥3⚡1
Mamba4Cast is presented as a modular time-series forecasting core for high-frequency market data, combining compact feature extraction, multi-window convolutions for noise-resistant signal detection, and an SSM-based long-memory block to keep context across dozens of candles. A key design choice is forecasting across the full planning horizon rather than only the next step, improving stability for trading decisions.
The framework is integrated into an Actor–Director–Critic agent. The Environment State Encoder normalizes raw OHLCV and indicators (using noisy batch norm for better generalization), adds H1/D1 harmonic time embeddings, then applies stacked convolution + pooling + Chimera SSM blocks, followed by a convolutional decoder and denormalization.
The Actor aligns account state with per-feature latent embeddings via stacked cross-attention before...
👉 Read | Forum | @mql5dev
The framework is integrated into an Actor–Director–Critic agent. The Environment State Encoder normalizes raw OHLCV and indicators (using noisy batch norm for better generalization), adds H1/D1 harmonic time embeddings, then applies stacked convolution + pooling + Chimera SSM blocks, followed by a convolutional decoder and denormalization.
The Actor aligns account state with per-feature latent embeddings via stacked cross-attention before...
👉 Read | Forum | @mql5dev
❤10👍4🔥3👌3🤩2
Destructors in MQL5 become clearer when compared to MetaTrader’s event model. OnInit/OnDeinit behave like constructor/destructor pairs: allocate resources (create chart objects) on init, and reliably release them on deinit.
The article refactors a simple regression-channel example from an indicator into a script, then into a class where the destructor (~ClassName) deletes the OBJ_REGRESSION automatically when the instance goes out of scope. No explicit call is needed; lifetime rules trigger cleanup.
Key rules: destructors return nothing, take no parameters, and are invoked implicitly. To reuse the pattern across scripts, indicators, and EAs, the class is moved into a header and included where needed, making chart-object management predictable and leak-free.
👉 Read | AppStore | @mql5dev
The article refactors a simple regression-channel example from an indicator into a script, then into a class where the destructor (~ClassName) deletes the OBJ_REGRESSION automatically when the instance goes out of scope. No explicit call is needed; lifetime rules trigger cleanup.
Key rules: destructors return nothing, take no parameters, and are invoked implicitly. To reuse the pattern across scripts, indicators, and EAs, the class is moved into a header and included where needed, making chart-object management predictable and leak-free.
👉 Read | AppStore | @mql5dev
👍13❤8🤩3🔥2👌1
An EA can place a valid trade while still accumulating unsafe account exposure. Multiple “correct” entries on the same symbol can turn 1% per trade into 3–6% combined risk, increase margin usage, and extend time spent underwater.
The fix is basket accounting: total volume, volume-weighted average entry, floating P/L including swap, estimated margin via OrderCalcMargin, position count, oldest open time, plus MAE/MFE and peak count for diagnostics. Netting vs hedging changes what “position count” means, but money-based aggregates still apply.
Controls split into every-bar protections (aggregate loss cut, time stop, MAE tracking, pending-order cleanup) and pre-trade admissions (position ceilings, margin ceilings, implied-risk caps). A target-sized mean-reversion demo highlights that profit-target sizing makes risk an output, requiring separate implied-loss che...
👉 Read | CodeBase | @mql5dev
The fix is basket accounting: total volume, volume-weighted average entry, floating P/L including swap, estimated margin via OrderCalcMargin, position count, oldest open time, plus MAE/MFE and peak count for diagnostics. Netting vs hedging changes what “position count” means, but money-based aggregates still apply.
Controls split into every-bar protections (aggregate loss cut, time stop, MAE tracking, pending-order cleanup) and pre-trade admissions (position ceilings, margin ceilings, implied-risk caps). A target-sized mean-reversion demo highlights that profit-target sizing makes risk an output, requiring separate implied-loss che...
👉 Read | CodeBase | @mql5dev
❤12👍7🔥2⚡1🎉1🤩1👌1
Backtests showing 0% history quality usually come down to missing tick data. A tester can still run across periods with no real ticks, silently generating ticks from M1 bars. That produces smooth intra-bar movement, no gaps, no spread expansion, and can make fragile systems look profitable, especially grids, martingales, tight-stop scalpers, and small-target strategies.
A TickAudit script queries the terminal month by month and prints what exists before running a test: real ticks, partial ticks (holes), GENERATED TICKS (bars only), or nothing. The key risk is months that have bars but no ticks, because they still output results.
Outputs include the month where continuous real ticks begin and how many months would force synthetic ticks. Options include a full daily scan (slow), sampling, a wait time for downloads, and optional CSV export. It places no or...
👉 Read | Calendar | @mql5dev
A TickAudit script queries the terminal month by month and prints what exists before running a test: real ticks, partial ticks (holes), GENERATED TICKS (bars only), or nothing. The key risk is months that have bars but no ticks, because they still output results.
Outputs include the month where continuous real ticks begin and how many months would force synthetic ticks. Options include a full daily scan (slow), sampling, a wait time for downloads, and optional CSV export. It places no or...
👉 Read | Calendar | @mql5dev
❤10👍4🔥2🤩1👌1
A harmonic pattern script can reduce late entries by combining multi-scale structure detection with live PRZ validation.
A dual Zigzag engine runs “Major” and “Minor” wave scans in parallel. The logic prioritizes macro setups, then falls back to minor structure when the broader swing becomes noisy.
Point D is tracked in real time using the current candle wick, updating Fibonacci ratios as price moves into the Potential Reversal Zone instead of waiting for a confirmed pivot.
Entry signals are gated by RSI momentum exhaustion. Bull and Bear triggers are issued only when Point D forms and RSI crosses the configured oversold/overbought thresholds.
On trigger, risk and targets are plotted automatically: TP1 at 38.2% and TP2 at 61.8% of the A–D retracement. Stop loss is placed 20% beyond Point D’s structural size to account for deeper extensions.
👉 Read | NeuroBook | @mql5dev
A dual Zigzag engine runs “Major” and “Minor” wave scans in parallel. The logic prioritizes macro setups, then falls back to minor structure when the broader swing becomes noisy.
Point D is tracked in real time using the current candle wick, updating Fibonacci ratios as price moves into the Potential Reversal Zone instead of waiting for a confirmed pivot.
Entry signals are gated by RSI momentum exhaustion. Bull and Bear triggers are issued only when Point D forms and RSI crosses the configured oversold/overbought thresholds.
On trigger, risk and targets are plotted automatically: TP1 at 38.2% and TP2 at 61.8% of the A–D retracement. Stop loss is placed 20% beyond Point D’s structural size to account for deeper extensions.
👉 Read | NeuroBook | @mql5dev
❤21👍6🔥3👌2⚡1👨💻1👀1
Grid, martingale, and averaging risk is often misread by focusing on loss at the last planned level. Account failure typically happens earlier, when margin level hits broker stop-out while the position chain is still open.
A read-only EA calculates the adverse move that triggers stop-out, then scans the symbol’s M1 history to count how often a move of that size occurred over a chosen window. This turns a cash figure into a probability-relevant frequency and shows whether failure occurs before the configured leg cap is reached.
Key corrections: floating loss grows as step × N(N−1)/2, not step × N. Margin usage rises with open legs, so equity drops while margin used increases. Stop-out is percentage-based, so liquidation can occur after partial equity loss.
Outputs include full chain span, floating loss, margin locked, stop-out move distance, legs open at st...
👉 Read | AppStore | @mql5dev
A read-only EA calculates the adverse move that triggers stop-out, then scans the symbol’s M1 history to count how often a move of that size occurred over a chosen window. This turns a cash figure into a probability-relevant frequency and shows whether failure occurs before the configured leg cap is reached.
Key corrections: floating loss grows as step × N(N−1)/2, not step × N. Margin usage rises with open legs, so equity drops while margin used increases. Stop-out is percentage-based, so liquidation can occur after partial equity loss.
Outputs include full chain span, floating loss, margin locked, stop-out move distance, legs open at st...
👉 Read | AppStore | @mql5dev
❤16👍4🔥2🤩1👌1🤣1
A lightweight approach to customizing the MetaTrader 5 AI Assistant is shown via a prompt file generated by an MQL5 script. The assistant’s language, persona, menu structure, and response behavior can be adjusted by editing a plain text prompt, without using an AI API, DLL, or external service.
The AI_Prompt_Writer.mq5 script writes AI_Prompt.txt into the terminal’s MQL5\Files folder. Users select one of 11 response languages and a predefined persona, optionally set the output filename, and choose whether to overwrite an existing file. After loading the prompt in the assistant, a custom numbered menu becomes available for actions such as news checks, chart analysis, and trade review.
The sample is positioned as a template rather than a complete solution. It also enforces strict safety limits: no order placement or modification, no position management, no para...
👉 Read | Quotes | @mql5dev
The AI_Prompt_Writer.mq5 script writes AI_Prompt.txt into the terminal’s MQL5\Files folder. Users select one of 11 response languages and a predefined persona, optionally set the output filename, and choose whether to overwrite an existing file. After loading the prompt in the assistant, a custom numbered menu becomes available for actions such as news checks, chart analysis, and trade review.
The sample is positioned as a template rather than a complete solution. It also enforces strict safety limits: no order placement or modification, no position management, no para...
👉 Read | Quotes | @mql5dev
❤21👍7👌3🔥1🤩1🤡1
Gold intraday range is session-driven. For XAUUSD, most of the daily move typically forms between 13:00 and 16:00 GMT during the London/New York overlap, while Sydney and Tokyo often stay confined. The 22:00 GMT rollover hour frequently prints the widest spread.
An indicator can visualize this with one high/low box per session (Sydney, Tokyo, London, New York), plus a thicker outline for the 13:00–16:00 overlap and a shaded rollover band across the day’s high/low. Each box is labeled with the current session range and the average of the last N completed sessions.
Session inputs are defined in GMT. Server offset is computed via TimeTradeServer() minus TimeGMT(), rounded to 15 minutes, and refreshed on every new bar to stay aligned through DST changes.
Implementation uses chart objects only (no buffers), exact ranges via CopyHigh/CopyLow, redraw on new ...
👉 Read | Docs | @mql5dev
An indicator can visualize this with one high/low box per session (Sydney, Tokyo, London, New York), plus a thicker outline for the 13:00–16:00 overlap and a shaded rollover band across the day’s high/low. Each box is labeled with the current session range and the average of the last N completed sessions.
Session inputs are defined in GMT. Server offset is computed via TimeTradeServer() minus TimeGMT(), rounded to 15 minutes, and refreshed on every new bar to stay aligned through DST changes.
Implementation uses chart objects only (no buffers), exact ranges via CopyHigh/CopyLow, redraw on new ...
👉 Read | Docs | @mql5dev
❤16👍6🤡2🤩1👨💻1
Completed Bar Trend Regime Dashboard is a lightweight MT5 indicator that summarizes market structure using completed candles only. The panel combines EMA structure and slope, ADX/DI strength, higher-timeframe confirmation, ATR-based volatility context, breakout position, and spread versus ATR.
Regime classification requires agreement between the signal timeframe and the higher timeframe. When alignment is missing, the output switches to range or transition rather than assigning a directional label.
Panel interpretation focuses on EMA stack and the close versus the filter EMA, fast EMA slope, ADX with DI+/DI- pressure, and higher-timeframe validation. ATR and body/ATR provide volatility context, breakout flags location versus the recent range, and spread/ATR highlights execution friction relative to volatility.
Suggested US500 configuration uses H4 a...
👉 Read | AlgoBook | @mql5dev
Regime classification requires agreement between the signal timeframe and the higher timeframe. When alignment is missing, the output switches to range or transition rather than assigning a directional label.
Panel interpretation focuses on EMA stack and the close versus the filter EMA, fast EMA slope, ADX with DI+/DI- pressure, and higher-timeframe validation. ATR and body/ATR provide volatility context, breakout flags location versus the recent range, and spread/ATR highlights execution friction relative to volatility.
Suggested US500 configuration uses H4 a...
👉 Read | AlgoBook | @mql5dev
👍1