How to Place and Track Pending Limit and Stop Orders in an EA
Summary
This tutorial explains four pending-order types used in an Expert Advisor: buy limit and sell limit orders placed away from the current price for a potential reversal, and buy stop and sell stop orders placed beyond the current price for a potential move through a level. It outlines how order type and a specified distance determine the entry price, and shows how stop-loss and take-profit levels are set relative to that entry. The examples use MetaTrader 4 order functions and constants.
The accompanying EA illustrates placing all four order types during a configured server-hour window. A helper counts existing orders by symbol, magic number, and type so the EA can avoid placing another of the same type; another function adjusts lot size to the symbol’s permitted range and step. This is implementation guidance, not a trading strategy evaluation: it gives no entry rationale, testing evidence, or performance results. The examples also depend on broker and platform conventions, so operational details require validation in the intended environment.
Key ideas
- A buy limit and sell limit are placed below and above the current market price, respectively.
- A buy stop and sell stop are placed above and below the market price, respectively.
- Entry distance determines the pending order price, with stop-loss and take-profit levels set around that entry.
- The example EA restricts trading to configured hours and tracks existing orders by symbol, magic number, and type.
- The tutorial explains order implementation but provides no evidence about strategy profitability.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.