# MetaTrader 4 trade server return code: 140 ERR_LONG_POSITIONS_ONLY_ALLOWED

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/errors/mt4/140, 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.

The error, as text you can copy:

```
140 ERR_LONG_POSITIONS_ONLY_ALLOWED
```

- Kind: Trade server return code
- Where you meet it: Returned by the trade server to the platform
- API: [MetaTrader 4 (MQL4)](https://openbrokerapi.com/platforms/metatrader-4)
- Status: verified. Source: [docs.mql4.com](https://docs.mql4.com/constants/errorswarnings/enum_trade_return_codes), checked 2026-10-09.

## What does 140 ERR_LONG_POSITIONS_ONLY_ALLOWED mean on the MetaTrader 4 API?

Only buy orders are allowed. It is a MetaTrader 4 trade server return code, returned by GetLastError() in MQL4.

## No fix in the source

The vendor's page gives no remedy. It lists the code with a one line description and nothing more.

That is all the source says, so this page does not invent a fix. General guidance: [the other trade server return codes recorded for MetaTrader 4](https://openbrokerapi.com/errors/mt4#platform-return-code), the [error lookup](https://openbrokerapi.com/tools/error-lookup) for the exact text of the reply you received.

## More on the MetaTrader 4 API

- [All MetaTrader 4 API error codes](https://openbrokerapi.com/errors/mt4)
- [MetaTrader 4 API error codes](https://openbrokerapi.com/errors/mt4): 161 decoded, each with what it means, and the fix where the source gives one.
- [MetaTrader 4 functions](https://openbrokerapi.com/platforms/metatrader-4/functions): 28 documented, each with its signature, arguments, return value and source.
- [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: MetaTrader 4 trade server return code: 140 ERR_LONG_POSITIONS_ONLY_ALLOWED. Broker API Hub, https://openbrokerapi.com/errors/mt4/140, newest check 2026-10-09.

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.
