BullsEdges algo trading guide: MT5 accounts come in two modes: hedging and netting. The mode changes how positions work and can break EAs written for the other. Here is the difference.
MetaTrader 5 supports two ways of recording positions. Most retail forex accounts use one, exchange-traded markets use the other, and an Expert Advisor written for one can misbehave badly on the other.
BullsEdges algo trading application: Confirm hedging or netting mode before deployment, especially when several positions or strategies share the same symbol.
Netting mode
There is one position per symbol. Every new order changes that position:
- Buy 1.0 lot, then buy 0.5: one position of 1.5 lots at an averaged price.
- Buy 1.0, then sell 0.4: one position of 0.6 lots long.
- Buy 1.0, then sell 1.5: one position of 0.5 lots short.
This is how stock and futures exchanges work.
Hedging mode
Every order opens a separate position with its own ticket, stop loss and take profit. You can hold a buy and a sell on the same symbol at the same time. This is how MetaTrader 4 always worked, and it is the default on most MT5 forex accounts.
Why it matters for EAs
- Grid and basket strategies rely on separate positions per level, each with its own entry price. They need hedging mode.
- Straddles (a buy stop and a sell stop) can briefly leave both legs filled in a spike. In hedging mode the EA sees two positions and can close one. In netting mode they cancel out.
- Stop loss and take profit in netting mode apply to the whole position, not to individual entries.
- Position counting: an EA that counts positions to decide its next lot size will count very differently in each mode.
How to check your account
In MT5, the account type is shown in the Navigator under the account, or in the account's properties. MQL5 code can read it with AccountInfoInteger(ACCOUNT_MARGIN_MODE). A well-written EA checks the mode on start-up and refuses to run if it is wrong.
Margin differences
In hedging mode, brokers often charge reduced or no margin for the hedged part when you hold equal buy and sell positions. This can unexpectedly allow larger positions on a small account - and it disappears the moment one side is closed.
Choosing a mode
- Forex and gold algo trading with grids, baskets or multiple independent strategies on one symbol: hedging.
- Futures, stocks, or strategies that think in terms of one net position: netting.
You usually choose the mode when opening the account; it cannot be changed later.
BullsEdges takeaway for algo trading
Know your account mode before installing an EA, and make sure it matches what the EA was designed and tested for. A grid EA on a netting account, or a netting-style EA on a hedging account, will not behave like the backtest.
Trading forex and gold carries a high level of risk and may not be suitable for every investor. Past performance and backtests do not guarantee future results. This article is education, not financial advice.
