Yes, you can hold both long and short positions of the same trading instrument in a single trading account, which is also known as "hedging" or "locking" positions.
What hedging and locking mean
Hedging means holding a buy and a sell position on the same product at the same time, to offset risk without closing the original position.
Locking is a specific case where the buy and sell volumes are exactly equal — for example 1 lot buy and 1 lot sell on EUR/USD.
Once locked, the combined profit and loss stops moving with the market. A gain on one side is matched by an equal loss on the other, so the net floating result freezes at the level it reached when the lock was created. It stays frozen until you close one of the two positions.
Locking is not the same as closing
Both positions remain open. They continue to use margin and incur swap.
You still need free margin to lock
Opening the offsetting position is a new order and goes through the same margin check as any other. If your free margin is not enough, the order is rejected — even though the result would be a hedged position.
This matters most when your account is already under pressure. If you are close to a margin call, you may not be able to lock a losing position. Locking is not a way to escape a margin call.
What a locked position costs
Spread on each position, paid when you open it and again on the offsetting one
Swap on both positions overnight. Long and short rates differ, so the two charges rarely cancel out and a locked position can lose money slowly
Commission on both, if your account type charges it
Important notes