Loading…

Objects To MQL4 Code Generator

Drawing a level or a set of annotations by hand on a chart and then wanting that exact layout inside an EA or indicator normally means retyping every coordinate off the screen. This script reads the coordinates back instead: it walks every object on the chart and emits the actual ObjectCreate and ObjectSet calls that would recreate it, as one pasteable MQL4 function written to a text file. It covers the objects that reduce cleanly to the properties this API exposes: horizontal and vertical lines, trend lines (including by-angle), rectangles, text, arrows, labels, rectangle-label panel backgrounds, and a Fibonacci retracement's two anchor points. Multi-anchor tools - equidistant channels, triangles, Gann and Andrews Pitchfork tools, Fibonacci fan/arc/expansion - need more anchor points than OBJPROP_PRICE1/2 exposes and are deliberately left out rather than emitted half-right. Every object the generator cannot handle is named and counted in the Experts log rather than silently dropped, the same policy the companion "Export Chart Objects" script uses for CSV export. Colours are written as the raw packed integer ObjectGetInteger itself returns for OBJPROP_COLOR, so the generated line compiles and reproduces the exact colour without needing a name lookup table. Notes and limitations A Fibonacci retracement is recreated at its two anchor points with default level ratios and colours - custom level edits are not read back, since that needs per-level properties this generator does not walk. This is noted inline in the generated code as well as here. Bitmap and bitmap-label objects are skipped entirely: the object stores no reference back to the original image file path, so there is nothing to emit. Object names containing a double quote or backslash are escaped so the generated string literal still compiles; names are otherwise used exactly as drawn.

Script · MT5 · v1.0 · Free

About Objects To MQL4 Code Generator

Objects To MQL4 Code Generator is a script for MetaTrader 5. It draws buy and sell arrows on the chart and can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Output file and Function name. MQL source code included.

Files in the download: ObjectsToCodeGenerator.ex5, ObjectsToCodeGenerator.mq5, ObjectsToCodeGenerator.txt.

Settings

SettingDefaultWhat it does
Output fileGeneratedObjects.mq5Output file, written under MQL5\Files
Function nameRecreateChartObjectsName of the generated function

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Buy/Sell Arrows · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria