Skip to content
All library documents

Timed Buy Stop and Sell Stop Orders with OCO Cancellation

Article MQL5 code base

Summary

This expert advisor places Buy Stop and Sell Stop orders at a user-set time of day and removes pending orders at another specified time. If either order triggers, it detects the trade event and cancels the opposite pending order, creating an OCO-style entry setup. Inputs include order volume, distance from current prices, stop loss, take profit, trailing stop, trailing step, scheduling times, and a magic number.

The description cites an example test on GBPUSD at the hourly timeframe, but gives no performance results or detailed entry rationale. It also says positions are closed when the removal time arrives. The approach’s behavior therefore depends on the configured schedule and order distances; the document does not explain how to select these settings or assess risk across market conditions.

Key ideas

  • The advisor schedules Buy Stop and Sell Stop orders using hours and minutes.
  • It cancels the remaining pending order when one order triggers.
  • The user can specify order size, entry distance, stops, and trailing parameters.
  • At the configured removal time, pending orders are removed and open positions are closed.
  • The document mentions a GBPUSD hourly example without reporting its results.

Tags

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