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
This article upgrades a basic Python echo server into a multi-client TCP server suitable as a bridge concept for Excel and MetaTrader 5 workflows.

The core issue is blocking I/O: accept() and recv() halt execution, and when Python runs inside Excel via VBA it competes for CPU time, making the spreadsheet sluggish.

The solution shown is a threaded design: the main loop keeps accepting connections, while each client gets its own handler thread with an independent receive loop. This enables reconnects and simultaneous clients, and mirrors earlier MT5 mini-chat ideas previously implemented with a C++ server.

It also notes practical limits: threads consume scheduling resources, so scaling requires restraint and careful design before adding client-to-client message routing.

πŸ‘‰ Read | Signals | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀30πŸ‘Œ2✍1
Basic news filters that only pause entries at release time miss the real risk: spreads can blow out, slippage increases, and stop-losses get triggered by volatility spikes. Open trades stay exposed, prop-firm timing rules get violated, and many EAs lose their logic after restarts or can’t be tested without live events.

The article builds a structured MQL5 news filter around the native Economic Calendar, replacing fragile web scraping with cached, deterministic terminal data that can be simulated in the Strategy Tester.

Key mechanics: load and cache a rolling 24-hour event set, map events to the traded symbol via currency relevance (base/quote for FX, heuristics for indices/commodities, manual overrides for odd symbols), filter by impact, and enforce configurable pre/post buffers. The result is a state-driven system that blocks entries and can optio...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀22πŸ‘Œ3✍2
In the MetaTrader 4 Beta Build 1457, we have implemented several important security enhancements, fixed known issues, and improved overall platform stability.

We invite all traders to participate in testing. Your experience and feedback help us further improve the platform reliability.

To receive the beta update, connect to our public demo server MetaQuotes-Demo β€” enter the server name in the search field and open a demo account.

Discuss the update...
❀33πŸ”₯5πŸ‘Œ3πŸ‘2
This article tackles a practical integration issue: a threaded Python socket server works fine standalone, but becomes disruptive when launched from Excel via xlwings. The root cause isn’t threading itselfβ€”it’s blocking accept() and an always-running loop that still contends with Excel’s execution.

A safer pattern replaces blocking accept() with select() using a short timeout, letting the server poll for events without freezing the host application. Logging back into Excel is simplified with a small helper that writes status and messages into worksheet rows.

The server is then refactored into a class, separating connection checks and message handling into callable methods. Moving the main loop outside the class makes the component easier to package, test, and later adapt for MetaTrader 5 ↔ Excel data exchange.

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #script
❀67πŸ€”6πŸ‘Œ5✍2
An indicator implements pivot calculations for any selectable timeframe, provided the pivot timeframe is higher than the current chart timeframe. This supports multi-timeframe levels without switching charts.

Two calculation modes are available. Original mode follows the approach described by Austin Passamonte. Alternate mode adjusts the level logic to emphasize support and resistance behavior more strongly.

Operational use is consistent with standard pivot workflows, including plotting key levels for planning entries, exits, and risk boundaries across sessions.

πŸ‘‰ Read | Docs | @mql5dev

#MQL4 #MT4 #Indicator
❀30πŸ‘7⚑3🀯2πŸ‘Œ2😐2
Part 41 shifts from writing trade journals to reading them back in MQL5, using a practical target: an indicator that ingests a CSV trading history and plots a balance curve from profit/loss over a selected period.

The core technique is treating CSV content as sequential elements (cell-like values), not β€œlines of text”. The workflow starts by opening the file in FILE_READ with CSV parsing and defined encoding, validating the handle, and using FileIsEnding + incremental reads to count total elements for safe loop bounds.

After counting, the file pointer is reset, then all elements are loaded into dynamic arrays. This enables scalable grouping by column (TradeID, LotSize, etc.), avoids fixed-size structures, and prevents out-of-range errors when processing real trading logs.

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #Algorithm
❀28⚑5πŸ‘Œ3
A Python socket server can act as a bridge between Excel (VBA/COM) and MetaTrader 5, enabling Excel-driven actions without placing orders directly from Excel.

The implementation uses only the Python standard library, with a class-based server, explicit host/port parsing, and defensive exception handling for Excel session, worksheet, and cell access.

Data flow is kept minimal: one control cell for requests and one log area for responses. The server reads MT5 messages, writes results into Excel, and forwards Excel cell content back to MT5.

Connection gating is handled via an initial header plus simple command parsing (shutdown, disconnect). Unknown clients are rejected, and missing worksheets trigger a clean shutdown.

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀26⚑4πŸ‘Œ2πŸ‘1
Part 19 builds a chart drawing tools palette in MQL5 using Canvas, turning UI elements into an interactive, stateful panel instead of static buttons. The palette supports dragging, edge/corner resizing, minimize/close controls, and dark/light theme switching via centralized theme-aware color getters.

Tools are modeled with enums and a button table (icon font, type, tooltip), enabling consistent hover/active rendering and clean tool naming. Mouse handling is event-driven in OnChartEvent: hit-testing separates header drag zones, control buttons, tool grid, and resize handles, while clamping keeps the panel within chart bounds.

Drawing logic maps clicks to chart objects with ChartXYToTimePrice and ObjectCreate, handling single-click (H/V lines, text, arrows) vs two-click tools (trendline, rectangle, Fibonacci). Crosshair mode adds live cursor tracking plus a ...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #EA
❀24πŸ‘Œ4
In MetaTrader 5 build 5640, we have refined the dark interface theme by updating the overall background color, as well as the colors of tabs and scrollbars, to provide a more comfortable user experience.

We have also introduced convenient support for Markdown files in MetaEditor. You can now use Markdown to create descriptions and documentation for your projects when publishing them to AlgoForge.

MQL5 has also received several improvements: we fixed a number of compiler issues, added the new Color2PRGB function, and extended support for NormalizeDouble β€” it can now be applied to matrices and vectors.

Read more...
❀36πŸ‘4πŸ‘Œ2
Part 7 moves from an evolved RSI stack to a hybrid TPO Market Profile indicator in MQL5, covering intraday/daily/weekly/monthly/fixed sessions with timezone offsets. Prices are quantized to a grid, then session OHLC/high/low are tracked per profile window.

Data structures store per-level TPO strings and counts, plus session metadata. Core routines create/roll sessions, snap prices to grid, parse daily ranges, filter eligible bars, and add TPO characters. Levels are sorted descending, Point of Control is derived from max count, and Value Area expands around POC to a target percentage of total TPOs.

Rendering uses chart objects (labels and trend lines) rather than buffers, with configurable colors for default prints, single prints, value area, POC, and close highlighting.

πŸ‘‰ Read | Freelance | @mql5dev

#MQL5 #MT5 #Indicator
❀33πŸ‘Œ7
This article completes the Excel side of an MT5–Python–Excel socket bridge by adding a small VBA layer that controls the Python server and exposes a simple UI.

VBA starts the server script from the workbook’s folder, passes the required parameters, and runs it asynchronously so Excel remains usable. Server lifecycle is handled cleanly: auto-start on Workbook_Open and shutdown on Workbook_BeforeClose to avoid orphaned processes.

User actions are routed through shape-linked macros that call centralized procedures (start/stop, send MT5 commands). Button states are driven by worksheet events that watch a β€œstatus” cell and update colors to reflect whether MT5 is online, keeping the workflow transparent for traders while staying extensible for developers via a separate Python β€œmessage client” script.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀54πŸ†2😁1
A trading indicator based on Williams %R (WPR) for BUY/SELL signaling is being updated with a different decision threshold.

Instead of relying on classic overbought/oversold zones, the logic uses the -50 level as a pivot point, aiming for more stable behavior in markets where the extremes do not produce consistent entries. The threshold can be adjusted back to overbought/oversold levels if needed.

This release is functionally aligned with the prior version, but includes a fix for object cleanup. The update addresses cases where chart objects were not deleted correctly, reducing clutter and preventing stale elements from remaining on the chart.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #Indicator
❀35πŸ‘Œ4
Intraday automation benefits from behavior-based rules that avoid subjective candle pattern matching. A practical model is EMA retest trading, using trend bias (price above/below EMA) and an interaction rule (candle pierces the EMA and closes back with the trend).

Manual walk-back review shows bounce setups are variable: pin bars, engulfing, inside bars, double structures, and two-leg retests. This supports abstracting β€œreaction” rather than coding a single formation, plus tracking whether the EMA was recently defended to add context.

An MQL5 EA can implement this with iMA + CopyBuffer, new-bar execution, PositionSelect safeguards, modular checks (trend, interaction, confirmation, prior bounce), and CTrade for orders. Visual Strategy Tester runs using real ticks validate structural correctness before optimization.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #EA
❀30πŸ‘Œ3πŸ”₯2😈2
Trading discipline often fails not because a strategy is wrong, but because rules don’t enforce themselves under live pressure. Overtrading after early wins, shifting profit targets mid-session, and ignoring loss limits are execution failures caused by missing real-time guardrails.

The article treats discipline as a system outcome: convert written rules into code-level constraints that continuously measure behavior and can block orders immediately. In MQL5, this is done by routing every trade through a single gateway (e.g., TryOpenOrder) that rejects requests when limits are breached.

A modular framework uses an IConstraint-style interface plus a ConstraintManager, updated via OnTradeTransaction(), to enforce daily trade caps, profit-lock stops, and drawdown halts. Practical scope choices include per-symbol accounting and optional inclusion of manual tra...

πŸ‘‰ Read | Quotes | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀64πŸ‘Œ13πŸ”₯7⚑3πŸ†3🀯2
A market-structure indicator built on the standard MQL5 ZigZag swing logic, using Depth, Deviation, and Backstep. Recent pivots are tracked internally for structure evaluation over a configurable lookback window.

Break of Structure (BOS) is detected when price closes beyond the relevant swing level in the current structure direction. The tool draws a horizontal level and prints a β€œBOS” label. Change of Character (CHoCH) is detected as the first close-based break against the prior structure direction, with a horizontal level and β€œCHoCH” label.

Chart rendering relies on line and text objects, updated only on new bars to reduce redraw overhead.

Notes: ZigZag repaints until a leg is confirmed, so pivot points and BOS/CHoCH levels can shift. Large lookback values may impact performance on low timeframes or slower systems.

πŸ‘‰ Read | Forum | @mql5dev

#MQL5 #MT5 #Indicator
❀50✍8πŸ‘Œ2πŸ‘€2
UI shadow rendering was refactored into a dedicated graphical element that sits under the form, instead of drawing on the form canvas. This reduces redraw cost and avoids manual background blending, since alpha composition is handled by the terminal.

Defaults were adjusted for Gaussian blur: outer padding increased to 16px to prevent edge artifacts at blur radius 4. New style parameters were added: blur radius, shadow darkening based on chart background, X/Y offset, and an outline rectangle color. Style parameter count was updated accordingly.

Core library updates include overloaded color lightness and new saturation adjustment helpers (RGB↔HSL), plus a gradient Erase() for background fills. A new CShadowObj class draws a filled rect, applies ALGLIB-based Gaussian blur weights, shifts by offsets, and stays non-interactive. Form now owns and manages the s...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #AlgoTrading
❀60πŸ‘Œ8✍3πŸ‘€2
Williams %R (WPR) is used as an oscillator in the chart window, with additional TPSL levels calculated from recent high-low ranges.

The setup derives take-profit and stop-loss reference points from the latest swing extremes, aligning exits with nearby liquidity zones rather than fixed pip targets.

This combination can support more consistent risk placement by anchoring stops beyond local structure and setting targets based on measured range, while WPR provides timing via overbought/oversold conditions.

As with any oscillator-based approach, parameter selection and market regime filtering remain critical to reduce false signals in trending phases.

πŸ‘‰ Read | Signals | @mql5dev

#MQL5 #MT5 #Indicator
❀49πŸ‘Œ5πŸ‘€3πŸ”₯1
GUI groundwork is being extended around a new CForm object built on the existing canvas element base. The update adds theme/style infrastructure, refactors element properties, and prepares shadow rendering via a fixed pixel offset around forms.

Core changes include trimming two unused integer properties from the element property enum, adding a canvas offset constant for shadows, and extending the base graph object with visibility control through OBJPROP_TIMEFRAMES using OBJ_ALL_PERIODS and OBJ_NO_PERIODS, plus a foreground operation implemented as hide-then-show.

GCnvElement now stores background color and opacity as members, introduces HSL-based lightness adjustment from ARGB for consistent shading, and adds a protected parametric constructor for descendant types. GraphINI.mqh defines initial color themes and style parameter tables, with InpData.mqh expos...

πŸ‘‰ Read | VPS | @mql5dev

#MQL5 #MT5 #Indicator
❀75✍5πŸ†5πŸ‘€5πŸ‘4⚑3πŸ‘Œ3
An indicator implementing Austin Passamonte’s pivot concept with multi-timeframe support, requiring the selected pivot timeframe to be higher than the active chart timeframe.

Two calculation modes are provided. Original mode follows the referenced pivot formula. Alternate mode adjusts the levels to behave more like traditional support and resistance bands.

Operational guidance remains standard for pivot-based workflows: treat levels as potential reaction zones, validate with price action and context, and avoid assuming deterministic reversals.

The implementation is optimized for runtime efficiency by recalculating only the latest bar on incoming ticks. This makes it suitable for reuse inside other scripts and EAs through iCustom(), without adding significant per-tick overhead.

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #Indicator
❀29πŸ‘Œ2🀯1
Work continues on a base GUI canvas element for an MQL5 library. The focus is adding thin wrappers over CCanvas primitives and text, plus property persistence hooks for later use by an object collection.

Canvas clearing is corrected for alpha: Erase(0) drops transparency and causes artifacts. A NULL_COLOR constant uses 0x00FFFFFF to preserve the alpha channel during clears.

Text anchoring is normalized via an ENUM_TEXT_ANCHOR that encodes TA_LEFT/TA_CENTER/TA_RIGHT with TA_TOP/TA_VCENTER/TA_BOTTOM combinations, removing ambiguity in flag ordering.

Color utilities are centralized by making CColors static and extending it with RGBtoLab(). State persistence is prepared using a struct + StructToCharArray/CharArrayToStruct, with virtual ObjectToStruct/StructToObject and file read/write methods.

πŸ‘‰ Read | NeuroBook | @mql5dev

#MQL5 #MT5 #Indicator
❀65πŸ‘Œ6🀯5😁4πŸ‘€4⚑3
A multi-metric indicator can be used to assess whether a timeframe is tradeable by quantifying structure versus randomness.

Signal-to-Noise Ratio is derived from a rolling linear regression, comparing explained variance to residual variance to separate trend from noise.

A memory check is added via lag-1 return autocorrelation. Values above 0.1 are treated as persistence, while readings near zero are flagged as noise.

Long-range dependence is estimated using the Hurst exponent: ~0.5 suggests random walk, >0.55 trending bias, <0.45 mean reversion.

Volatility clustering is presented as a 0–1 oscillator to indicate variance stability. Shannon entropy is computed from binned returns and normalized to 0–1, where higher values imply increased randomness.

Suggested presets include balanced defaults, trend-following for breakouts, fast intraday settings, a...

πŸ‘‰ Read | CodeBase | @mql5dev

#MQL5 #MT5 #Indicator
❀42πŸ‘Œ3⚑1