Skip to content
All library documents

Handling Invalid Trade Parameters and Capturing Concurrent Trading Events

Article MQL5 articles

Summary

This installment describes a trading-library design for responding to invalid order parameters and preserving multiple trading events. Rather than always rejecting an order, the handler classifies errors and can disable trading, stop the current operation, correct fixable values, retry with unchanged values, refresh quotes and retry, or prepare a pending request for later processing. Waiting is relevant when a request is blocked by a freeze area; refreshing is useful after stale prices or a requote. The design aims to make error behavior configurable and avoid repeatedly sending requests that cannot succeed.

The article also addresses event tracking that could miss consecutive events with the same event type. It proposes storing new event descriptions in a collection, exposing access by index and a total count, and clearing that collection during refresh. The reported tester examples include multiple pending-order removals being recorded and an oversized lot request being adjusted after an insufficient-funds message. These examples demonstrate the intended behavior, but the article is a library implementation tutorial rather than a systematic evaluation across brokers or trading conditions.

Key ideas

  • Classify trade-request errors by whether trading should stop, parameters can be corrected, or a retry may succeed.
  • A retry may require waiting for price to leave a freeze area or refreshing stale quote data.
  • A pending request can store the order details and retry timing without blocking inside the trading method.
  • Store event descriptions in a collection so multiple events, including repeated event types, can be retrieved.
  • The tester examples show several removals being tracked and an oversized volume being adjusted after an error.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.