# MQL5 PositionSelect()

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-5/functions/mql5-positionselect, 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 the open position in a symbol, so that PositionGetDouble(), PositionGetInteger() and PositionGetString() read it.

- Function: `PositionSelect()`
- Interface: MQL5
- Group: Positions
- Status: verified. Source: [mql5.com](https://www.mql5.com/en/docs/trading/positionselect), checked 2026-10-12.

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

Note: On a hedging account, where one symbol can hold several positions, the page says this selects the one with the lowest ticket. It also says the function copies the position's data, so the values read afterwards are as they were at the moment of the call.

## Signature

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

```mql5
bool PositionSelect(
  string symbol
)
```

## Arguments

- `symbol` (type string, required): The name of the financial instrument.

## Return value

- Type: `bool`
- What comes back: True when a position was selected, false when not. On failure 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.

```mql5
void OnStart()
  {
   if(PositionSelect(_Symbol))
      PrintFormat("%s: %.2f lots, profit %.2f",_Symbol,PositionGetDouble(POSITION_VOLUME),PositionGetDouble(POSITION_PROFIT));
   else
      Print("No position in ",_Symbol);
  }
```

## Related MQL5 functions: Positions

- [PositionGetDouble()](https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-positiongetdouble): Returns one floating point property of an open position. It reads the position last selected with PositionGetSymbol() or PositionSelect().
- [PositionGetInteger()](https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-positiongetinteger): Returns one integer or date property of an open position. It reads the position last selected with PositionGetSymbol() or PositionSelect().
- [PositionGetString()](https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-positiongetstring): Returns one text property of an open position. It reads the position last selected with PositionGetSymbol() or PositionSelect().
- [PositionGetSymbol()](https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-positiongetsymbol): Returns the symbol of the open position at a place in the list of positions, and selects that position so its properties can be read.
- [PositionGetTicket()](https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-positiongetticket): Returns the ticket of the open position at an index in the list of positions, and selects that position so its properties can be read.
- [PositionSelectByTicket()](https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-positionselectbyticket): Selects an open position by its ticket, so that PositionGetDouble(), PositionGetInteger() and PositionGetString() read it.
- [PositionsTotal()](https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-positionstotal): Returns how many positions are open on the account.

## More on MetaTrader 5

- [All MetaTrader 5 functions](https://openbrokerapi.com/platforms/metatrader-5/functions): 78 documented here, grouped by what they do.
- [MetaTrader 5 API quickstart](https://openbrokerapi.com/platforms/metatrader-5/quickstart)
- [All MetaTrader 5 error codes](https://openbrokerapi.com/errors/mt5)
- [MetaTrader 5 API page](https://openbrokerapi.com/platforms/metatrader-5): 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: MQL5 PositionSelect(). Broker API Hub, https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-positionselect, 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.
