Mql programming – Create MT4 Objects with MQL4

Spread the love

Mql programming LanguageĀ (or simply metatrader 4 programming language) is a high-level object oriented programming language based on the concepts of the popular C++ programming language. The flexibility of the MQL4 programming language allows users to develop complex programs with large amount of calculations while accurately manage almost all trading robot and indicator parameters.

Mql4 programming

MQL4 contains the basic indicators necessary for analyzing current and historical quotes, and has built-in functions for managing trading orders. All these features of the MetaQuotes Language 4 (also known as metatrader 4 programming or mt4 coding) allows creating applications that can perform operations in the Forex market and thus can completely replace a trader.

In this post I will teach you how to program mql4 and how to create objects on your MT4 chart. So first of all open your MetaEditor.

Then create new mql4 file in your MetaEditor.

Then proceed exactly as it is appearing in the screenshots

Mql Custom Indicator for creating indicators

Name the indicator any name, I named ObjectsInMT4

Choose OnCalculate and press Next

I did not tick Indicator in separate window because I want the indicator to appear in the chart, and Press Finish.

ObjectsInMT4.mq4 file will be created.

In the OnInit method, place this 3 lines of code


This block of code declare 3 objects of type label (Symbol1, Symbol2 and Symbol3).

In the OnCalculate method add this block of code :

      string Symbol_1 = "JOSEPH CHALHOUB";
      string Symbol_2 = "Rpc Technology";
      string Symbol_3 = "";
      ObjectSetText("Symbol1",Symbol_1,"12","Arial Black",Lime);
      ObjectSetText("Symbol2",Symbol_2,"10","Arial Black",Lime);
      ObjectSetText("Symbol3",Symbol_3,"10","Arial Black",Lime);

The first block is declaring the data that it will be held by the objects and will appear in the chart.

The next 3 blocks, they set the fonts of the objects, for example the Symbol1 object is Arial black font.
And its X axis is 23, and Y axis 600, and its color will be red.
The same thing for Symbol2 and Symbol3, with only difference is with the Y axis, respectively 630 and 660, in order for the objects to appear under each others.

And this is it, now we compile the mql file to check for errors.


If no errors then we run our file


The MT4 will load the ObjectsInMT4 indicator directly in the chart

For a full explanation for this mql programming post please visit our YouTube channel “Rpc Technology” and watch the video tutorial