Canvas Tabs: a lightweight tab bar for MQL5 based on C Canvas
Info
The Canvas Tabs: a lightweight tab bar for MQL5 based on C Canvas is a Expert Advisor for MetaTrader 5 that 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.
Usage
This tool is typically used for automated trading on major forex pairs and gold.
Platform
This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Canvas Tabs: a lightweight tab bar for MQL5 based on C Canvas
1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.
2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.
3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.
4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.
Frequently Asked Questions
Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.
Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.
Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.
What this tool does
CanvasTabs draws a tab bar on a chart with the standard CCanvas class.
Typical Use Case
This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.
Description & Settings
Related: trade signals based on price crossover with moving average, confirmed by adx - another powerful expert for MetaTrader 5 traders.
Also recommended: raymond cloudy day for ea - similar expert with strong performance on MetaTrader 5.
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.
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.
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.
You may also like: Basket Protective Close - excellent alternative for expert users on MetaTrader 5.
Source Code
#property copyright "RobotFX"
#property version "1.01"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#include <CanvasTabs\CanvasTabs.mqh>
input bool TestMode=false;
CCanvasTabs TabsA,TabsB;
string TitlesA[]= {"Overview","Details","Notes"};
string TitlesB[]= {"Summary","A deliberately long tab title","History","Help"};
string LabelA="",LabelB="";
bool OwnLabelA=false,OwnLabelB=false;
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.