MQL5 Algo Trading
489K subscribers
3.1K photos
3.1K 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
A chart watermark indicator is available to show the active symbol and current timeframe in a large font on the chart background. This reduces mistakes when switching between multiple instruments and timeframes during analysis or execution monitoring.

Setup is straightforward. Open the desired symbol on a chart and select the required timeframe. Attach the Watermark indicator, then adjust visual parameters such as font family, font size, color, and on-chart position to match the workspace layout and avoid overlap with other objects.

πŸ‘‰ Read | AppStore | @mql5dev

#MQL4 #MT4 #Indicator
❀25πŸ‘8πŸ‘Œ3πŸŽ‰2
This article shows how to generalize an MQL5 struct that computes average and median so it works across numeric types without duplicating code. The core technique is templating the structure, enabling β€œoverload-like” reuse while keeping data encapsulation via a Set method.

A key pitfall appears with return types: a templated median/average can silently promote integers to double, producing unexpected results for integer-based structs. The fix is a cleaner API: expose Sum() and Count() inside the struct, then compute averages with explicit casting where needed.

For EA/indicator code, this encourages reusable, type-safe utilities and pushes precision/rounding decisions to the caller instead of hiding them in one monolithic function.

πŸ‘‰ Read | Signals | @mql5dev

#MQL5 #MT5 #EA
❀33πŸ‘7πŸ‘Œ3✍1
Work continues on structural templates and type overloading, moving from basic structs toward data-aware containers used in search and lookup tasks.

The example models a key/value association using two arrays (K as keys, H as values). A direct index access fails when K is unordered, so the relationship must be preserved while enabling efficient search via sorting or binary search.

A refined approach embeds the lookup inside a struct: search K for a key, then return H at the same position. This keeps the mapping intact and prepares the code for reuse.

Generalization then starts by templating one base type to trigger compiler overloading. This introduces warnings when return types and stored types diverge, highlighting a common library-design risk: hidden conversions and mismatched expectations.

πŸ‘‰ Read | Calendar | @mql5dev

#MQL5 #MT5 #algorithm
❀67πŸ‘Œ4😱3πŸ‘1😁1
A chart watermark indicator is available for displaying the active symbol and current timeframe directly on the chart background using a large, configurable font. This reduces ambiguity when switching rapidly between multiple instruments and timeframes across several windows.

Operation is straightforward: open a chart for the required symbol and set the desired timeframe, then attach the Watermark indicator. Visual parameters can be adjusted as needed, including font family, font size, color, and on-chart positioning to match existing templates and keep other overlays readable.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #Indicator
❀32πŸ‘3πŸ‘Œ3
Better programming outcomes come from improving learning habits and applying fundamentals, not from constant coding.

Avoid blind copy/paste. Treat forum snippets as references, then validate assumptions against documentation and write the fix intentionally.

Stop β€œhacking” errors. Identify root cause, reduce the case, and use official references and peer review to ask precise questions.

Drop perfectionism and ship incremental improvements. Prefer clean, consistent, commented, DRY code over β€œsmart” tricks. Optimize for readability, maintenance, and user-facing diagnostics rather than shortest code.

πŸ‘‰ Read | AppStore | @mql5dev

#MQL5 #MT5 #Programming
❀67πŸ‘19✍4πŸŽ‰3πŸ‘Œ3⚑2πŸ”₯1
Utility script for chart cleanup: removes all graphical objects from the active chart, including comments, horizontal and vertical lines, arrows, and other drawing elements.

No user input is required. Execution is immediate and will clear every object on the current chart.

Operational notes: assign a keyboard hotkey via the script context menu (β€œSet hotkey”) or run it by drag-and-drop onto the chart.

Risk notice: use on a new or non-critical chart first. Running on a working chart will permanently remove existing annotations and objects from that chart.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #script
❀34πŸ‘2πŸ‘Œ2⚑1
Part 17 extends the MQL5 canvas dashboard with vector rendering for rounded rectangles and rounded triangles, keeping edges clean through supersampling and controlled downsampling.

The implementation builds reusable primitives: ARGB color packing with opacity, angle normalization and arc-range tests, and a scanline polygon filler used to paint interiors and border strips deterministically.

Rounded rectangles are composed from a central fill, side strips, and quadrant circle fills, then bordered using thickened straight-edge quads plus precise corner arc rings.

Rounded triangles rely on precomputed geometry (arc centers, tangency points, and arc angles) so scanline filling can combine straight edges and circular arcs without gaps. This supports configurable radii, border thickness, and transparency for modern MT5 UI elements and overlays in backtests.

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #EA
❀32πŸ”₯4πŸ‘Œ4
This article breaks down a common execution error in price-action trading: treating liquidity grabs and market structure shifts as the same event. Liquidity grabs typically sweep equal highs/lows or prior session levels, then reverse quickly, often leaving an imbalance; structure shifts are decisive breaks that flip the sequence of highs/lows, usually after major liquidity is cleared.

A key emphasis is multi-timeframe context: use D1/W1 plus MA stacking to define trend and narrative, then drop to M15/M5/M1 to time intraday entries after a purge, avoiding counter-trend trades.

An MQL5 Expert Advisor operationalizes this with configurable inputs (lookback, volume spike, engulfing confirmation window), 1% risk per trade, and trailing stops. Practical benefit: consistent rule-based filtering to reduce false breakouts and late entries on pairs like GBPJPY, GBPUS...

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #EA
❀75πŸ‘Œ6⚑3πŸ†3πŸ‘2
SNR Sentinel is an adaptive support and resistance engine for MT5 that maintains only the nearest active levels to current price. It uses strict left/right bar confirmation to validate swing highs and lows, filtering out low-quality structure and reducing chart noise.

Breakouts are recognized only on candle close beyond a level. Once breached, the prior level is marked and queued for replacement, and the engine selects the next historically relevant level likely to receive a reaction.

Active levels are projected forward and updated per bar using controlled line extensions rather than rays. Output is limited to one support and one resistance at any time, with no repainting and no redundant objects.

Typical applications include breakout and retest workflows, reaction-zone mapping for scalping or swing trading, market structure validation, and clean S/...

πŸ‘‰ Read | AppStore | @mql5dev

#MQL5 #MT5 #Indicator
❀40πŸ‘Œ2
A utility script is available to export all locally available tick data from the terminal into files stored under the Common directory. Existing files are appended with new ticks since the last recorded timestamp, enabling incremental updates and later reuse for building custom symbols.

Setup requires creating a destination folder in Common (default: β€œMW Download History”) or adjusting the MW_DH_DEST_FOLDER compiler define. After compiling, add the desired instruments to Market Watch, open any chart, and attach the script.

Inputs support exporting a single symbol or all Market Watch symbols, plus selecting a timeframe (M1 recommended). Separate files are created per symbol and timeframe. Execution progress is reported in the Experts log, and periodic reruns keep datasets current.

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #script
❀31✍4πŸ‘Œ3πŸ‘2
Candle Close Timer is an MT5 indicator that displays the remaining time until the active bar closes. The countdown is rendered in real time above the current candle and stays aligned with the latest price action.

Settings allow customization of text color and font size without affecting chart readability. The indicator is lightweight and designed to remain accurate across symbols and all timeframes.

Deployment is straightforward: attach it to any chart, then adjust visual parameters in the inputs. It supports timing-sensitive workflows such as scalping and intraday execution where decisions depend on the exact close of the current candle.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #Indicator
❀21✍4πŸ‘4πŸ‘Œ2
Quantitative trend analysis in FX replaces subjective chart reading with measurable statistics: trend duration, magnitude in points, and frequency distributions by pair and timeframe. This enables hypothesis testing and parameter selection based on observed data.

A common implementation uses Python with MetaTrader 5 data, pandas for time series handling, and a sliding-window algorithm to detect local highs/lows and form uptrend/downtrend segments. Window size controls sensitivity and noise filtering.

Example EURUSD H1 (Feb 2018–May 2025, ~45k bars, 100-bar window): 471 trends, split 236 up and 235 down. Average duration 5.11 days (~120 hours), average magnitude 167 points. 51.6% of trends fall in 100–200 points; 85.6% end within 10 days; moves >500 points are ~1.3%, creating a heavy tail that is a key risk factor for grid averaging systems.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀41πŸ‘Œ7⚑3✍2πŸ‘2
ARIMA forecasts prices by combining three ideas: autoregression (recent prices influence the next one), integration via differencing (model daily changes to handle non-stationary series), and moving average (use past forecast errors to correct bias).

In MetaTrader 5, a practical ARIMA indicator needs more than formulas: separate buffers for prices, residuals, and forecasts; dynamic arrays; and an OnCalculate pipeline that updates efficiently on new ticks and restores forecasts back from differenced space.

Parameters (lookback, forecast horizon, p/d/q, learning rate) are fit by maximizing log-likelihood, optimizing AR/MA coefficients with gradient descent. Reliability depends on validation: MAE/RMSE, residual diagnostics (Ljung-Box, Jarque-Bera), and sliding-window tests. ARIMA is strongest in stable regimes and degrades around news, policy shifts, and s...

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #ARIMA
❀58πŸ‘Œ12⚑4πŸ€”4
Utility script for removing chart annotations and drawing objects on the active chart. Intended to clear items such as comments, horizontal and vertical lines, arrows, and other objects created by indicators or manual markup.

No user input is required. When executed, it deletes all objects on the current chart, so it should be validated on a clean, newly opened chart before running on an active workspace.

Operational notes: assign a keyboard hotkey via the platform’s script list (context menu: Set hotkey) or run it by dragging the script onto the chart. The code can be adjusted to keep specific object types if needed.

πŸ‘‰ Read | Signals | @mql5dev

#MQL4 #MT4 #script
❀28πŸ‘6
Structured vs organized code remains a frequent source of confusion. A practical boundary appears when structures start carrying context through internal procedures, before transitioning to classes and OOP.

A struct with public data can compute average/median, but it also allows external writes. After a reset, memory may be reused incorrectly, producing wrong medians and hard-to-trace faults. This is a typical encapsulation error.

Marking internal arrays as private blocks direct access and even prevents blanket memory wipes, forcing explicit API methods for set/reset/print. The result is tighter invariants, clearer intent, and fewer hidden state bugs, at the cost of more deliberate design.

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #algorithm
❀30πŸ‘Œ2
Risk-management module update: new enums, structures, and constants added to support daily limits, position accounting, and dynamic per-trade risk.

Dynamic risk now adjusts assigned_percentage based on balance drawdown from an initial balance. Initial balance can be fixed (prop firm) or captured at startup (personal account). Thresholds must be sorted; a loop-free counter-based method requires ordered activation levels. A CHashMap approach is recommended to preserve key-value mapping during sorting.

Balance-check timing is configurable via enum: per-tick checks (accurate but noisy) or checks on trade close (lighter but less granular). Dynamic-risk modes include full custom strings, fixed numeric parameters (up to four steps, optimizer-friendly), or disabled.

Daily limit exceedance criteria are selectable: equity only, closed P/L only, or combined. Trade ac...

πŸ‘‰ Read | Calendar | @mql5dev

#MQL5 #MT5 #Strategy
❀31✍3πŸ‘2πŸ‘Œ2πŸ†2⚑1πŸ€”1
This article turns slanted, swing-anchored trendlines into a rule-based breakout signal tool for MetaTrader 5. Trendlines are treated as dynamic support/resistance built from market structure, not discretionary drawing.

Signals come only from validated lines: two swing anchors define the slope, and a third swing confirms that price actually respects the level. Breakouts are detected via true cross logic (with optional close vs wick selection and a configurable buffer), filtering minor intrusions and reducing false triggers.

The MQL5 EA is modular: ATR-assisted swing filtering, ordered swing storage, scored selection of best support/resistance candidates by touches and recency, automatic chart objects, and persistent breakout records with optional alerts. Practical result: consistent trendline breakout execution suitable for automation and clean cha...

πŸ‘‰ Read | Docs | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀30😱1πŸ‘Œ1
Part 18 extends the MQL5 canvas vector toolkit by composing a rounded rectangle body with a triangular pointer to form a speech bubble, with pointer orientation set to up, down, left, or right via an enum.

Geometry is precomputed per orientation, including body bounds, pointer vertices, apex rounding, tangents, and scanline mode selection. Filling uses supersampled high-res rendering, scanline triangle fill with arc inclusion checks, and quadrant circle fills for rounded corners, then bicubic downsampling.

Border rendering is segmented to avoid overdrawing at the pointer junction. A configurable borderExtensionMultiplier scales edge extensions by thickness to keep joins clean across wider strokes. Initialization integrates additional canvases, redraw handling, and cleanup, with backtest visuals confirming output.

πŸ‘‰ Read | Forum | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀32πŸ‘2πŸ‘1πŸ‘Œ1
This part extends an MQL5 trading journal from basic file creation to exporting real account history into a structured log. It selects deals within a defined date range, then extracts core fields needed for audit and analysis: ticket, symbol, side, volume, open/close times and prices, SL/TP, profit, and a final result flag.

The journal becomes readable by writing a consistent header row first, ensuring every subsequent value lands in the right column and can be parsed later by scripts or spreadsheets.

History processing is done safely: HistorySelect scopes the dataset, HistoryDealsTotal drives iteration, and DEAL_ENTRY_IN filters to true position entries. Ticket IDs are collected into a resized dynamic ulong array, using a separate index to avoid gaps when non-entry deals are skipped.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀27πŸ‘3πŸ”₯2πŸ‘Œ2🀣1😈1
Market Memory Zones move from a chart-only indicator to a MetaTrader 5 Expert Advisor that turns price behavior into executable rules. The system models three zone types: displacement (ATR-qualified impulse candles), structure transitions (CHoCH via swing breaks), and liquidity sweeps (stop-hunts that reverse back into range).

Each zone is stored as a structured object with boundaries, direction, ATR context, expiry, and activation state, managed in bounded arrays for stable long runs. OnTick updates ATR and swing structure, detects new zones only on fresh bars, removes expired zones, and continuously evaluates returns into active zones.

Entries avoid blind level trading: a zone must be revisited and confirmed on a lower timeframe (engulfing or strong close). Trades use risk-based sizing, optional dynamic stops beyond zone invalidation, structure-aware targ...

πŸ‘‰ Read | Forum | @mql5dev

#MQL5 #MT5 #EA
❀32πŸ‘Œ3😈1
Final part of a risk management series builds an MT5 Expert Advisor around an optimized Order Blocks indicator, then measures how risk controls change backtest results across four parameter sets (with/without loss and profit limits, plus dynamic per-trade risk).

Indicator speed is improved by reducing recalculation loops via prev_calculated, simplifying mitigation checks to highs/lows, switching to predefined OHLC arrays, and using template helpers to add/remove array elements. Mitigated blocks are now removed from the main list and deleted from the chart using auxiliary name arrays.

The EA is assembled with clear inputs: Order Block/TP-SL modes (ATR or points), fixed vs risk-based lots, PropFirm-style constraints, max daily/weekly/total loss, max daily profit with strict/non-strict logic, and dynamic GMLPO risk adjustment checked on ticks or on trade close...

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #EA
❀45πŸ‘Œ7πŸ†1