Hey there, fellow traders! Have you ever found yourself needing to copy and paste graphical objects between different charts? If so, you're not alone! Unfortunately, MetaTrader doesn't offer a straightforward "Copy & Paste" feature for these objects. The closest solution is using templates (tpl-files), but they save the entire chart state—indicators, settings, and all that extra fluff—which is often more than you need.
That's where my handy indicator, ChartObjectsCopyPaste.mq5, comes into play. This tool allows you to select and copy graphical objects directly to your clipboard, making it a breeze to paste them onto other charts—no strings attached!
This indicator is built on the foundation of another one you might know from the algotrading book: ObjectGroupEdit.mq5. If you're curious about the underlying classes like ObjectMonitor and MapArray, feel free to check them out!
To get started, you’ll want to attach the indicator to at least two charts: the source chart where you want to copy objects from, and the target chart where you plan to paste them. While it’s running, the indicator keeps an eye on existing graphical objects and tracks which ones you’ve selected for copying.
As with any good copy-and-paste operation, you’ll need to remember a couple of hotkeys:
- Press Ctrl+Q to copy all selected objects to your Windows clipboard as text. You can open this clipboard content in any text editor—an example is shared below.
- On your target chart, hit Ctrl+J to paste the objects you've copied.
Now, you might be wondering why I chose Ctrl+Q and Ctrl+J. Well, unfortunately, MetaTrader intercepts many common hotkeys, so these two were some of the few available options. Standard hotkeys like Ctrl+C and Ctrl+V just don’t work in this context.
If you’re a bit tech-savvy, the source code is available for you to tweak those hotkeys to something else if you prefer!
Since this indicator uses system DLLs to access the Windows clipboard, you’ll need to allow DLL imports in the Properties dialog, specifically under the Dependencies tab.
Just a heads up: because the Codebase doesn’t allow DLL imports, the clipboard-related code is wrapped in a conditional preprocessor directive. Be sure to uncomment the line:
#define DLL_LINK
before you compile it. Otherwise, you’ll get alerts when you try to use the hotkeys, but nothing will actually happen!
Here are the inputs you can work with:
- MakeAllSelectable: A flag to make all objects selectable (normally false for objects created programmatically).
- LogDetails: A flag to output all properties of transferred objects to the log.
Keep in mind, the indicator doesn’t verify if the pasted objects match the target chart’s specifications, like symbol, price range, or number of subwindows—that’s up to you!
Here’s an example of what the clipboard text looks like with two objects:
OBJ_VLINE H1 Vertical Line 5578 0 0 enum ENUM_OBJECT_PROPERTY_INTEGER 0 OBJPROP_COLOR 55295 1 OBJPROP_STYLE 2 2 OBJPROP_WIDTH 1 3 OBJPROP_BACK 0 4 OBJPROP_SELECTED 1 7 OBJPROP_TYPE 0 8 OBJPROP_TIME 1726739940 10 OBJPROP_SELECTABLE 1 11 OBJPROP_CREATETIME 1726847009 12 OBJPROP_TIMEFRAMES 2097151 200 OBJPROP_LEVELS 0 207 OBJPROP_ZORDER 0 208 OBJPROP_HIDDEN 0 1032 OBJPROP_RAY 1 enum ENUM_OBJECT_PROPERTY_DOUBLE 9 OBJPROP_PRICE 1.11449 enum ENUM_OBJECT_PROPERTY_STRING 5 OBJPROP_NAME H1 Vertical Line 5578 6 OBJPROP_TEXT 206 OBJPROP_TOOLTIP OBJ_CHANNEL H1 Equidistant Channel 40885 5 1 enum ENUM_OBJECT_PROPERTY_INTEGER 0 OBJPROP_COLOR 255 1 OBJPROP_STYLE 0 2 OBJPROP_WIDTH 1 3 OBJPROP_BACK 0 4 OBJPROP_SELECTED 1 7 OBJPROP_TYPE 5 8 OBJPROP_TIME 1726758000 8 OBJPROP_TIME.1 1726797600 8 OBJPROP_TIME.2 1726758000 10 OBJPROP_SELECTABLE 1 11 OBJPROP_CREATETIME 1726847883 12 OBJPROP_TIMEFRAMES 2097151 200 OBJPROP_LEVELS 0 207 OBJPROP_ZORDER 0 208 OBJPROP_HIDDEN 0 1003 OBJPROP_RAY_LEFT 0 1004 OBJPROP_RAY_RIGHT 0 1031 OBJPROP_FILL 0 enum ENUM_OBJECT_PROPERTY_DOUBLE 9 OBJPROP_PRICE -28.113879003558715 9 OBJPROP_PRICE.1 -21.708185053380777 9 OBJPROP_PRICE.2 -48.04270462633452 enum ENUM_OBJECT_PROPERTY_STRING 5 OBJPROP_NAME H1 Equidistant Channel 40885 6 OBJPROP_TEXT 206 OBJPROP_TOOLTIP
And here’s what those objects look like once pasted onto the chart:

Comments 0