Skip to content
All library documents

Modifying Open Positions and Pending Orders in MetaTrader 5

Article MQL5 code base

Summary

This document describes a MetaTrader 5 utility for changing stop-loss and take-profit levels on open positions, and changing prices or protective levels on pending orders. Its functions accept filters such as symbol, expert identifier, direction, order type, and whether positions are profitable or losing. Values can be supplied as point-based offsets for position stops or targets, or as direct prices.

The described workflow enumerates positions or pending orders, applies the requested filters, preserves settings that are not being changed, and submits modifications through the platform’s order mechanism. Examples illustrate setting levels for selected positions and modifying individual classes of pending order. The text is a feature and usage description, not a complete code review or trading strategy. It omits detailed mathematical formulas and optimal parameter guidance, and gives no evidence about execution reliability, broker constraints, or behavior under rejected modification requests.

Key ideas

  • Position modifications can be filtered by symbol, expert identifier, direction, and profitability.
  • Position stop-loss and take-profit inputs support point offsets or direct price values.
  • Pending orders can be selected by order class and have their price, stop-loss, or take-profit changed.
  • The procedure aims to preserve unmodified levels when submitting an order change.
  • The description does not provide performance evidence or detailed handling of broker-side constraints.

Tags

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