An amazing "approach" is used by respected and experienced programmers to "solve the problem" of 5-digits. And now this "approach" is also cultivated among beginners, in educational, we may say, literature.
The "approach" given by the author completely nullifies the whole advantage of 5-digit. Instead of explaining to a beginner that the introduction of a 5-digit quote makes it possible to set, for example, take profit not 10 pips, but 10.5. And also to explain that when using an Expert Advisor with a 5-digit quote it is necessary to specify take profit not 10 pips but 100. Instead of such explanations, lines are introduced into the programme code, which programmatically do not make it possible to use the advantages of 5-digit quotes.
"We must be sure that our EA will work correctly with all brokers". Well, we are sure and then what? How can we use the advantage of 5-digit quotes now, if programmatically the Expert Advisor has "sentenced to serve correctly".
And if
_Digits==3
then what, it's all the same ?
STP = STP*10;
TKP = TKP*10;
And what do we get? Isn't it more correct to write?
//--- Whether the number of bars is sufficient for operationif(Bars(_Symbol,_Period)<60) // total number of bars on the chart is less than 60?
{
Alert("On a chart of less than 60 bars, the EA will not work!!!");
return;
}
and a little further away
//--- Do we have enough bars on the chart to work with?int Mybars=Bars(_Symbol,_Period);
if(Mybars<60) // if the total number of bars is less than 60
{
Alert("On a chart of less than 60 bars, the EA will not work!!!");
return;
}
And I read another interesting thing in the documentation:
if copying of timeseries and indicator values should be done frequently, for example, at each call of OnTick() in Expert Advisors or at each call of OnCalculate() in indicators, then in this case it is better to use statically distributed arrays, because memory allocation operations for dynamic arrays require additional time and it will affect testing and optimisation of Expert Advisors.
In mql4 i programmed my few ea in few days without any learning, it was that easy. I know dozens of different programming languages (java, c, php, other minor or outdated languages). mql5 language is not so intuitive as mql4. It's a shame there is no converter between languages. I have to take a deep breath and start learning..
thank you for this article.
I felt lost when I start looking the MQL5 examples... after looking at your article, everithing is much easier to understand.
Ottima spiegazione :-) Grazie :-)
Excellent article Tank You :-)
Great Article,
It helps me to save more than 3 months, Thank you, I am going to your next related article (OOP)
hoping to see money marking expert and sharing with you, I looking forward to such article,
Thank you again,
Dear Sam,
I have already download your; " my_first_ea" and I have tried, it's enjoy. thank you very much!
because of your EA, I'm interest to make EA by my logic reason, it can't trade by self. sorry I'm beginer n don't know what code in mql basic.
FYI; this EA is not error and warning when I've compile, but it can't execute trading.
could you please to help me?
thank you very much for your helping
An amazing "approach" is used by respected and experienced programmers to "solve the problem" of 5-digits. And now this "approach" is also cultivated among beginners, in educational, we may say, literature.
The "approach" given by the author completely nullifies the whole advantage of 5-digit. Instead of explaining to a beginner that the introduction of a 5-digit quote makes it possible to set, for example, take profit not 10 pips, but 10.5. And also to explain that when using an Expert Advisor with a 5-digit quote it is necessary to specify take profit not 10 pips but 100. Instead of such explanations, lines are introduced into the programme code, which programmatically do not make it possible to use the advantages of 5-digit quotes.
"We must be sure that our EA will work correctly with all brokers". Well, we are sure and then what? How can we use the advantage of 5-digit quotes now, if programmatically the Expert Advisor has "sentenced to serve correctly".
And if
_Digits==3
then what, it's all the same ?
STP = STP*10;
TKP = TKP*10;
And what do we get? Isn't it more correct to write?
STP = STP/10;
TKP = TKP/10;
Why is the same code repeated twice in the OnTick function?
and a little further away
And for optimisation it would be nice to use ArrayResize to dynamic arrays: https://www.mql5.com/en/docs/array/arrayresize
And I read another interesting thing in the documentation:
if copying of timeseries and indicator values should be done frequently, for example, at each call of OnTick() in Expert Advisors or at each call of OnCalculate() in indicators, then in this case it is better to use statically distributed arrays, because memory allocation operations for dynamic arrays require additional time and it will affect testing and optimisation of Expert Advisors.
https://www.mql5.com/en/docs/series