Download MetaTrader 5
To add comments, please log in or register
Download MetaTrader 5 and start trading today!
MetaQuotes Software Corp.
MetaQuotes Software Corp. 2008.01.17 18:53 

New article MQL4 Language for Newbies. Custom Indicators (Part 2) has been published:

This is the fifth article from the series "MQL4 Languages for Newbies". Today we will learn to use graphical objects - a very powerful development tool that allows to widen substantially possibilities of using indicators. Besides, they can be used in scripts and Expert Advisors. We will learn to create objects, change their parameters, check errors. Of course, I cannot describe in details all objects - there are a lot of them. But you will get all necessary knowledge to be able to study them yourself. This article also contains a step-by-step guide-example of creating a complex signal indicator. At that, many parameters will be adjustable which will make it possible to change easily the appearance of the indicator.

About Graphical Objects

You often deal with them when working in MetaTrader 4 terminal. You can use graphical objects for various purposes. Traders place support and resistance levels, pivot points, Fibonacci levels etc. Let us view a simple example of using objects:

Four graphical objects are attached to this chart:

  • 2 horizontal lines
  • a text object
  • an object-symbol (an arrow)

Today we will learn to attach such objects using MQL4. Just imagine how many manual actions can be automated by using objects! For example, have you ever calculated pivot points, support and resistance levels and then drawn them manually? Well, there is not so much work, but if this process is automated in MQL4, the terminal will calculate and draw the corresponding levels itself. All you need is a double click on the script name, and everything will be done. Besides, using graphical objects one can write very useful signal indicators.

Author: Antoniuk Oleg

alfredo 2008.01.17 23:06  
Thanks! Very useful tutorial, thanks a lot!
MQL4 Comments
MQL4 Comments 2008.01.18 01:18  
Hey.. the deinit function deletes all existing objects on the chart! So the code should be revised to enumerate and erase specifically the indicator's objects
Antoniuk Oleg
Antoniuk Oleg 2008.01.18 15:53  
Hey.. the deinit function deletes all existing objects on the chart! So the code
should be revised to enumerate and erase specifically the indicator's objects
Try this version of deinit():
int deinit()
   // deleting table of signals
   for(int x=0;x<9;x++)
      for(int y=0;y<3;y++)
  // deleting names of timeframes    
  // deleting names of indicators 
MQL4 Comments
MQL4 Comments 2008.02.01 09:27  
please is there any way this lesson can be simplify, so i can understand it very well. Thank you

MQL4 Comments
MQL4 Comments 2008.04.28 00:22  


What a great series you have created.  For the first time, I am beginning to comprehend the MQL4 language.  Your descriptions and layouts are very easy to understand.  I just want you to know how much I appreciate your articles.  I am hoping that you are planning to continue the series to include the development of EA's.  I hope it will be soon!  I offer my encouragement and appreciation for a job well done.


Mike Johnson, USA

MQL4 Comments
MQL4 Comments 2008.05.15 14:48  

have you test in real account ?

what is the result ? profit ?

MQL4 Comments
MQL4 Comments 2008.08.06 22:59  
Brilliant tutorial. I actually enjoyed coding mql4 for once. Very easy to follow and makes mql4 easier to understand.
MQL4 Comments
MQL4 Comments 2008.12.17 12:58  
I'm having some trouble understanding the use of text vs. label objects in my EA. What's the difference between them? I can put labels in corners, but have trouble putting words on the chart at a time and amount. Why would you use one or the other? How can in insure that they appear when I hit the "Open chart" button after optimization? Are there amy differences between their use in EAs and their use in indicators?
okwh 2009.03.20 06:00  
  • window – the window number, in which the object should be drawn. If you need to draw an object on a chart, i.e. in the main window, use 0 as the window number.

how to use current window ? a indicator maybe in amin window or subwindow, I need to use the window the indicatoe inside.

OldZ 2010.05.05 12:26  

you explain is very clear !
Thank you !

/ /12
To add comments, please log in or register