Protection, re-plans and exits
After an entry is placed, Wallbot keeps reacting to the order book. It re-plans a pending entry when the walls change, re-anchors an open trade when its wall goes, takes profit in front of the counter wall, trails the stop, and moves the stop to breakeven when no wall protects the trade any more.
What "protected" means
A wall only helps a trade if price has to get through it before reaching the stop. With protection_by_wall_between on (default), a position counts as protected only if a confirmed wall on its own side starts between the current price and the stop:
- a long: a support wall whose low edge is above the stop and below the price;
- a short: a resistance wall whose high edge is below the stop and above the price.
A wall behind the stop protects nothing. Price would hit the stop first. Walls on the other side never count as protection either: bids under a short or asks over a long are counter walls, the take-profit targets. The trade card shows "Protected by wall lo–hi" or "Not protected by a wall · stop only / stop at breakeven".
This definition drives the breakeven rule further down. A protected position keeps its stop behind the wall. A position that is not protected, and is far enough in profit, has its stop moved to breakeven.
Re-plans of a pending entry
While an entry is still resting, the walls around it can change. Wallbot re-plans when a closer wall appears, after the front wall is pulled, and when its stack loses a wall. With nearest_side_priority on it can also switch to the other side. A re-plan always runs the full planning logic again: a rebuilt stack, a new entry, stop and leverage, and every entry check. For a closer wall the old order is only replaced if the new plan passes; when the stack lost a wall, the old order is cancelled unless the new plan is the same.
A closer wall appears
With replan_on_closer_wall on (default), a new confirmed wall on the entry's own side that sits between price and the pending entry triggers a re-plan. For a long that means a higher bid wall below price. For a short it means a lower ask wall above price. The new wall must be confirmed and must become the new nearest wall. The old entry is cancelled, and the new one placed, only after the new plan passed. If the old entry filled in the meantime, the fill wins and no new entry is placed.
The log and a trade-update notification say "Re-planned (a closer confirmed wall appeared): entry ... -> ..., stop ... -> ..., leverage ...x -> ...x". If the closer wall is not used, log_replan_reasons logs why, for example "SHORT XRPUSDT: closer wall 0.5412-0.5415 not used: reward/risk 0.80 below 1; keeping the pending entry at 0.5409".
Limits on closer-wall re-plans
- At most one closer-wall re-plan per coin and side within
replan_min_interval_s(30 s). - With
replan_recheck_after_limiton (default), a closer wall that confirms inside that limit is checked again when the limit runs out, instead of being ignored until another wall confirms. - If the new plan needs a different leverage, the leverage is set only after the old entry's cancel is confirmed (Leverage is held).
After the front wall is pulled
When the wall in front of a pending entry is pulled or fades, the entry is always cancelled. With replan_after_front_pull on (default) and other confirmed walls still on that side, the bot waits replan_cooldown_s (60 s). Then it tries one new entry on the nearest remaining confirmed wall. A wall that reappears during the wait is a new wall and must confirm again. The log reads "Front wall pulled; 1 confirmed wall(s) remain: re-planning in 60 s". With the setting off, the normal entry logic may place a new entry on the remaining walls right away.
When the stack loses a wall
With replan_on_stack_loss on (default, wall hug only), a pending entry on a stack of several walls is planned again at once when one of its walls fades, is pulled, absorbed or broken before the fill. The same happens when the front wall is absorbed or broken; a pulled or faded front wall keeps the wait above.
- The new plan uses the remaining walls with the normal planner: entry in front of the nearest, stop behind the farthest, the highest leverage that keeps liquidation behind that stop, and every entry check.
- If the plan is unchanged, the order stays.
- Otherwise the old entry is cancelled and the cancel confirmed, then the new leverage is set, then the new entry placed ("RE-PLAN" notification). If the old entry filled meanwhile, the fill wins.
- If the new plan fails a check, the entry is cancelled and nothing new is placed ("RE-PLAN FAILED ... entry cancelled").
Switching to the closer side
Without both sides, a pending entry on one side of a coin blocks a setup on the other side. With nearest_side_priority on (off by default, wall hug only), a setup on the other side that passes every entry check takes over when its entry is at least side_switch_closer_pct (30%) closer to the price than the pending one:
- the pending entry is cancelled and the cancel confirmed, then the leverage is set and the closer entry placed ("SIDE SWITCH coin: long -> short");
- never when the pending entry is within
side_switch_min_dist_pct(0.1%) of the price, as it is about to fill; - at most one switch per coin per
side_switch_cooldown_s(60 s); - never a filled position. If the old entry filled during the cancel, nothing new is placed.
If the new entry cannot be placed after the cancel, "SIDE SWITCH FAILED" is sent and the old entry is not re-placed automatically.
When the anchor wall goes after the fill
An open trade is tied to its anchor wall. What happens when that wall ends depends on how it ended (see What happens to a wall).
Pulled
pulled_wall_exit decides:
unless_protected(default). The bot looks for a backup: another confirmed wall on the same side whose far edge is still in front of the stop. If there is one, the trade re-anchors to the nearest such wall and keeps its position and stop. The log says "Wall at ... pulled: still protected by the confirmed wall at ... in front of the stop ...; keeping the position (re-anchor #1)". This repeats on every later pull. With no backup, the hold rule below decides between holding and exiting.always. Any pull of the anchor wall exits at market.
The hold rule (hold_unprotected_in_profit, on) applies when no backup wall is left. If the trade is up at least min_net_roe_to_hold_unprotected (5% of margin, after fees), it stays in. Its stop moves to breakeven, unless the trailing stop already locks more. Trailing and the take profit stay active. Below that threshold the trade exits at market: "Wall vanished after entry: exiting at market".
Warning. At high leverage the entry fills well before price reaches the wall, and spoofers tend to pull when price gets close. An exit after a pull can therefore cost a large share of the margin. Watch this number in paper trading.
Absorbed
An absorbed wall was eaten by trades, which is a real fight at that price, not a spoof. With on_absorbed_after_fill = protect (default), the bot never exits because of it:
- With a backup wall in front of the stop, it re-anchors to the nearest one. With
tighten_stop_on_stack_changeon, it also moves the stop behind the farthest remaining backup wall, if that is at least 5 ticks tighter. - With no backup and net ROE at least the hold minimum, the stop moves to breakeven plus fees and slippage, only if that is tighter.
- Otherwise the stop stays where it is.
none only marks the wall as absorbed and takes no action.
Faded or broken
A fade keeps the trade unless exit_on_wall_faded is on, in which case it is handled exactly like a pull. A broken wall needs no action: price went through the wall and the exchange stop does its job.
Stack walls disappearing
With tighten_stop_on_stack_change on (default), when walls of an open trade's stack disappear and the farthest remaining wall is closer to price, the stop moves to that wall's far edge plus stop_beyond_wall_pct. It only moves if that tightens the stop by at least min_stop_tighten_ticks (5). It never loosens a stop, never touches a trailing or breakeven lock, and never changes the leverage.
Counter-wall take profit
With tp_mode = counter_wall (default), the target is the nearest confirmed wall on the other side, in the direction of profit: resistance above a long, support below a short. Only counter walls within wall_max_dist_pct of price are used.
The target
- The take profit sits
tp_ticks(2) ticks in front of the counter wall's near edge, so it fills before the wall stops price. - At planning time the counter wall is only used for the reward/risk check against
min_reward_risk. Tracking starts at the fill, from the book as it is then: "Take profit tracking started: 101.48, before the counter wall at 101.5-101.55". - With no counter wall at the fill, the trade runs on the stop and trailing stop.
Arming
The take profit is tracked locally. The exchange order, a close-only limit order, is only placed when price comes within tp_arm_distance_pct (0.3%). If price jumps past the target before the order is armed, the bot closes at market. If the take profit fills partly, the stop is resized to what is left, and trailing continues on the rest.
When the counter wall changes
- Moves inside its zone. The take profit follows only when the target changes by at least
tp_min_move_ticks(5), to avoid churn. - Pulled, faded, absorbed or broken. An armed order is cancelled. The target moves to the next confirmed counter wall further out, or is removed: "Take profit ... removed (counter wall ... pulled, none further); the trade runs on stop and trailing stop".
- A closer counter wall confirms (
tp_closer_wall, on). A new counter wall between price and the take profit moves the take profit in front of it. The new target must be beyond the fill price and at least the minimum move closer. An armed order is modified in place, or cancelled and re-armed, never placed twice. - No take profit at all (
tp_reacquire, on). A trade without a target, because none existed at the fill, the last one was removed, or the trade was resumed after a restart, picks up the nearest confirmed counter wall as soon as one appears. This is checked on every counter-wall confirmation and every 5 seconds, even while entries are paused. The target must lie beyond both the current price and the fill price. - After a restart (
tp_restart_cleanup, on). A take-profit order left on the exchange from before the restart is cancelled, and a fresh target is picked up from the live book. It is never left untracked or doubled.
Opposite entry after the take profit
When the take profit fills in front of a counter wall, price has just stopped at that wall. With tp_opposite_priority on (the default), that same wall gets priority for an opposite entry for tp_opposite_priority_s (90 s): a short in front of the resistance after a long, a long in front of the support after a short.
- The wall must still be valid at the moment the entry is placed: still confirmed, not traded through, still big enough by the normal size rules, and still holding at least
tp_flip_min_remaining_pct(50%) of the size it had just before price first touched it. If any check fails, the window ends at once and normal rules apply. Withtp_flip_reconfirmon (the default) that wall is then treated as a new wall: it is used for no entry at all until it confirms again from scratch. - There is no retry cooldown for this wall during the window, and no same-side entry may take the coin's slot.
- The entry still never chases: it is placed on the first update where the post-only order would rest in front of the wall, at the planned price.
- A refused attempt sends nothing to the exchange; the leverage is set only right before the order.
Real example. In a replay of 1 Oct 2026 on HYPEUSDT the take profit filled at 91.316 in front of a wall at 91.31-91.356. At that moment the wall no longer passed the size rules, so the window ended with no short; a quarter of a second later the wall was pulled (98% cancellation). The check kept the bot from shorting in front of a spoof.
Trailing stop
Trailing switches on once the trade's best ROE (return on margin, before fees) reaches trail_activate_roe (default +100%). From then on the stop locks part of the best ROE reached. trailing_mode decides how much:
| Mode | Lock | Best ROE +150% | +200% | +400% |
|---|---|---|---|---|
fixed_gap (default) | Best ROE minus trail_gap_roe (50 points) | +100% | +150% | +350% |
keep_pct | trail_keep_pct (50%) of the best ROE | +75% | +100% | +200% |
With a fixed gap, the room for a pullback stays the same however far the trade runs. With a kept share, the room grows with the profit. With the defaults, both lock +50% at the +100% trigger, and above it keep_pct leaves more room than fixed_gap.
Both modes follow the same rules:
- The stop only ever tightens. It moves only when the lock improves by at least
trail_step_roe(5 ROE points), which saves order-rate budget. - The stop never locks less than breakeven after fees and slippage.
- It never overrides a better lock, such as a breakeven stop from the hold rules.
- A new stop is placed and confirmed before the old one is cancelled, so the position is never without a stop.
- Changing the mode applies from the next update and never loosens an open stop. In live mode, changing the mode or lowering the keep share needs the typed confirmation "I ACCEPT".
The log reads, for example, "Trailing stop moved to ... (locks +150% ROE, peak +200%; fixed gap 50 ROE points behind the best)". With persist_trailing_state on, the "trailing active" marker survives a restart, so the trade card keeps showing "(trailing)".
Breakeven and hold rules
Several rules move the stop to breakeven. They all use the same two ideas.
- Net ROE is the gross ROE minus the round-trip fees as a share of margin, (maker fee + taker fee) x leverage. At 50x with 0.02% maker and 0.05% taker, fees are 3.5% of margin. A net ROE of +5% then needs a gross ROE of +8.5%, a price move of 0.17%.
- The breakeven stop is the stop price at which the whole trade nets about zero: entry fee, exit fee at the stop and, with
include_slippage_in_breakevenon, the assumed stop slippagepaper_slippage_bps. It is rounded away from the entry, so the lock is slightly better, never worse.
Example
Illustrative numbers. A long filled at 100.00 with maker 0.02%, taker 0.05% and 5 bps slippage: 100.00 x 1.0002 / (0.9995 x 0.9995) = 100.12, rounded up to the next 0.01 tick, 100.13. Without the slippage part the breakeven stop is 100.08.
Where breakeven is used:
| Situation | Rule | Below the hold minimum |
|---|---|---|
| No wall protects the position (definition above) | breakeven_when_unprotected: stop to breakeven when net ROE is at least min_net_roe_to_hold_unprotected | The stop stays. No exit |
| Anchor wall pulled, no backup wall | hold_unprotected_in_profit: hold with the stop at breakeven | Exit at market |
| Anchor wall absorbed, no backup wall | on_absorbed_after_fill = protect: stop to breakeven | The stop stays. No exit |
In every case the stop only moves if breakeven is tighter than the current stop and still on the right side of price. A better lock, for example from trailing, is never loosened. Each move is logged and notified, for example "No confirmed wall between price and the stop; net ROE +6.2% >= 5%: stop moved ... -> ... (breakeven + fees + slippage)".
All the ways a trade ends
| Exit | Order type | When |
|---|---|---|
| Stop | Exchange stop-market | Price reaches the stop, whether it sits behind the wall, at breakeven or at a trailing lock |
| Take profit | Close-only limit, armed near the target | Price reaches the target in front of the counter wall |
| Take profit at market | Market | Price jumped past an unarmed target |
| Wall pulled | Market | Anchor wall pulled with no backup wall and not enough profit to hold (or pulled_wall_exit = always) |
| Wall faded | Market | Only with exit_on_wall_faded on, as for a pull |
| Liquidation safety | Market | Live: the stop cannot sit safely before Binance's liquidation price without being in front of the wall |
| Close all | Market | You press "Close all" on the dashboard |
Whichever exit fills first closes the trade, and the other exit orders are cancelled. See Entries, stops and sizing for how the first stop is placed, and Coins, movers and limits for the limits that apply across trades.