Attachments forums

Re: 🔺 MT5 XARD - Simple Trend Following Trading System

Pelle, Thu Oct 22, 2026 6:32 am

I have long wished for a "Toggle Border" feature for MT5.

Today, after an extensive "discussion" with an AI, we managed to create something like that.

I have included images showing the "on" and "off" states. The fact that the headers of the lower elements end up underneath the upper ones is, in my view, a minor formatting detail.


(Note: Requires "Allow DLL imports" enabled in the indicator's Dependencies tab, as it uses standard Windows user32.dll and gdi32.dll API calls.)
MT5 itself (terminal64.exe) requires the `user32.dll` and `gdi32.dll` libraries to function.

Toggle Borders for MT5 (64-bit) – Port & Technical Overview

Here is a working 64-bit MetaTrader 5 port of Mladen’s classic Toggle borders indicator (Toggle borders.mq5). It adds an on-chart on/Off button that removes the title bars and borders from all open tiled chart windows at once, expanding the charts seamlessly into a clean multi-chart grid.

Why a Direct MT4-to-MT5 Conversion Didn't Work

It is often claimed that removing chart window borders is impossible in MT5 because simple SetWindowLong style changes from MT4 no longer work in modern 64-bit MT5 builds. Specifically:

64-bit Handles (HWND / HRGN): MT4 used 32-bit int handles and ANSI (GetWindowLongA / SetWindowLongA). MT5 is 64-bit and requires long handles (intptr_t) and Unicode (GetWindowLongW / SetWindowLongW).
Custom MDI Non-Client Frame in MT5: In MT5, each docked chart (AfxFrameOrView140su) sits inside an MDI child container (hWindow = GetParent(hChart)). Even after stripping WS_CAPTION, WS_BORDER, WS_THICKFRAME, and WS_EX_CLIENTEDGE, MT5’s custom window procedure still reserves a non-client frame margin around the chart (6px left/right/bottom and 29px top title bar).
How This MT5 Version Works
MDI Child Enumeration: Starting from the current chart’s MDI container (hMDIClient), the indicator iterates through all open chart subwindows so a single button click toggles borders across all tiled charts simultaneously.
Style Stripping + Margin Expansion: When toggled on, it measures each window's exact non-client margins (mL, mT, mR, mB), strips the caption/border window styles, expands the outer MDI child window by those exact margins, and resizes the inner chart view to fill the full original tile dimensions (origW x origH).
Region Clipping (SetWindowRgn): It applies a rectangular clipping region (CreateRectRgn + SetWindowRgn) matching the exact inner chart canvas so the overhanging non-client frame margins do not overlap adjacent charts, and keeps the region enforced when switching active charts.
Exact State Restoration: Original coordinates, margins, and window styles are stored per window handle so toggling Off (or removing the indicator) restores every chart window to its exact original tiled position and size without cumulative zoom/resize drift.
Added Input Parameters
Button Corner: Place the toggle button in any of the 4 chart corners (Top-Left, Top-Right, Bottom-Left, Bottom-Right)
X / Y Distance (pixels): Fine-tune button position from the selected corner
Button Width / Height: Customize button dimensions

(Note: Requires "Allow DLL imports" enabled in the indicator's Dependencies tab, as it uses standard Windows user32.dll and gdi32.dll API calls.)
All files in topic