Two position accounting systems are supported in the MetaTrader5 trading platform: hedging and netting.
With a hedging system, you can have multiple open positions on one and the same trading instrument, including opposite positions. If you have an open position in an instrument and execute a new trade (or a pending order is triggered), a new position will be additionally opened. Your current position does not change. MetaTrader 4 platform supports only the hedging position accounting system.
With a netting system, you can have only one open position on each trading instrument at any given time. Oppositely directed positions on a single symbol are not allowed. If there is an open position in an instrument, placing a trade in the same direction increases the volume of this position. If you already have an open position and place another order in this same instrument in the opposite direction, the volume of the existing position will be reduced. The position will be closed if the new trade volume is equal to the current position volume or reversed if the volume of the opposite trade is greater than the current position.