Partial fills are rare on retail FX accounts, but they do happen, mostly with larger limit orders or on less liquid symbols. My EA didn't handle them, and I found out when a 2 lot limit on gold filled 1.4 lots and the EA treated the position as complete.
What I changed:
In OnTradeTransaction, I check the deal volume against the order's requested volume, not just whether a deal happened.
If the order is still active with remaining volume, the EA waits up to a set time, then cancels the rest.
Stop and target are sized for the actual position volume, not the requested one. That matters for any logic that closes part of a position.
The CSV log records requested and filled volume separately.
The tricky bit is that the order state and the position state update in separate transactions, sometimes a few milliseconds apart. Code that reads PositionGetDouble(POSITION_VOLUME) right after the first transaction can see the old value.
On netting accounts it's even messier, since a partial fill gets merged into an existing position.
Has anyone else had to deal with this? I'd like to know if some brokers partially fill market orders too, or only limits.
On an exchange, orders are matched by price and time priority. The first order at a price is filled first. People assume forex works the same way, and plan around it, for instance by placing limit orders early to be at the front of the queue.
Retail forex has no such queue. An order sent to a broker isn't placed in a central book. The broker decides how to handle it: internalize it against its own book, pass it to a liquidity provider, or route it elsewhere. Priority is whatever the broker's system gives.
A limit order sitting at a level may be filled when price touches it, or may need to trade through it by a tick. Different brokers use different rules. Some fill at touch, others require the market to trade through the level.
Evidence of this shows up when a limit order isn't filled although the chart shows price touching the exact level. The chart displays bid quotes, and the fill requires ask, or the broker's own rule about "touch vs. through".
For scalpers who plan on resting orders at precise levels, testing the fill rule with small orders is a smart first step.
What did the broker say when a limit order missed a fill at a level that price clearly touched?