Skip to content
All library documents

Scheduling Market-Closed Orders with Virtual Stops and Trailing Stops

Article MQL5 code base

Summary

This script description explains how to prepare a buy or sell order while a market is closed and submit it when trading resumes. Users can set the direction, order size, stop parameters, and an optional start time, so an order may be delayed until a chosen time after the open. Once placed, the script monitors the position and can maintain a trailing stop if that feature is enabled.

It also describes virtual stop-loss and take-profit handling: when requested stop levels fall outside the broker’s permitted range, the script tracks those levels itself and closes the position when they are reached. If a price gap occurs when the script is attached, it attempts to enter at the first available price. These are execution and order-management behaviors, not a trading signal or evidence of an edge. The description gives no testing results and does not establish how slippage, gaps, or platform interruptions affect outcomes.

Key ideas

  • The script can submit a configured buy or sell order when the market opens or at a specified later time.
  • Order size and stop settings are defined before submission, and an enabled trailing stop can manage the open position.
  • Virtual stops let the script enforce stop-loss or take-profit levels that the broker will not accept directly.
  • After a gap, the script attempts to enter at the first available price, with no performance evidence provided.

Tags

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