• Join us

Discussion of article "Library for easy and quick development of MetaTrader programs (part XXIV): Base trading class - auto correction of invalid parameters"

To add comments, please log in or register
MetaQuotes
Moderator
214761
MetaQuotes  

New article Library for easy and quick development of MetaTrader programs (part XXIV): Base trading class - auto correction of invalid parameters has been published:

In this article, we will have a look at the handler of invalid trading order parameters and improve the trading event class. Now all trading events (both single ones and the ones occurred simultaneously within one tick) will be defined in programs correctly.

Generally, the EA should be able to act according to the circumstances while following the user-defined logic of handling errors in trading orders. Thus, we may give the following instructions to the EA when a trading order error is detected:

  1. Simply exit the trading method letting the user create the handler of invalid parameters of an erroneous order on their own.
  2. If an invalid value of a trading order can be fixed, do that right away and send it to the server,
  3. If a situation and an error are appropriate, repeat a trading request after a pause or simply repeat the request with the same parameters.

Handling errors in trading order parameters may lead to one of several outcomes:

  • Inability to continue trading using the EA before an error source is eliminated by the user.
  • Inability to send a trading order — exit from the trading method.
  • Correcting invalid values and sending a fixed trading order.
  • Immediate sending of a trading order with the initial parameters (here the assumption is made that trading conditions have improved).
  • Waiting, updating quote data and sending a trading order with the initial parameters.

In this article, we are going to develop the trading order error handler that will check errors and their sources, as well as return the error handling method:

  • disabling trading operations,
  • interrupting a trading operation,
  • correcting invalid parameters,
  • trading request with initial parameters,
  • trading request after waiting (temporary solution),
  • creating a pending trading request (in subsequent articles)

Author: Artyom Trishkin

To add comments, please log in or register