Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

New: Metatrader 5 Libraries | CanvasTabs: a lightweight tab bar for MQL5 based on CCanvas | MetaTrader Tool

Explore the latest free tools from the MQL5 community. Here's a new indicator, expert advisor, or script for MetaTrader.

CanvasTabs draws a tab bar on a chart with the standard CCanvas class. It is a single include file with no DLLs, no trading functions and no built-in persistence. It is meant for panels that need simple tabs without a large GUI framework.

Image for CanvasTabs: a lightweight tab bar for MQL5 based on CCanvas

Features

  • Tab titles, an active tab and a simple hover state.
  • Selection by mouse click or by code (SetActiveTab).
  • Width changes without recreating the chart object (Resize).
  • Long titles are shortened to fit their tab, with an ellipsis when space permits.
  • Several independent instances on one chart; each has its own object and resource names.
  • Height, padding and font size are scaled once from the screen DPI.
  • Destroy() removes only the instance's own object and resource and is safe to call more than once.

Interface

Create(chart, id, x, y, width, titles)
ActiveTab()
SetActiveTab(index)
Resize(width)
OnChartEvent(id, lparam, dparam, sparam)
Destroy()

Tab indices start at zero. OnChartEvent returns true only when a click changes the selected tab; hover, clicks on the active tab and clicks outside the bar return false. Coordinates and widths are in chart pixels. The minimum width is tab_count * (2 * padding + 2). An invalid width or tab index is rejected and the current state is kept. Instance IDs may contain 1 to 16 letters, digits or underscores; an existing name is rejected and never overwritten.

Example (CanvasTabsDemo)

The demo shows two tab bars (3 and 4 tabs) with a content label under each. Keys P and O select the next tab of each bar. The demo, not the library, enables mouse-move events (and restores the previous setting on exit) and keeps the selected tabs during symbol or timeframe changes. Selected tabs are not kept after a terminal restart.

Grid trading done right – try the robust Grid Expert Advisor for controlled risk. Details here.

Input parameter: TestMode (default false) runs built-in checks: duplicate names, invalid input, repeated resizing, repeated destruction and resource cleanup.

Installation

CanvasTabs.mqh: MQL5\Include\CanvasTabs
CanvasTabsDemo.mq5: MQL5\Experts\CanvasTabsDemo

Tested on MetaTrader 5 build 6230 at a screen DPI of 120.

Complement community code with advanced automation from RobotFX.

78866

Best MetaTrader Indicators + Profitable Expert Advisors