How a trading bot protects a position
Updated:
When people ask how a trading bot protects a position, the answer has several layers: protective orders on the exchange itself, checks before entry, recovery after failures and limits on risk. No single layer guarantees anything, but together they reduce the chance of the worst scenarios. Below, in order, is what Snapback does.
1. Before entry: size and leverage
Before placing an order, the service calculates the trade plan: entry price, size, stop and take-profits. All rounding goes in the direction that is worse for you, so the real trade can be better than the plan but not worse: the stop triggers no later than planned, and a take profit does not take more than planned.
Leverage is checked too. If liquidation would come before the stop, the trade is not opened. Details in Binance futures leverage and liquidation.
Extra checks run before every order: whether the bot is switched off, whether there is already a position on this coin, whether the pause after the previous trade has ended, whether "Max simultaneous positions" and "Max total margin" are exceeded. The "Daily loss limit" is checked as well.
2. Entry
The bot places a limit sell order. By default it is a "maker only" (post-only) order: if it would fill immediately at the market, the exchange rejects it, so the fee matches the calculation. The order waits for the set time ("Wait for the fill, seconds"). If it does not fill, it is cancelled and there is no trade: in the list it shows as "cancelled", with the reason "cancelled on timeout".
3. Right after the fill: stop and take-profits
When the entry order fills (even partly), the bot places protection as one set.
- Stop loss. A conditional order that closes the whole position (closePosition) and triggers on the mark price. Because it closes "everything that is there", it does not need recalculating after a partial entry fill or after take-profits.
- Take-profits. Each take profit is a conditional order for its share of the size. The last share closes the entire remainder. If the entry filled partly, the take-profit shares are recalculated proportionally.
- If the exchange rejected one take profit and the price has already passed its level, the bot immediately closes that share at market, so the position is not left with a target the price will no longer reach. The stop and the other take-profits are not affected.
4. During the trade
- When a take profit fills, the bot records it and, if "Breakeven" is on, moves the stop: how a breakeven stop loss works. The move is a cancel of the old stop and a new one placed, so for a moment there is no stop.
- When the last take profit or the stop fills, the bot cancels the remaining orders on the coin. Futures have no automatic "one filled, the other cancelled" link, so the bot cleans up the leftovers itself.
- Every event (order, take profit, breakeven, close) sends a Telegram message, if Telegram is connected: how to connect Telegram.
5. If protection could not be placed
This is the most dangerous moment: the position is already open and there is no protection. The bot does not wait for a person to notice. It cancels its orders and closes the position at market. The reason is recorded as "closed at market - could not protect" (internal name protection_failed). The result of such a trade can be negative, zero or even positive, but the goal here is not profit; it is not leaving an open short without a stop.
6. Recovery after failures
The service is a separate process that can restart, and the connection to the exchange can drop. So it does not rely on its own memory.
- On every start, for each position recorded as open, the service asks the exchange what the real state is. If the position is already closed, the trade is written up as closed, with the actual exit price, fees and funding taken from the exchange's history. If it is still open, the bot picks it up and places protection if there is none. If protection can no longer be placed (for example, the price is already beyond where the stop should sit), the position is closed at market.
- On every reconnection of the exchange event stream, the same check is repeated for your account: an event that happened between the drop and the new connection could be lost, and the position would stay unprotected until the next restart. Positions the bot is already managing are left alone, so it does not forget which take-profits have already filled.
- A position with no record. If a position is found on the exchange that the service knows nothing about, it appears on the Trades page in the "Unassigned positions" block, marked with whether there is a stop. There you can attach it to a bot with the "Assign" button.
- A missed closing event. If the closing event was lost, the service rebuilds the trade from the exchange's history, so the list shows a real exit price and the correct reason rather than an empty row.
7. Risk limits
- "Max simultaneous positions" and "Max total margin, % of deposit" limit how many trades and how much margin are open at once.
- "Pause per coin, min" stops a new trade on the same coin right after the previous one.
- "Daily loss limit, %": the service counts the realized result for the day (UTC) including fees and funding. If the loss reaches the set share of the deposit, the bots are switched off and orders waiting for entry are cancelled. The Bots page has a "Reset the counter and start the bots" button, so the decision to resume trading stays with you. The unrealized loss on open positions is not part of this limit.
- There is also a service-level emergency switch that forbids new trades or closes all positions.
The limits of protection
An honest note on what this protection does not solve.
- It does not guarantee the exit price: the stop and take-profits trigger at the market.
- It does not work if the exchange itself is unavailable or your key has been revoked or restricted.
- A switched-on bot does nothing if the market scanner is not running: the Bots page then shows a warning. Protective orders already on the exchange keep working even without the service.
- It does not change the risk of the strategy: a short against a pump can lose, and in series.
How to read the result of a trade that has already closed is described in the Trades page and exit reasons.
Frequently asked questions
What happens if the bot cannot place a stop loss?
The bot does not hold a position without protection: it cancels its orders and closes the position at market. In the trade list that trade has the reason "closed at market - could not protect".
What happens to an open trade if the service restarts?
On every start, and after the connection to the exchange is restored, the service re-checks its records against the real state on Binance: it picks up open positions, places protection if there is none, or closes the position if protection can no longer be placed.
Does protection guarantee the loss will not exceed the stop?
No. A stop triggers at the market, and in a sharp move the fill can be worse. Protection reduces risk; it does not remove it.
Can all bots be stopped after a big loss?
There is a daily loss limit: when the realized loss for the day reaches the set share of the deposit, the service switches the bots off. After that you have to start them again by hand.