Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

ObjectCreateAndSet - MetaTrader 5 Library - MT4/MT5 Resources

author EAcpu | 3 reads | 0 comments |

ObjectCreateAndSet - library for MetaTrader 5

ObjectCreateAndSet - library for MetaTrader 5

ObjectCreateAndSet - library for MetaTrader 5

ObjectCreateAndSet - library for MetaTrader 5

The attached *.mqh file contains functions for creating objects and changing object properties. It's especially useful to me when I need to quickly write some test code to create objects on the chart and/or change properties of existing objects.

Another file is a script with a usage example (create a text label, gradually rotate it 90 degrees, and change the text and its color along the way).

1. Function to create objects :

These functions are based on standard functions described in MQL5 Reference . Main differences from the corresponding standard functions:

List of functions that create objects:

Create a vertical line

Create a horizontal line

Create a trendline based on given coordinates

Arrow line creation

Creates a line with an arrow based on given coordinates

OBJ_ARROWED_LINE

Create equidistant channels by given coordinates

Rectangle creation

Create a rectangle based on the given coordinates

Creates a triangle based on given coordinates

Create an ellipse based on given coordinates

Create OBJ_ARROW

Create text object

Create text labels

Create a button

Create a bitmap in the chart window

Bitmap label creation

Create a bitmap label object

OBJ_BITMAP_LABEL

Create editing object

Create an event object on the chart

Rectangular label creation

Create a rectangular label

OBJ_RECTANGLE_LABEL

2. Function to set object properties:

Use object set double(...) , object set integer(...) and object set string(...) without specifying modifiers:

Specify modifiers using ObjectSetDouble(...) , ObjectSetInteger(...) and ObjectSetString(...) :

Additional features:

You can use it as an include file or copy some of its functions into your source code.

If you choose the second way, I think it's better to use it as an include file first. Once all necessary function calls have been implemented, you can remove the include directives (#include ...).

The compiler then indicates which functions you need to copy from the include file.

Use as include file:

 #include
The attached script provides an example that includes this library.

  • After that, compile your code. When you start typing a function name, it will allow you to see tooltips for the included functions:
  • ObjectCreateAndSet - library for MetaTrader 5

    Figure 1. The full name of the function in the tool tip after entering the first few letters

    ObjectCreateAndSet - library for MetaTrader 5

    Figure 2. Parameters of function in tooltip

    By the way, you can use the function list button on the meta-editor toolbar to quickly see a list of functions used in the current file:

    ObjectCreateAndSet - library for MetaTrader 5

    Figure 3. Button to display a list of functions used in the file

    When you press the button, a drop-down list appears. To go to a specific function, click its name in the list.

    ObjectCreateAndSet - library for MetaTrader 5

    Figure 4. Pressing the button opens a list of functions in the file (helps to quickly go to a function)


    Attachment download

    📎 objectcreateandset.mqh (96.06 KB)

    📎 test_labelcreate.mq5 (3.58 KB)

    Source: MQL5 #13374

    Verification code Refresh