Download MetaTrader 5

Examples: MQL4 Language for Newbies. Custom Indicators (Part 1)

To add comments, please log in or register
How to use MQL5.community messages editor? Find out in the article!
MetaQuotes Software Corp.
Moderator
181343
MetaQuotes Software Corp. 2007.10.30 09:50 

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

This is the fourth article from the series "MQL4 Languages for Newbies". Today we will learn to write custom indicators. We will get acquainted with the classification of indicator features, will see how these features influence the indicator, will learn about new functions and optimization, and, finally, we will write our own indicators. Moreover, at the end of the article you will find advice on the programming style. If this is the first article "for newbies" that you are reading, perhaps it would be better for you to read the previous ones. Besides, make sure that you have understood properly the previous material, because the given article does not explain the basics.

Types of Indicators

Now I will show you, what kinds of indicators exist. Of course, you have seen a lot of them, but now I would like to draw your attention to features and parameters of indicators, thus we will make a small classification of features and parameters. It will then help you to write custom indicators. So, the first simple indicator:

This is Moving Average, MA, a widely used technical indicator. Pay attention to the following important facts:

  • the indicator is drawn in the chart window
  • the indicator shows only one value
  • the range of the indicator values is unlimited and depends on the current prices
  • the line is drawn with a certain color, width and style (solid line)

Author: Antoniuk Oleg

okwh
1631
okwh 2007.10.30 11:33  
How to draw candle type indicator in seperate(sub) windows  like in chart window?
Antoniuk Oleg
205
Antoniuk Oleg 2007.11.15 18:37  
DxdCn:
How to draw candle type indicator in seperate(sub) windows  like in chart window?
You can't draw candle type indicator in subwindow. But you can use graphic objects to do this (not easy).
Salt Cafe
75
Salt Cafe 2007.11.19 16:52  
Hi, I've followed your article and found it very useful.

I have 2 questions for you:

Question 1:

I've attached an image below where the results do not appear to make sense. For example see highlighted bars A (no sell signal where there should be one), B (sell signal when there shouldn't be one) & C (no buy signal when there should be one). I'm trying to find out why there is such a difference, but can't understand it.



The only way that I could see this happening is that in the "RandonIndicatorSignal" does not use the same values of randomness then the one being displayed in the window. (ie. it would mean that on this chart there are actually 2 seperate instances of the "RandomIndicator" created by MT4, one for display purposes on the chart and another instance for the actual Signal variation.) Is this actually true?

Question 2:

Also, I've noticed your sentence:
The fact is, there are some situations, when the last tick of the previous bar remains unprocessed, because when the last tick came, the last but one tick was processed.
This is part of your discussion to justify the following code fragment:
if(counted_bars>0)
      counted_bars--;
Can you please explain what are these situations where the last tick in a previous bar remains unprocessed? It would appear that because of this, we have to calculate the current bar and the previous bar. Which means that on occasions the value for the previous bar could change depending on this "last tick" and that could change the outcome for our custom indicator.

PS. Minor suggestion, since this a multi-part series of articles, it would handy to have links of the previous articles embedded in this article.
MQL4 Comments
16319
MQL4 Comments 2008.01.02 23:08  
DxdCn:
How to draw candle type indicator in seperate(sub) windows  like in chart window?
You might search for Linear Price Bar or LPB.mql on the internet.  It is similar to what you request.
MQL4 Comments
16319
MQL4 Comments 2008.05.21 14:27  
I am a newbie and shall be very much thankful if someone advise me how to save the custom indicator properties changed by me. I use a set of custom indicators on different currencies and like changing the line width to 4 or 5 for better visibility but as soon as i switch the chart to different time frame or restart the platform it again picks up the default thickness of the lines despite I have made a single template of all the indicators. Or if i will have to change the indicator in MetaEditor, please advise how?
MQL4 Comments
16319
MQL4 Comments 2009.11.02 13:42  

im a newbi but i dont understan this article... so hard .. what dose mQL4 do..??????????


molanis
384
molanis 2010.02.22 17:55  

You can create custom indicators in less than a minute with a custom indicator builder. It's a graphical environment to create Custom Indicators. No coding is required. No need to know/learn how to program in MQL.

Read more about it here: http://www.molanis.com/products/molanis-technical-indicator-builder/custom-indicator-design

You can download it here: http://www.molanis.com/products/molanis-technical-indicator-builder/forex-technical-indicator-builder-download


Features and Benefits

  • Create Custom Indicators without writing any code.
  • Fast development time. Test your trading ideas in minutes.
  • No programming skills or MQL knowledge are required.
  • Leading Edge Code Generation creates all the code for MetaTrader.
  • Keep your trading and indicator ideas to yourself. No need to share your knowledge with programmers.
  • Gives you access to Molanis Online Community, Molanis Forum and free custom indicators for MT4.
  • Free trial!
MQL4 Comments
16319
MQL4 Comments 2010.08.18 22:43  

If you are interested in automating trading of your custom indicators, you can do it very simply at http://www.eacreator.com/

All parameters and modes will be read automatically from your custom indicator mql4 file and you will see them on web site. Creating EA with custom indicators takes just several minutes and you will have automated system with important features like money/risk management, various trailing stops, dynamic SL/TP, martingale, strategy reversal and many others.

MQL4 Comments
16319
MQL4 Comments 2010.09.25 02:12  

Indicators are much more difficult to write than EA's I can write an EA to do anything I want it to do, but I have never managed to write an indicator that actually worked other than by modifying an existing one.

MQL4 Comments
16319
MQL4 Comments 2010.10.29 16:54  
SDC:

Indicators are much more difficult to write than EA's I can write an EA to do anything I want it to do, but I have never managed to write an indicator that actually worked other than by modifying an existing one.


Further to that comment, This tutorial helped me learn how to create my own indicators, I would recommend everyone learning mql4 read this tutorial
12
To add comments, please log in or register