Articles on MQL4
MQL-4 executable files (scripts, expert advisers, indicators)

MQL-4 executable files (scripts, expert advisers, indicators)


for example, forex

There are three types of independent executable files in MQL-4. Each file does its own task and is kept in its own directory. Scripts are kept in the folder …MetaTrader 4expertsscripts, indicators are kept in the folder …MetaTrader 4expertsindicators, expert advisers are kept in the folder …MetaTrader 4experts, which contains also folders …scripts and …indicators. It’s easy to define the file type according to the file location, as they have equal file extension *.mq4.

 
 

Each file exercises only its own functions. Thus, different curves may be displayed only from indicators in the simplest and most efficient way. Trading operations may be done only by scripts or expert advisers. Here a digression may be done: the statement about incapability of drawing from scripts or experts seems to be contradicted – it is probable to make and draw graphical objects (vertical, horizontal and trend lines (in the form of a ray), icons of different styles and color) both from scripts and experts. However try to switch over the time-frame of the chart and you’ll have to do it over again, as the graphical objects have conjunction in time and price. In another time-frame all the objects should be deleted and new ones should be drawn.

Indicators, scripts and expert advisers are also objects. Expert adviser that will call to one or several indicators in its own code may be set in the chart. Script is also unlimited in calling the indicators (user-defined or standard). You may also set an indicator which is built on readings of another indicator, which in its turn calls the third one for calculation. In OOP terms (object oriented programming) it may be characterized as follows: object-chart includes object-adviser, which in its turn includes objects-indicators. Let’s represent it in two ways, standard one and in the form of a diagram. Open EURUSD chart, H1 time-frame. Set expert adviser MACD Sample from the standard supply MetaTrader4 and allow it to trade. Moreover set standard indicator Stochastic Oscillator (5,5,5), standard indicator Fractals and user-defined indicator Zigzag (also from the standard supply MetaTrader4). The picture is the following:

 
 

We have three indicators (two standard and one user-defined). Each of them works independently from the others. Moreover, expert adviser is being executed. Work of each indicator requires machinery time (processor operation life) and place in the random access memory (storage budgets). Let’s consider it now from another point of view. EURUSD chart, H1 represents an object-chart window, where three more object-indicators and one object-expert are placed (these objects are called subsidiary). Object-chart gets computer resources and distributes them between its subsidiary objects. In the expert’s code we may see a standard indicator MACD activation with parameters 12, 26, 9. Flipping from the adviser to the indicator creates one more MACD indicator (12, 29, 9) in the expert. We don’t see this indicator in the chart, but nevertheless it exists. Moreover, there are indicators which also refer to readings of the other indicators (standard or user-defined – doesn’t matter) in their estimation. So, except the objects seen in the chart there are objects unseen for us. These objects also acquire computer recourses (processor operation life and storage budgets). Thus, we do not have four (three indicators and one expert) but five objects – three indicators and one expert containing one indicator. I drew it in the following way:

 
 

Actually, often much more than 3 indicators are drawn on the chart, expert advisers that use calls of more than one indicator are used. All these objects use resources intended for the terminal (MetaTrader4). Moreover, when testing indicators and advisers in one terminal, ten and more charts are opened. Each of them contains indicators and adviser. So, correct writing of executable files and efficient algorithm of advisers, scripts and indicators work are of primary concern. Ultimately, I suggest a screen shot of my terminal on weekends (the market doesn’t work and there are no quotations). 19 charts are opened. Each of them contains 4 indicators.

 
 

Processor operation life is almost not used, but memory uses more than 70 mb for the terminal work.


Go to article «Charts».

+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?