Closing Part of a Position: How close_percent Works
By the TradeAon team · Published · Updated · 7 min read
"Take half off at the first target" is one of the most common rules in discretionary trading and one of the more awkward things to automate, because the alert firing the instruction usually has no idea what size the position actually is. A percentage solves that — the size is worked out on the terminal, where it is known. This page covers what the percentage is measured against, why your broker's lot step has the final word, and one side effect of partial closing that is worth knowing before you build a strategy around it.
- Two ways to close part of a position: an explicit
volumein lots, orclose_percent. If both are sent, volume wins. - The percentage is measured against the volume open at the moment the instruction arrives — so two 50% closes leave 25%, not nothing.
- The result is rounded down to your broker's lot step, then raised to the broker's minimum lot if it lands below it.
close_percent: 100is handled as a full close rather than as arithmetic, so it never leaves a fractional remainder behind.- MT5 clears the comment on the surviving position after a partial close — which is exactly why positions are tracked by ticket instead.
Two ways to close less than everything
A CLOSE instruction with no size closes the whole position. To close part of it, you either state the size directly or state a proportion:
{"action": "CLOSE", "symbol": "XAUUSD", "volume": 0.05} exactly 0.05 lots
{"action": "CLOSE", "symbol": "XAUUSD", "close_percent": 50} half of whatever is open
The difference is where the knowledge lives. An explicit volume requires the alert to know the position size, which is fine when your strategy always opens the same size and awkward the moment sizing becomes dynamic. A percentage moves the arithmetic to the terminal, which is the only place that knows what is actually open right now.
If both fields are present, the explicit volume wins and the percentage is ignored. That precedence is deliberate: an exact number is a more specific instruction than a proportion, and silently overriding it with a computed value would be the wrong kind of helpful. The percentage only takes effect when no explicit volume was supplied.
A percentage of what, exactly
The base is the volume open at that moment, matched by the same targeting rules the close itself uses, in order of precision:
| What the instruction carries | The percentage applies to |
|---|---|
A ticket | That one position's volume |
| A comment reference | The total across positions carrying it |
Only a symbol | The total open volume on that symbol |
The consequence that trips people up is compounding. The base is recalculated every time, so repeated partial closes shrink geometrically rather than linearly:
open 1.00 lot close_percent 50 -> closes 0.50 remaining 0.50 close_percent 50 -> closes 0.25 remaining 0.25 close_percent 50 -> closes 0.125 remaining 0.125
That is usually what a scale-out rule means, and it is worth checking against what your strategy intends. If the rule is "take a third off at each of three targets", three instructions of 33% leave about 30% behind, not zero — because the second and third are thirds of a smaller position each time. Closing thirds by proportion of the original means sending 33%, then 50%, then 100%.
If the target does not resolve to any open position, nothing is closed and the instruction is reported as a failure naming that reason — rather than being quietly treated as a no-op, which would leave you believing you had scaled out when you had not.
Your broker's lot step has the last word
Percentages produce awkward numbers, and brokers do not accept awkward numbers. Every volume must be a multiple of that symbol's lot step and at least its minimum lot, so the computed figure is normalised before it is sent. Two rules apply, and both can move the result away from the exact percentage you asked for.
It rounds down. Aligning to the step always floors, never rounds to nearest, for the same reason it does when opening: rounding up closes more of the position than the instruction asked for, and that is a change to your exposure that you did not request. Flooring can only ever leave you with more position than intended, which is the recoverable direction — another instruction can always close the rest.
33% of 0.10 lot = 0.033 step 0.01 -> closes 0.03 (not 0.04) 50% of 0.03 lot = 0.015 step 0.01 -> closes 0.01 (not 0.02)
Then it raises to the minimum. If the floored result lands below the symbol's minimum lot, it is lifted to that minimum, because a volume below the minimum is not an order the broker will accept at all. This is the case worth knowing in advance: on a symbol with a 0.01 minimum, asking to close 5% of a 0.10-lot position works out to 0.005, which becomes 0.01 — twice the fraction you asked for. The smallest partial close available to you is one minimum lot, whatever percentage you write.
The general rule is the one that runs through every sizing decision in automated trading: you propose a size and the broker's contract specification disposes. Percentages are a convenience for expressing intent, not a guarantee of precision, and the finer your position size the coarser the percentage becomes in practice.
Why 100% is a special case
You might expect close_percent: 100 to be the same arithmetic with a factor of one. It is handled separately, and the reason is floating-point arithmetic.
Computing 100% of a position and then normalising it invites a rounding error at the last decimal to leave a sliver behind — a position of 0.00001 lots that the terminal still considers open. That sliver is worse than useless: it keeps the position in every list, it may not be closable by a subsequent instruction that also rounds, and it makes the account disagree with the records for reasons nobody can see.
So 100% skips the arithmetic entirely and takes the ordinary full-close path — the same one an instruction with no size at all would take. The lesson is a general one about interfaces that accept proportions: the boundary values usually need their own branch, because "the whole thing" and "a very large fraction of the thing" are different instructions even when the number suggests otherwise.
The side effect: MT5 wipes the comment
Partial closing has a consequence in MT5 that has nothing to do with trading logic and everything to do with how the platform records the operation. When a position is partially closed, the surviving position can be left with an empty comment.
That sounds trivial. It is not, if anything downstream identifies positions by their comment — which is the obvious way to link a copied position back to the master position it mirrors. Once the comment is gone, the remainder becomes invisible to every mechanism that looks for it: the comment scan misses it, the position-sync filter skips it, and even the reconciliation process that exists to catch problems cannot see it. One partial close and the position is orphaned in the records while remaining perfectly real at the broker.
This is the reason positions are keyed on broker ticket instead, with the comment kept only as a fallback. A ticket is assigned by the broker, is unique, and cannot be erased by a later operation. The reconciliation guide covers the identity question in more depth, but the short version is worth stating on its own: if you are building anything that tracks positions, do not build it on a field the platform is allowed to clear.
Choosing between volume and percent
Neither is better in general; they suit different strategies.
- Use an explicit volume when your position sizes are fixed and known to the alert, or when a specific residual size matters to you — for example a runner you always want to be exactly 0.01 lots.
- Use a percentage when sizing is dynamic, when the same alert template serves accounts of different sizes, or when the rule is genuinely proportional ("take half off").
- Use a percentage for copy relationships, where the follower's size may legitimately differ from the master's. An explicit volume from a master account may not even be a valid size on the follower's.
Whichever you choose, confirm the first one on a demo account and read the resulting position size rather than assuming it. Between the step rounding and the minimum-lot floor, the difference between what you asked for and what happened is small, entirely predictable once you know the symbol's specification — and completely invisible until you look.