Skip to content
All library documents

Building Condition-Triggered Pending Trade Requests in MQL5

Article MQL5 articles

Summary

This installment extends an MQL5 trading library so pending requests can wait for user-defined conditions before sending orders. Conditions are stored with their source, property, comparison rule, reference value, and current value. A manager checks them on a timer and submits a request once all configured criteria are met. Conditions may use account properties, symbol properties, or account events, and can be combined.

The example focuses on opening positions based on price and elapsed time, separately or together. In the strategy-tester demonstration, Buy requests wait for price and time conditions, while a Sell request waits for a specified number of bars; the journal shows requests activating and being removed after activation or execution. The article describes library architecture and an implementation path rather than testing trading performance. Its examples use simulated conditions and do not establish that the resulting trades are profitable. The installment is part of a continuing series, with conditional pending-order placement left for a later article.

Key ideas

  • Pending requests can store activation conditions for account, symbol, and trading-event data.
  • A manager periodically evaluates the configured criteria and sends the order when they are satisfied.
  • Conditions may be combined, such as a price threshold and a time delay.
  • The tester example demonstrates request activation and execution, not a profitable trading strategy.

Tags

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