Discussion of article "Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator"
After downloading the file "indicator_TP_en.mql5", rename it to "indicator_TP.mql5", please.
This ExpertAdvisor does not work on MT5 build 712, at least not for me.
There is an error message "Cant't copy indicator buffer".
Also the indicator does not compile without warnings,
"possible loss of data due to type conversion" on line 53,
"possible use on uninitialized varaiable 'day_n'" on line 54
"possible use on uninitialized varaiable 'h_day'" on line 62
"psosible use on uninitialized varaiable 'l_day'" on line 63
Can you correct these problems, please?
This is otherwise a good example for us who have background in other software but MT5.
- www.mql5.com
This is a excellent article, for beginners and people who comes from mql4, with in prime a good trading strategy example.
There are some minor lacks in code (error checking not always implemented), but the EA works very well if used on minute timeframe as recommended by the author. Warnings when compiling the indicator are only warnings, and are not blocking you to use it and the EA.
Thank you.
- www.mql5.com
this is not an easy way of explaining mql5 to the people. (like beginners ever had chance to understand it!) its like with programming books 90% of people dont have idea how to start. They open this book for example about c programming and first "Easy example" is long for 1 whole page written in tiny fonts. In my whole life i read only one good programming book that could teach programming to anyone. The reason for that is that they are being written by probably excellent programmers, but unfortunately very bad teachers. Programming can be really easy and i will prove it to you making a simple tutorial for MQL4 programming language when i have a little more time than now. For everyone - even total beginners. The biggest mistake is to teach people details of language most of their work should be ctrl+C and ctrl+v and use google for the commands and most important - keeping everything VERY SIMPLE. I know 10+ programming languages (I programm since i was 7) and i am still am scared by the way this "Easy example" on 11kb (!!!) is explained. I would like to know is there is any real programming beginner that learned MQL5 from this example ;D. I doubt it and if there is you can count these people on fingers of one hand.
- 2012.08.02
- MetaQuotes Software Corp.
- www.mql5.com
this is not an easy way of explaining mql5 to the people. (like beginners ever had chance to understand it!) its like with programming books 90% of people dont have idea how to start. They open this book for example about c programming and first "Easy example" is long for 1 whole page written in tiny fonts. In my whole life i read only one good programming book that could teach programming to anyone. The reason for that is that they are being written by probably excellent programmers, but unfortunately very bad teachers. Programming can be really easy and i will prove it to you making a simple tutorial for MQL4 programming language when i have a little more time than now. For everyone - even total beginners. The biggest mistake is to teach people details of language most of their work should be ctrl+C and ctrl+v and use google for the commands and most important - keeping everything VERY SIMPLE. I know 10+ programming languages (I programm since i was 7) and i am still am scared by the way this "Easy example" on 11kb (!!!) is explained. I would like to know is there is any real programming beginner that learned MQL5 from this example ;D. I doubt it and if there is you can count these people on fingers of one hand.
You are right about programmers not being good teachers in general.
But I don't agree when you said mql5 is so difficult to learn, mainly for a programmer who have experimented with 10+ languages.
Im new at mql5 programming.
Was trying to learn through this example, but im a bit lost with the loop at the end of the indicator build. Where exactly did he assign a value to day_n variable?
Because the loop will check for day_n<day_t. How can the program know day_n value?
for(i=prev_calculated;i<rates_total;i++) { day_t=time[i]/PeriodSeconds(ATRtimeframe); if(day_n<day_t) { day_n=day_t; h_day=high[i]; l_day=low[i]; } else { if(high[i]>h_day) h_day=high[i]; if(low[i]<l_day) l_day=low[i]; } bu[i]=l_day+atr[1]; bd[i]=h_day-atr[1]; }
And how is it calculated at all? Lets assume rate_total = 10 and there is still no calculated bar yet. So prev_calculated = 0
day_t=time[0] (TODAY! since its counted backwards)/PeriodSeconds... since it starts counting from 1970, lets assume it starts count from 10 days ago. so it should give 10, right?
So day_t=10. Now it checks if dayt > dayn. I dont know dayn, but i know dayt=10. Im gonna assume dayn is zero, since there is no value.
Then dayn becomes 10 too. Ok.
Second roll of the loop. prev_calculated + 1= 1.
DayT=time[1] (yesterday)/period... remember, it starts counting from 10 days ago... but now only until yesterday. it should give a value of 9, right?
but now dayN < dayT is false. Then it starts to perform the else expressions. Ok. I understand.
It then will calculate all the bu[] and bd[]. Ok. The loop will end when prev < total rate is false.
But when a new bar arrives, and it becomes true again, i will start from zero again? Or it will start from 10 and go straight to the else part?
Thanks!!!!
this is not an easy way of explaining mql5 to the people. (like beginners ever had chance to understand it!) its like with programming books 90% of people dont have idea how to start. They open this book for example about c programming and first "Easy example" is long for 1 whole page written in tiny fonts. In my whole life i read only one good programming book that could teach programming to anyone. The reason for that is that they are being written by probably excellent programmers, but unfortunately very bad teachers. Programming can be really easy and i will prove it to you making a simple tutorial for MQL4 programming language when i have a little more time than now. For everyone - even total beginners. The biggest mistake is to teach people details of language most of their work should be ctrl+C and ctrl+v and use google for the commands and most important - keeping everything VERY SIMPLE. I know 10+ programming languages (I programm since i was 7) and i am still am scared by the way this "Easy example" on 11kb (!!!) is explained. I would like to know is there is any real programming beginner that learned MQL5 from this example ;D. I doubt it and if there is you can count these people on fingers of one hand.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator is published:
MetaQuotes Programming Language 5 (MQL5), included in MetaTrader 5 Client Terminal, has many new possibilities and higher performance, compared to MQL4. This article will help you to get acquainted with this new programming language. The simple examples of how to write an Expert Advisor and Custom Indicator are presented in this article. We will also consider some details of MQL5 language, that are necessary to understand these examples.
Author: Denis