Skip to content
All library documents

Virtual Stop Management and Spread Filtering for Trade Exits

Article MQL5 code base

Summary

The document describes a trade-management utility for positions opened manually or by another automated strategy. It keeps stop-loss and take-profit thresholds on the local terminal rather than placing them with the broker, then submits a market close when a virtual threshold is reached. The stated motivation is to conceal exit levels from broker-side visibility and reduce exposure to stop triggers during sharp price movements.

A spread filter can delay a virtual stop-loss close when the spread exceeds a configured maximum, with the aim of avoiding exits during temporary spread widening around news or server rollover. Users set virtual stop and target distances, the maximum spread allowed for stop execution, and a magic number to select manual trades or positions from a particular strategy. This design depends on the terminal and manager operating correctly; delaying an exit while spreads remain wide can also leave a position exposed to further losses. The document provides no performance tests or evidence that hidden levels prevent stop hunting.

Key ideas

  • The utility manages existing positions and does not open trades.
  • Stop-loss and take-profit thresholds are monitored locally rather than exposed as broker orders.
  • A maximum-spread condition can postpone stop-loss execution during spread widening.
  • The manager can target manual positions or positions identified by a strategy's magic number.
  • Local monitoring and delayed execution create operational and market-risk limitations.

Tags

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