MT4 error 140: Long positions only allowed (ERR_LONG_POSITIONS_ONLY_ALLOWED)
The broker allows only buy orders on this symbol right now. Your sell order was refused, and nothing was executed.
What it means
You see this code in GetLastError() in MQL4, after a trade function fails on the server side.
The broker allows only buy orders on this symbol. Opening a sell is refused with 140.
It is a rule the broker sets for the symbol, not a setting in your terminal. Compare error 4111, which comes from your program's own settings.
Common causes
- A symbol that can't be sold short.
- Some stock CFDs, which brokers sometimes limit to buys.
- A temporary broker rule.
How to fix it
- Treat 140 as a rule of the symbol, not a passing error, and don't retry the sell in a loop.
- Skip sell signals on this symbol while the rule applies.
- Ask the broker how long it will last.
Example in MQL4:
int ticket = OrderSend(Symbol(), OP_SELL, 0.10, Bid, 3, 0, 0, "", 4711);
if(ticket < 0 && GetLastError() == ERR_LONG_POSITIONS_ONLY_ALLOWED)
Print(Symbol(), ": only buys are allowed, sell signal skipped"); Is it safe to retry?
Not as a sell, while the broker allows only buys on this symbol.
Could the order have executed?
No. The sell was refused.
How Tickwire handles it
Tickwire treats it like MT5 10042, and the MT4 code stays in the message. See trade results.
Related codes
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.