# MQL4 OrderSelect()

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderselect, written from the same records as that page.

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

Selects one order, by its place in a list or by its ticket, so that the functions which read an order's properties read that one.

- Function: `OrderSelect()`
- Interface: MQL4
- Group: Finding orders
- Status: verified. Source: [docs.mql4.com](https://docs.mql4.com/trading/orderselect), checked 2026-10-12.

This is an MQL4 function, not an HTTP endpoint. It has no method, no path and no address to send a request to: it runs inside the MetaTrader 4 terminal, in a program written in MQL4. It is in no OpenAPI file on this site and the request builder does not list it.

Note: The page says the pool argument is ignored when selecting by ticket, and that an order's close time tells which list it came from: 0 means it is open or pending. Open trades, pending orders and history are all reached through this one function, which is why it is listed under three tasks.

## Signature

The form of the call on the vendor's page, with the vendor's comments taken out.

```mql4
bool OrderSelect(
  int index,
  int select,
  int pool=MODE_TRADES
)
```

## Arguments

- `index` (type int, required): The order's index or its ticket, depending on the second argument. The page's own parameter list calls this argument ticket.
- `select` (type int, required): How the first argument is read: SELECT_BY_POS for an index in the order pool, SELECT_BY_TICKET for a ticket.
- `pool` (type int, optional): Which pool to index into when selecting by position: MODE_TRADES for open and pending orders, MODE_HISTORY for closed and cancelled ones. Default: MODE_TRADES.

## Return value

- Type: `bool`
- What comes back: True when the order was selected, false otherwise. The page points to GetLastError() for the reason.

## Sample

Written by this site from the signature and arguments recorded on this page. It has not been run against a terminal, a server or an account, and the values in it are placeholders. It holds no credential and needs none: the program runs inside a terminal that is already logged in to an account. Nothing is entered on this site.

```mql4
void OnStart()
  {
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         PrintFormat("#%d %s %.2f lots",OrderTicket(),OrderSymbol(),OrderLots());
     }
  }
```

## Related MQL4 functions: Finding orders

- [OrdersHistoryTotal()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordershistorytotal): Returns how many closed orders are in the account history the terminal has loaded.
- [OrdersTotal()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderstotal): Returns how many market and pending orders the account has.

## More on MetaTrader 4

- [All MetaTrader 4 functions](https://openbrokerapi.com/platforms/metatrader-4/functions): 28 documented here, grouped by what they do.
- [Open positions: the call at each API](https://openbrokerapi.com/endpoints/positions): The same job at every broker and platform API recorded here, HTTP or not.
- [List open orders: the call at each API](https://openbrokerapi.com/endpoints/open-orders): The same job at every broker and platform API recorded here, HTTP or not.
- [Trade history: the call at each API](https://openbrokerapi.com/endpoints/history): The same job at every broker and platform API recorded here, HTTP or not.
- [All MetaTrader 4 error codes](https://openbrokerapi.com/errors/mt4)
- [MetaTrader 4 API page](https://openbrokerapi.com/platforms/metatrader-4): The full record: access, authentication, limits and the source for each.

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: MQL4 OrderSelect(). Broker API Hub, https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderselect, newest check 2026-10-12.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
