Articles on MQL4
Object Representation in MetaTrader4

Object Representation in MetaTrader4


for example, forex

It is very difficult to program in MQL-4 without knowing object-oriented programming (OOP). OOP languages are high-level languages, that is why many traders, who wrote indicators and advisers in MQL-2, faced difficulties. Actually, it is not so difficult. The terminal, MetaTrader 4, gives a lot of examples of objects, which help understand this concept. An object is a structure of a programing language, which possesses some definite features. Herewith some objects may contain some other objects. For example, if menu «Window»-«Windows» is chosen in the terminal, a popup window appears with a list of charts. This list displays the opened instruments with specified time-frames. The window with AUDUSD chart in the H4 time-frame goes first. That is, the charts windows are objects.

 
 

If you choose the first window and press button F8 («Features»), the next window will appear, where features of the chart (object) are given. Features-attributes of the chart-object are given there. We see the color of the background, text, grid, line chart, bar and candlesticks colouring. This is a typical example of object programming, though we can not get access to these features of the chart by means of MQL-4. There as lots of other objects, access to which can be got in the terminal as well as indicators and advisers (and scripts) in MQL-4. Trend lines, vertical and horizontal lines, text marks, texts, patterns, etc are among them. These objects have at least one feature in common, this is the color in which they are displayed in the chart.

 
 

Moreover, standard (inbuilt) indicators and users indicators are also an example of the object. If combination Ctrl+I is pressed in the chart, which contains indicators, the list of indicators, attached to this chart, will appear, that is chart-object contains indicators-objects.

 
 

These indicators can be placed either in the main window of the chart (in the price chart) or in its own separate window, if the indicator does not fit into the price range. The choice of the indicator position (either in the main window or in its own additional window) is also specified by the features of this indicator-object. And again, in case some certain indicator is chosen from the list (with the double click of the mouse), the window with this indicator features appears.

 
 

With the help of tabs we can move along the indicator features and set input parameters of the indicator (the value of the indicator on every bar depends on it), the color of every line and levels of the indicator, and we can also specify the charts where the indicator should be displayed. These features can be modified from the terminal as well as from programs, written in MQL-4. That is why one of the main questions is how to write one's own indicator and from the indicator code get access to the objects features, which are placed in the chart by the user or created by the indicator code.


Go to article «MQL-4 executable files (scripts, expert advisers, indicators)».

+7 (495) 710-76-76
© 1998—2008 «Alpari»

close

Your Personal Area

For alpari.classic enter your account number (a letter and 4 figures) and the code word for the Personal Area.

For alpari.micro account: enter your login (6 figures) and the password for MT.

Open an account!Forgotten your password?