Market Orders vs Pending Orders in an MT5 API
A market order trades now; a pending order waits at the broker for your price. How each behaves in an MT5 API, with one example and a comparison table.
In short
- A market order executes now, at the price available. Its result is a fill — or a rejection.
- A pending order waits at the broker until the price reaches a level you set. Its result is a working order, not a position.
- A limit waits for a better price; a stop waits for the price to break through. Buy limits sit below the market, buy stops above it.
- Placing a pending order and having it fill are separate events. Treat working and filled as different states in your code.
On this page
Every trade in MetaTrader 5 starts as one of two kinds of order. A market order says "now". A pending order says "when the price gets here". They return different results, and code that treats them the same eventually tells someone they are in a trade they are not.
One scenario
EUR/USD is trading at 1.1000. You want to buy.
- Buy now. Send a market order. It fills at about 1.1000 — the price available when it reaches the broker.
- Buy if it dips to 1.0950. Send a pending buy limit at 1.0950. It waits at the broker and fills only if the price falls there.
- Buy if it breaks above 1.1050. Send a pending buy stop at 1.1050. It waits and fills only if the price rises there.
Side by side
| Aspect | Market order | Pending order |
|---|---|---|
| When it executes | Immediately | When the price reaches your level |
| The price | The market's, now | Your level (a stop can slip past it in a fast market) |
| Result of placing it | filled — a position exists | working — no position yet |
| Can be cancelled | No — close the position instead | Yes, until it triggers |
| Where it waits | Nowhere; it executes | At the broker's trade server |
| fxapis endpoint | POST /v1/accounts/{id}/orders/market | POST /v1/accounts/{id}/orders/pending |
The three pending kinds
| Kind | A buy waits | A sell waits | Use it to |
|---|---|---|---|
limit | Below the market | Above the market | Get a better price |
stop | Above the market | Below the market | Trade a breakout |
stop_limit | A stop triggers, then places a limit | The same | Trade a breakout with a price cap |
The side is the usual mistake: a buy limit above the market is not a limit. fxapis refuses the wrong side before anything is sent, with a message naming the order you probably meant.
In the API
A market order needs no price:
curl -X POST https://api.fxapis.com/v1/accounts/$ACCOUNT_ID/orders/market \
-H "Authorization: Bearer $FXAPIS_KEY" -H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "symbol": "EURUSD", "side": "buy", "volume": "0.10" }'
A pending order names its kind and its price:
curl -X POST https://api.fxapis.com/v1/accounts/$ACCOUNT_ID/orders/pending \
-H "Authorization: Bearer $FXAPIS_KEY" -H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "symbol": "EURUSD", "side": "buy", "kind": "limit", "volume": "0.10", "price": "1.0950" }'
Both take a stop loss and take profit as absolute prices, and both should carry an idempotency key.
Working is not filled
A placed pending order comes back working. That means it is waiting at the broker — no position exists. Some brokers answer a pending placement with the same return code as a fill; fxapis reads it as working, not filled, so your code does not report a trade that has not happened.
When it triggers, a position appears in GET /v1/accounts/{id}/positions. To call it off first, POST /v1/orders/{id}/cancel. If it has already triggered, the cancel is refused — there is a position now, and what you want is a close.
Which to use
- Signals and copy trading usually want market orders: the point is to act on the signal now, on every account.
- Entries at a level — a pullback, a breakout — want pending orders, which wait at the broker even while your own systems are offline.
Pending orders are included on fxapis's Starter, Scale and Enterprise plans; Free has market orders only. See pricing.
Next steps
- Pending orders in the trading guide — every kind, states and cancelling.
- Why an MT5 trade can fail — what a rejection tells you.