Skip to content
All library documents

Manual Chart Triggers for Placing Orders in an MQL5 Expert Advisor

Article MQL5 articles

Summary

This article explains a teaching example that uses chart mouse and keyboard events to place pending orders or open market positions from an MQL5 Expert Advisor. A class tracks mouse position and button state, displays the cursor price with a horizontal line, and exposes read-only status to the rest of the program. Event handling then interprets clicks and key combinations as order instructions.

The example illustrates how a manual trigger can initiate an order, after which the broker-side pending order and its limits govern what happens without further trader input. The article also describes chart-object creation and deletion notifications and stresses that triggers can fail. It warns that fast price moves may cause a position to remain open beyond an expected limit, and that the demonstration EA can malfunction or loop. It is presented for learning and demo-account use, not as evidence of a tested trading strategy.

Key ideas

  • Chart events can translate mouse position and keyboard state into manual order instructions.
  • A horizontal chart line can display the price under the cursor for order placement.
  • Encapsulating event state and exposing it through read-only methods limits accidental changes from outside the class.
  • Manual actions place orders, while subsequent pending-order activation and position management proceed automatically.
  • Triggers can fail, and volatile price jumps can leave a position exposed longer than expected.

Tags

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