Discussion of article "Library for easy and quick development of MetaTrader programs (part XXVII): Working with trading requests - placing pending orders"

 

New article Library for easy and quick development of MetaTrader programs (part XXVII): Working with trading requests - placing pending orders has been published:

In this article, we will continue the development of trading requests, implement placing pending orders and eliminate detected shortcomings of the trading class operation.

In the previous article, we started the implementation of pending trading requests and created the first pending request for opening a position in case an error is received in the trading class after sending a request to the server. In this article, we will resume the development of pending requests and implement creation of a pending request in case of errors occurred when setting pending orders.

While testing the trading class, I have detected some shortcomings. In particular, when initializing symbol's trading objects in the class constructor, hard-set default values were set for them. Not all of those values may have been supported in the symbol specification. This caused server errors when attempting to place pending orders — the server activated the unsupported order expiration type error. This error was not corrected anywhere and eventually led to the inability to place a pending order. When sending a trading request with default values, some unsupported data was also sent to the trading request. To solve this issue, I had to specify correct data corresponding to the appropriate symbol specification directly in the trading request

This required the knowledge of a symbol specification and the manual input of accurate values directly in the program code instead of auto correction of values by the library itself. To simplify things, we are going to make minor changes in the trading class handling logic. All symbol trading objects are to be initialized by auto selection of correct values in the EA's OnInit() handler. The -1 values are passed to the trading methods of the trading class by default for order filling and expiration types indicating it is time to use preset correct default values. If another value is passed from the program, it is applied instead. If the value turns out to be invalid, it is corrected when handling errors in the trading class.

Author: Artyom Trishkin

 

Almost 4 megabytes of code, and the library schema and custom methods are not provided... Are you writing for yourself?

Look through the eyes of your users. What it's like for them to understand all this without reference points.

 
Another question: how "reasonable" is it to set a pending order after an internet outage, without re-interviewing the user? If it takes an hour for the user to get the internet back on and the situation has changed dramatically, is it worth setting the order automatically? Wouldn't it be better to leave a message saying that the order was not set due to lack of internet and the user will decide whether it should be set again?
Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Приказы на проведение торговых операций оформляются ордерами. Каждый ордер имеет множество свойств для чтения, информацию по ним можно получать с помощью функций Идентификатор позиции, который ставится на ордере при его исполнении. Каждый исполненный ордер порождает сделку, которая открывает новую или изменяет уже существующую позицию...
 
Реter Konow:
Another question: how "reasonable" is it to set a pending order after an internet outage, without re-interviewing the user? If it takes an hour for the user to get the internet back on and the situation changes dramatically, is it worth setting the order automatically? Isn't it better to leave a message saying that the order was not set due to the lack of internet connection and the user will decide whether it should be set again or not?
Doesn't the article describe the principle and why this is the case?
 
Artyom Trishkin:
Doesn't the article describe the principle, and why exactly?

Specifically in this article there is no word why it is decided to send a pending order immediately after the Internet connection, without repeated polling of the user.

There is a warning that the pending requests presented in the article cannot be used in real trading. That is, it is all concept testing and nothing more.

There is no explanation for setting an order after reconnecting the Internet without polling the user.

And do you really need several articles to test an uncomplicated mechanism of a pending trade request? Moreover, it is easier and more correct to poll the user again and that's all.

 
Реter Konow:

Specifically in this article there is no word why it is decided to send a pending order immediately after the internet connection, without re-questioning the user.

There is a warning that the pending requests presented in the article cannot be used in real trading. That is, it is all concept testing and nothing more.

There is no explanation for setting an order after reconnecting the Internet without polling the user.

And do you really need several articles to test an uncomplicated mechanism of a pending trade request? Moreover, it is easier and more correct to poll the user again and that's all.

Do not forget that this is only an article written for those who want to understand something. It is just a small piece of programming lesson, not a ready-made Expert Advisor. The article describes and shows in the code how and what to do to achieve the desired result. If you need to make a user poll in your Expert Advisor, nobody forbids you to do it.

 
Реter Konow:

Specifically in this article there is no word why it is decided to send a pending order immediately after the internet connection, without re-questioning the user.

There is a warning that the pending requests presented in the article cannot be used in real trading. That is, it is all concept testing and nothing more.

There is no explanation for setting an order after reconnecting the Internet without polling the user.

And do you really need several articles to test an uncomplicated mechanism of a pending trade request? Moreover, it is easier and more correct to poll the user again and that's all.

Please read the previous article - there is an explanation of why this is necessary. Hint:
1. Sleep() function stops the execution of the Expert Advisor. At all.
2. Multicurrency Expert Advisor.
You don't quite understand this concept. Hence such questions.
For the user survey everything will be. By means of the library. But not inside trading methods - they should not and will not do it.
 
Alexey Viktorov:

Do not forget that this is only an article written for those who want to understand something. It is just a small piece of programming lesson, not a ready-made Expert Advisor. The article describes and shows in the code how and what to do to achieve the desired result. If you need to make a user poll in your Expert Advisor, nobody forbids you to do it.

1. Taking care of those who want to understand, it would be good to make a library scheme to facilitate orientation on the material.

2. Each amendment made by the author in trading functions is not a reason to print them in every article. The material is bloated. The same trading functions are swapped from article to article with minor changes. Now there will be codes of pending requests? This does not clarify but confuses the reader.

3. There will be 30 articles soon, and the author warns against using the library. What is it for then? To teach how to write a library that is undesirable to use?

 
Реter Konow:

1. Taking care of those who want to understand, it would be nice to make a library diagram to make it easier to navigate through the material.

2. Each amendment made by the author in trading functions is not a reason to print them in every article. The material is bloated. The same trade functions are swapped from article to article with minor changes. Now there will be codes of pending requests? This does not clarify but confuses the reader.

3. There will be 30 articles soon, and the author warns against using the library. What is it for then? To teach how to write a library that is undesirable to use?

Do you eat mincemeat raw? Here, so that you don't eat it, and the warning is given - in this and last article there is preparation of material and debugging of the concept.
And, yes, if necessary, the methods will be changed and the changes will be explained.
I don't support trolling in questions - I like substantive conversation.
 
Artyom Trishkin:
Do you eat mincemeat raw? Here, so that you do not eat it, and a warning is given - in this and the last article is preparing the material and debugging the concept.
And, yes, if necessary, the methods will be changed and the changes will be explained.
I don't support trolling in questions - I like substantive conversation.

I thought articles should have completed solutions. And what is there to debug?

If communication with the server was interrupted, record the order data, set the flag of rechecking communication with the server. We recheck in a loop until the connection is established. After communication is restored, we ask the user if he wants to set the failed order. If yes - send it back, remove the flag and delete the order data from the list of failed orders. In general, the whole concept.

 
Seems pretty substantive.