Thank you, it is clearly explained. But still there is a question - it is clear that it is faster in MT4, but if we are talking about 5 - is it faster to execute all methods separately than to call one CopyRates? If yes, then it makes sense to create a bar structure/class instead of MQLRates, which would write not all fields, but only the necessary ones in our case, by mask, for example.
Thank you, it is clearly explained. But still there is a question - it is clear that it is faster in MT4, but if we are talking about 5 - is it faster to execute all methods separately than to call one CopyRates? If yes, it makes sense to create your own bar structure/class instead of MQLRates, which would write not all fields, but only the necessary ones in our case, by mask, for example.
As it is a library in development I will wait further articles before doing any global remark.
However I noticed 2 potential problematic situations in this first part :
Firstly.
Sometimes, you may want to get the number of decimal places in a symbol lot. Let's enter this function to our file of service functions:
//+------------------------------------------------------------------+
//| Return the number of decimal places in a symbol lot |
//+------------------------------------------------------------------+
uint DigitsLots(conststring symbol_name)
{
return (int)ceil(fabs(log(SymbolInfoDouble(symbol_name,SYMBOL_VOLUME_STEP))/log(10)));
}
1.a The proposed solution using log is not universal. On some symbol you can perfectly have a volume step of 0.25 for example and the DigitsLots() will return a wrong answer in such case.
1.b Why would you want the "number of decimal places in a symbol lot" ? I don't see any real use case for that.
1.c If you really want to use log function and you will deal with special cases somewhere else, you should use log10, instead of natural logarithm.
1.d Providing such function on the public interface could lead to inefficient results, it uses 5 function calls and could be called several times on each tick.
Secondly.
intOnInit()
{
//---
list_all_orders.Sort();
list_all_orders.Clear();
if(!HistorySelect(0,TimeCurrent()))
{
Print(DFUN,TextByLanguage(": Не удалось получить историю сделок и ордеров",": Failed to get history of deals and orders"));
returnINIT_FAILED;
}
...
2.a This is not a correct way to call HistorySelect(), you could miss some history information as TimeCurrent() returns the last know tick date from the broker server. Rationale from here and from experience.
2.b It's a bad example to use TimeCurrent() in OnInit() function where you have no guarantee to have a broker connection. In general it's a bad idea to do any data request in OnInit().
I will consider the possibility of changing the function to another - completely universal
the number of decimal places for the lot of each individual symbol is necessary for the unmistakable sending of trade orders
Your function with log10 does not have a problem voiced by you with a lot step of 0.25?
data on the number of decimal places is written once to the object of the class-symbol. This will be further - in subsequent articles.
A test check in OnInit () is needed just for checking. And only there I get the history of orders in this way. In collections of orders, deals and positions - otherwise.
All this in subsequent articles.
-------------
Спасибо за комментарии, но это всего лишь тест.
я рассмотрю возможность изменения функции на иную - полностью универсальную
количество знаков после запятой для лота каждого отдельного символа нужно для безошибочной отправки торговых приказов
ваша функция с log10 не имеет озвученной вами проблемы с шагом лота 0.25 ?
данные о количестве знаков после запятой записываются единожды в объект класса-символ. Это будет далее - в последующих статьях
Тестовая проверка в OnInit() нужна всего лишь именно для проверки. И только там историю ордеров получаю таким образом. В коллекциях ордеров, сделок и позиций - иначе.
I will consider the possibility of changing the function to another - completely universal
the number of decimal places for the lot of each individual symbol is necessary for the unmistakable sending of trade orders
Your function with log10 does not have a problem voiced by you with a lot step of 0.25?
data on the number of decimal places is written once to the object of the class-symbol. This will be further - in subsequent articles.
A test check in OnInit () is needed just for checking. And only there I get the history of orders in this way. In collections of orders, deals and positions - otherwise.
All this in subsequent articles.
1. Good.
2. It's not needed if you normalize your lot correctly, something like :
working step by step according to the article . You can be wrong and do not understand.
There are two ways to create a class method - it is directly in the class body:
class CMyClass
{
bool Flag(void) { returnfalse; }
}
and outside the class body:
class CMyClass
{
bool Flag(void);
}
//--- method implemented outside the class bodybool CMyClass::Flag(void) { returnfalse; }
In the first case, the method is defined and implemented directly in the class body - it's convenient to do so for short methods that don't take up many lines. But if the method is large, it is more convenient to declare it in the class body, and put the implementation outside the class body - as in the second example.
It is clear that it is more convenient to write the method inside the class body. But the method you are asking about - it is more convenient to write it separately from the class body.
However, you can download all the files attached to the article - they already contain everything, they are ready for use - and use them to study what is described in the article.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Thank you, it is clearly explained. But still there is a question - it is clear that it is faster in MT4, but if we are talking about 5 - is it faster to execute all methods separately than to call one CopyRates? If yes, then it makes sense to create a bar structure/class instead of MQLRates, which would write not all fields, but only the necessary ones in our case, by mask, for example.
Thank you, it is clearly explained. But still there is a question - it is clear that it is faster in MT4, but if we are talking about 5 - is it faster to execute all methods separately than to call one CopyRates? If yes, it makes sense to create your own bar structure/class instead of MQLRates, which would write not all fields, but only the necessary ones in our case, by mask, for example.
Try this.
Won't you update?
Не понял вопроса.
I do not understand the question.
As it is a library in development I will wait further articles before doing any global remark.
However I noticed 2 potential problematic situations in this first part :
Firstly.
Sometimes, you may want to get the number of decimal places in a symbol lot. Let's enter this function to our file of service functions:
Secondly.
Thanks for the comments, but this is just a test.
A test check in OnInit () is needed just for checking. And only there I get the history of orders in this way. In collections of orders, deals and positions - otherwise.
All this in subsequent articles.
-------------
Спасибо за комментарии, но это всего лишь тест.
Тестовая проверка в OnInit() нужна всего лишь именно для проверки. И только там историю ордеров получаю таким образом. В коллекциях ордеров, сделок и позиций - иначе.
Всё это в последующих статьях.Thanks for the comments, but this is just a test.
A test check in OnInit () is needed just for checking. And only there I get the history of orders in this way. In collections of orders, deals and positions - otherwise.
All this in subsequent articles.
1. Good.
2. It's not needed if you normalize your lot correctly, something like :
Using lot digits can only lead to problem.
3. log10 has the same problem, it's not universal. It was just to avoid the useless call to log(10).
4. Good.
I know it's only to check but even with test code publicly available, I think we have a responsibility to show and use good practices.
I will read other articles.
1. Good.
2. It's not needed if you normalize your lot correctly, something like :
Using lot digits can only lead to problem.
3. log10 has the same problem, it's not universal. It was just to avoid the useless call to log(10).
4. Good.
I know it's only to check but even with test code publicly available, I think we have a responsibility to show and use good practices.
I will read other articles.
Hello
You can consider me your entrant or student so to speak.
I decided to study your library, but it is difficult for me, although I know something in MQL, but I stumbled on the first step.
I came to the point Implementation of the method of comparing two orders with each other by a given property:
This is the code in the library, where to write it
after
or in the protected class of the abstract order.
Please understand that I am not young anymore, young people can grasp this on the fly.
And also I have opened a topic on the forum in Articles and technical library on automated trading (12560) I am a student there I will duplicate this topic I would like an answer from you in detail about the structure,
working step by step according to the article . You can be wrong and do not understand.
Hello
You can consider me your applicant or student so to speak.
I have decided to study your library, but it is difficult for me, although I know something in MQL, but I stumbled at the first step.
I reached the point Realisation of the method of comparing two orders with each other by a given property:
This is the code in the library, where to write it
after
or in the protected class of the abstract order
Please understand that I am not young anymore, but young people can grasp it on the fly.
And also I opened a topic on the forum in Articles and technical library on automated trading (12560) I am a student there I will duplicate this topic I would like a detailed answer from you about the structure,
working step by step according to the article . You can be wrong and do not understand.
There are two ways to create a class method - it is directly in the class body:
and outside the class body:
In the first case, the method is defined and implemented directly in the class body - it's convenient to do so for short methods that don't take up many lines. But if the method is large, it is more convenient to declare it in the class body, and put the implementation outside the class body - as in the second example.
It is clear that it is more convenient to write the method inside the class body. But the method you are asking about - it is more convenient to write it separately from the class body.
However, you can download all the files attached to the article - they already contain everything, they are ready for use - and use them to study what is described in the article.