Skip to content
All library documents

Event-Driven, Modular Design for Trading Robots

Article MQL5 articles

Summary

This article presents a software design approach for trading robots built around servicing current conditions. Instead of tracking the full history of how an order or position arose, the robot checks its present state on each tick and acts on that state. For example, a pending-order cancellation can remain a recorded task that is retried on a later tick, rather than trapping the expert in a potentially unbounded retry loop.

The design also advocates abstracting functions from buy or sell direction and symbol where possible, and separating operations such as opening, trailing, and closing into independent modules. It distinguishes indicator events, changes in positions or orders, and external events such as chart interactions or trading errors. A base expert-advisor structure organizes these modules before they inspect their relevant signals, which the author argues makes extensions easier. The piece offers architectural examples, not comparative performance evidence, and these principles still need to be matched to a strategy’s specific requirements.

Key ideas

  • A trading robot can make decisions from current order, position, and environment state without reconstructing how that state arose.
  • Recording a pending cancellation for later ticks avoids blocking the expert in a retry loop.
  • Abstracting away direction and symbol can make trading functions more reusable.
  • Separating opening, trailing, and closing logic into modules makes the robot easier to extend.
  • Indicator, trade-state, and external events provide distinct sources of signals for the expert.

Tags

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