Worked examples
Step-by-step trades with real arithmetic: a long, the same idea as a short, a wall stack, a pulled wall, the breakeven rule, the two trailing modes, sizing with pending entries, and how many trades can be open at once. All numbers are illustrative, not real trades.
Assumptions used on this page
Every example uses one made-up coin, XYZUSDT, so the numbers can be compared from one example to the next. The prices, entries, stops and liquidation prices were computed with the bot's own planning code (plan_wall_hug and pick_leverage in app/risk.py, and Binance's liquidation formula in app/liq.py). They are illustrative, not a real trade.
| Item | Value used | Why it matters |
|---|---|---|
| Coin rules | tick 0.0001, quantity step 0.1, minimum notional 5 USDT, maximum leverage 75x | Prices snap to the tick, quantities round down to the step |
| Maintenance margin | 0.5% (one bracket, no maintenance amount) | Sets the liquidation price |
| Fees | 0.02% maker (entry, take profit), 0.05% taker (stop, market exit) | Round trip maker + taker = 0.07% of notional |
| Slippage | 5 bps on stop and market exits (paper_slippage_bps) | The stop fills a little past its trigger |
| Margin | Isolated; 10% of a 100 USDT available balance (about 10 USDT per trade) | One trade can lose at most its own margin |
| Settings | Defaults: wall hug, stop 0.5% behind the wall, buffer 8% of margin, 10 ticks minimum, max fees 15% of margin | See stop_mode and stop_beyond_wall_pct |
On a real coin, the tick, step, leverage brackets and your account's fee rates come from the exchange, so your numbers will differ. The method stays the same.
A long trade from confirmation to close
Price is 2.5150. A large bid zone sits at 2.4945-2.4961, about 0.8% below price, inside the 0.3% to 3% distance band. The steps below follow the order the bot works in.
1. The wall is confirmed
The zone has to stay in place for wall_persist_s (45 s) before the bot trusts it. Then the Activity log shows:
Support wall confirmed at 2.4945-2.4961 (1.76M USDT)
The zone holds four levels: 2.4945 (5,000 coins), 2.4950 (300,000), 2.4955 (150,000) and 2.4960 (250,000). With wall_core_pct at 90%, the edges come from the fewest largest levels holding 90% of the size: 2.4950, 2.4955 and 2.4960. The stray 2.4945 level is left out. So the near edge is 2.4960 and the far edge is 2.4950. Without the core rule the far edge would be 2.4945 and the stop would sit 5 ticks lower.
2. The support/resistance check
With sr_filter on, the wall needs a 4h level at or below price within 0.3% of the zone. Suppose the 4h pivots give a level at 2.4932. It is 0.05% below the zone, so the wall passes. If no level were close enough, the log would say Skipped wall: no 4h level at or below price within 0.3% of the wall at 2.4945-2.4961 and nothing more would happen.
3. The plan
The bot then checks that nothing on XYZUSDT belongs to someone else, confirms isolated margin, and plans the entry. The leverage search starts at the coin's maximum (75x) and steps down until every check passes. Here 75x passes at once.
Example: the long plan
| Item | Calculation | Result |
|---|---|---|
| Entry | near edge 2.4960 + 1 tick (entry_ticks) | 2.4961 |
| Stop | far edge 2.4950 x (1 - 0.5%) = 2.482525, rounded down | 2.4825 |
| Quantity | 10 x 75 / 2.4961 = 300.47, rounded down to the 0.1 step | 300.4 coins |
| Notional and margin | 300.4 x 2.4961 = 749.83; / 75 | 749.83 USDT; 10.00 USDT |
| Liquidation | Binance formula, isolated wallet = margin minus the opening fee | 2.4757 (204 ticks, 0.82% below entry) |
| Liquidation check | stop fill after slippage 2.4825 x 0.9995 = 2.48126; room to liquidation 55 ticks; needed max(8% of margin = 27 ticks, 10 ticks) = 27 | passes |
| Fees check | (0.02% + 0.05%) x 75 = 5.25% of margin, limit 15% | passes |
| Loss at the stop | price move 4.09 + fees 0.52 + slippage 0.37 | 4.98 USDT, 49.8% of margin |
Illustrative numbers, not a real trade.
The log explains the choice:
Wall hug at 75x (exchange maximum): stop 0.5% behind the wall, 68 ticks before liquidation; liquidation 204 ticks (0.82%) from entry; expected loss at stop 49.8% of margin incl. fees and slippage; fees 5.2% of margin
4. The reward/risk check
The nearest confirmed resistance wall is at 2.5400-2.5411, so the take profit would be 2 ticks in front of it (tp_ticks): 2.5398. The bot compares the reward with the risk, both in price:
- reward: 2.5398 - 2.4961 = 0.0437, minus fees in price (2.4961 x 0.02% + 2.5398 x 0.05% = 0.0018) = 0.0419;
- risk: 2.4961 - 2.4825 = 0.0136;
- reward/risk = 0.0419 / 0.0136 = 3.08, above
min_reward_risk(1.0).
The counter wall is only read here for this check. The take profit itself is chosen and tracked after the fill.
5. The entry and the free-balance gate
The planned margin is 10.00 USDT. The free balance must cover it plus 5% (free_margin_buffer_pct): 10.50 USDT. With 100 USDT free, the post-only entry is placed:
Placed long entry 300.4 @ 2.4961, stop 2.4825, 75x, margin 10.00, loss if wall breaks ≈4.98 USDT (50% of margin), 4h level 2.4932
6. The fill and the stop
Price drops and a trade prints through 2.4961. The stop is placed on the exchange the moment the entry fills:
Filled long 300.4 @ 2.4961. Stop armed at 2.4825
Take profit tracking started: 2.5398, before the counter wall at 2.54-2.5411
The support wall sits between the stop and price, so the trade card shows it as protected by that wall.
7. Trailing, the take profit arms, the close
Price bounces. At 2.5294 the trade is up +100% ROE (a 1.33% move at 75x), so trailing switches on and the stop jumps from 2.4825 to 2.5127, locking +50%. At 2.5322 price is within 0.3% (tp_arm_distance_pct) of the take profit, so the close-only limit order goes to the exchange. Just before the target, the trailing stop has followed to 2.5230 (locks +81%).
Trailing stop moved to 2.5127 (locks +50% ROE, peak +100%; fixed gap 50 ROE points behind the best)
Take profit armed at 2.5398 (price 2.5322, target wall 2.54-2.5411)
Closed long @ 2.5398: +12.82 USDT (+128% of margin), take profit
Example: the result
| Item | Calculation | USDT |
|---|---|---|
| Price gain | (2.5398 - 2.4961) x 300.4 | +13.13 |
| Entry fee (maker) | 749.83 x 0.02% | -0.15 |
| Take-profit fee (maker limit) | 2.5398 x 300.4 x 0.02% | -0.15 |
| Net | +131.3% gross ROE, +128.3% net on 10.00 margin | +12.82 |
| If the stop had fired instead | fill 2.48126 after slippage, taker fee | -4.98 (-49.8%) |
Illustrative numbers, not a real trade.
The same trade as a short
Everything mirrors. A resistance wall above price takes the place of the support wall, the stop goes above it, and the take profit sits in front of a support wall below price. Price is again 2.5150. The resistance zone is 2.5340-2.5356 with levels 2.5340 (250,000), 2.5345 (150,000), 2.5350 (300,000) and a stray 2.5355 (5,000). The core is 2.5340-2.5350, so for a short the near edge is 2.5340 (the lowest core level) and the far edge 2.5350 (the highest).
Example: the short plan and result
| Item | Long (example A) | Short |
|---|---|---|
| Wall | support 2.4945-2.4961, below price | resistance 2.5340-2.5356, above price |
| Entry | near edge + 1 tick = 2.4961 | near edge - 1 tick = 2.5339 |
| Stop | 2.4950 x (1 - 0.5%), rounded down = 2.4825 | 2.5350 x (1 + 0.5%) = 2.547675, rounded up = 2.5477 |
| Leverage | 75x | 75x |
| Quantity, margin | 300.4 coins, 10.00 USDT | 295.9 coins, 10.00 USDT |
| Liquidation | 2.4757, below entry | 2.5544, above entry (0.81%) |
| Loss at the stop | 4.98 USDT (49.8%) | 4.99 USDT (49.9%) |
| Counter wall | resistance 2.5400-2.5411 | support 2.4900-2.4911 (near edge 2.4910) |
| Take profit | 2.5400 - 2 ticks = 2.5398 | 2.4910 + 2 ticks = 2.4912 |
| Reward/risk | 3.08 | 2.97 |
| Take profit armed from | 2.5322 (0.3% below the target) | 2.4987 (0.3% above the target) |
| Trailing switches on at | 2.5294 (+100% ROE) | 2.5001 (+100% ROE) |
| Result at the take profit | +12.82 USDT (+128%) | (2.5339 - 2.4912) x 295.9 - fees = +12.34 USDT (+123%) |
Illustrative numbers, not a real trade.
For a short, only resistance walls above price protect the trade. Support walls below a short are its take-profit targets, never protection, and they never trigger a re-plan.
A wall stack
Now there are three confirmed support walls below price. With entry_anchor set to stack (default), the nearest wall anchors the entry and the stop goes behind the farthest wall that is still inside the stack span (stack_max_span_pct, 1.5%). The span is measured from the nearest wall's near edge to each other wall's far edge.
Example: which walls join the stack
| Wall | Core edges | Distance from 2.4960 to its far edge | In the stack? |
|---|---|---|---|
| Wall 1 (nearest) | 2.4960 to 2.4950 | 0.04% | yes, the anchor |
| Wall 2 | 2.4900 to 2.4890 | (2.4960 - 2.4890) / 2.4960 = 0.28% | yes, the farthest member |
| Wall 3 | 2.4570 to 2.4560 | (2.4960 - 2.4560) / 2.4960 = 1.60% | no, beyond 1.5% |
| Item | Single wall (example A) | Stack (walls 1 and 2) |
|---|---|---|
| Entry | 2.4961 | 2.4961 (still in front of wall 1) |
| Stop | 2.4825 (behind wall 1) | 2.4890 x 0.995 = 2.476555, rounded down = 2.4765 (behind wall 2) |
| Leverage | 75x | 68x: at 69x the stop's fill (2.47526) is only 25 ticks before liquidation 2.47279, and 29 are needed |
| Quantity, margin | 300.4 coins, 10.00 USDT | 272.4 coins, 10.00 USDT |
| Liquidation | 2.4757 | 2.4723 (238 ticks, 0.96% below entry) |
| Loss at the stop | 4.98 USDT (49.8%) | 6.15 USDT (61.5%) |
| Reward/risk to 2.5398 | 3.08 | 2.14 |
Illustrative numbers, not a real trade.
The deeper stop costs more if it is hit, and the leverage drops so that liquidation stays behind every wall in the stack. In return, the trade survives wall 1 being pulled (next example). The log records the choice:
Wall hug at 68x (69x: Stop 2.4765 (fill 2.47526 after 5 bps slippage) is 25 ticks before liquidation 2.47279 at 69x; needs 29): stop 0.5% behind the wall, 42 ticks before liquidation; liquidation 238 ticks (0.96%) from entry; expected loss at stop 61.5% of margin incl. fees and slippage; fees 4.7% of margin
Wall stack (2 walls, span 0.28%): 2.4945-2.4961, 2.489-2.4901; stop 2.4765 behind the farthest, 68x; counter wall at entry: take profit would be 2.5398 before 2.54-2.5411, reward/risk 2.14 (tracking starts at the fill)
Wall 3 is outside the span, so it gets its own note once it would have been tried: XYZUSDT support 2.456-2.4571 not used: not the nearest wall (nearest 2.4945-2.4961), outside its stack span 1.5%.
A pulled wall, with and without a backup
A wall is "pulled" when it shrinks below 35% of its peak and at least 70% of the drop was cancelled orders rather than trades. That is the classic spoof. What happens to an open trade depends on pulled_wall_exit (default unless_protected) and on whether another confirmed wall still guards the stop.
With a backup wall: re-anchor
Take the stack trade above: filled at 2.4961, stop 2.4765, 68x. Wall 1 is pulled. The bot looks for another confirmed support wall whose far edge is still above the stop. Wall 2's far edge, 2.4890, is above 2.4765, so the trade re-anchors to wall 2 and keeps its position and its stop:
Wall at 2.4945 pulled (likely spoof). 88% of the drop was cancellation
Wall at 2.4945-2.4961 pulled: still protected by the confirmed wall at 2.489-2.4901 in front of the stop 2.4765; keeping the position (re-anchor #1)
The stop does not move here, because wall 2 was already the farthest wall and the stop already sits behind it. If a stack wall in the middle had gone, and the farthest remaining wall were closer to price, tighten_stop_on_stack_change would move the stop up behind it (only when that tightens it by 5 ticks or more).
Without a backup wall: exit or hold
Now take the single-wall trade from example A: filled at 2.4961, stop 2.4825, 75x, nothing else on the bid side. The wall is pulled. With no backup, hold_unprotected_in_profit decides. The trade may stay only if it is up at least min_net_roe_to_hold_unprotected (5% of margin) after round-trip fees. At 75x the fees are (0.02% + 0.05%) x 75 = 5.25% of margin, so the gross ROE must be at least 10.25%. That is a price of about 2.4996.
Example: the same pull at two different prices
| Price when the wall is pulled | Gross ROE | Net ROE | What the bot does |
|---|---|---|---|
| 2.4975 | +4.2% | -1.0% | Exits at market. Fill 2.4975 x 0.9995 = 2.49625; result -0.48 USDT (-4.8%) |
| 2.5000 | +11.7% | +6.5% | Holds. The stop moves from 2.4825 to breakeven + fees + slippage, 2.4991 |
Illustrative numbers, not a real trade.
Wall pulled, no backup wall: net ROE -1.0% (gross +4.2% - fees 5.2%) is below 5%: exiting
Wall vanished after entry: exiting at market
Wall at 2.4945-2.4961 pulled, no backup wall, holding in profit (net ROE +6.5%); stop moved 2.4825 -> 2.4991 (breakeven + fees); trailing stop and take profit stay active
With pulled_wall_exit set to always, both cases exit at market. A pending (unfilled) entry is cancelled on a pull in every mode.
A broken wall and the breakeven rule
A wall is "broken" when price trades through it. The bot does not exit for that: the stop is there for exactly this case. But once no confirmed wall stands between price and the stop, the position counts as not protected by a wall (protection_by_wall_between). From then on, breakeven_when_unprotected moves the stop to breakeven as soon as the net ROE reaches 5%. The check runs on mark-price updates, at most every 2 seconds.
Take example A again: filled at 2.4961, stop 2.4825, 75x. Price dips, the best bid falls to 2.4940 (below the zone's low edge 2.4945), and the wall is reported broken. The stop at 2.4825 is not touched. Price then recovers.
Example: breakeven + fees + slippage
The breakeven stop is the price where a stop-out nets zero after the maker entry fee, the taker exit fee and the assumed 5 bps slippage (include_slippage_in_breakeven on):
2.4961 x 1.0002 / (0.9995 x 0.9995) = 2.49910, rounded up (away from entry) = 2.4991.
| Step | Mark price | Net ROE | Stop | Log |
|---|---|---|---|---|
| Fill | 2.4961 | -5.2% | 2.4825 | protected by the wall below |
| Dip through the zone (best bid 2.4940) | 2.4942 | -11.0% | 2.4825 | Wall at 2.4945 broken. price moved through the wall, then the "below 5%" line |
| Recovery | 2.4990 | +3.5% | 2.4825 | still below 5%: the stop stays (no new line) |
| Recovery | 2.5000 | +6.5% | 2.4991 | stop moved to breakeven |
| If price falls back | 2.4991 hit | about 0 | filled near 2.4979 | result about +0.00 USDT |
Illustrative numbers, not a real trade.
No confirmed wall between price and the stop; net ROE -11.0% is below 5%: the stop stays at 2.4825
No confirmed wall between price and the stop; net ROE +6.5% >= 5%: stop moved 2.4825 -> 2.4991 (breakeven + fees + slippage)
Each "below 5%" line is written once, not on every check, until the situation changes. Below the threshold the stop simply stays. There is no early exit. The rule only tightens: if the trailing stop already locks more than breakeven, it is left alone and the log says the stop "already locks breakeven or better".
Trailing: fixed gap vs keep a share
Trailing starts when the trade reaches trail_activate_roe (+100% ROE). Then trailing_mode decides where the stop goes:
fixed_gap(default): the stop staystrail_gap_roe(50) ROE points behind the best ROE.keep_pct: the stop lockstrail_keep_pct(50%) of the best ROE.
Both only ever tighten, move only when the lock improves by at least trail_step_roe (5 points), and never lock below breakeven after fees and slippage. The table uses example A's entry 2.4961 at 75x. Stop prices are rounded down to the tick, so the locked ROE is a hair under the target.
Example: peak ROE vs locked ROE
| Best ROE reached | Price at the peak | fixed_gap lock | fixed_gap stop | keep_pct lock | keep_pct stop |
|---|---|---|---|---|---|
| +50% | 2.5127 | not active | 2.4825 | not active | 2.4825 |
| +100% | 2.5294 | +50% | 2.5127 | +50% | 2.5127 |
| +120% | 2.5360 | +70% | 2.5193 | +60% | 2.5160 |
| +150% | 2.5460 | +100% | 2.5293 | +75% | 2.5210 |
| +200% | 2.5627 | +150% | 2.5460 | +100% | 2.5293 |
| +300% | 2.5959 | +250% | 2.5793 | +150% | 2.5460 |
| +400% | 2.6292 | +350% | 2.6125 | +200% | 2.5626 |
Illustrative numbers, not a real trade. With the defaults the two modes agree at +100%. Above that, fixed_gap locks more and keep_pct leaves more room.
Which one ends better depends on the path. Here is one price path, run through both modes: up to +150%, a pullback to +90%, a rally to +300%, then a drop back to +100%.
| Step on the path | fixed_gap | keep_pct |
|---|---|---|
| Peak +150% (2.5460) | stop 2.5293 (+100%) | stop 2.5210 (+75%) |
| Pullback to +90% (2.5261) | stop hit; fill 2.52804 after slippage; +9.06 USDT (+90.7% net) | not hit (stop is lower) |
| Rally to +300% (2.5959) | already out | stop 2.5460 (+150%) |
| Drop to +100% (2.5294) | already out | stop hit at 2.5460; fill 2.54473; +14.08 USDT (+140.8% net) |
On a path that goes straight up to +300% and then falls, it is the other way round: fixed_gap exits at its +250% lock (+24.07 USDT, +240.7% net), while keep_pct exits at +150% (+14.08 USDT). The locks are before fees and slippage, which cost about 9 ROE points at 75x. In live mode, changing the trailing mode needs a typed I ACCEPT.
Sizing with pending entries and the free-balance gate
Two settings work together. sizing_base decides how big the next entry is. require_free_margin decides whether there is enough free balance to place it at all.
The exchange's "available balance" already has the margin of your resting entry orders taken out. If the bot sized from that alone, every pending entry would make the next one smaller. So with available_plus_own_pending (default) the bot adds back the margin of its own pending entries. Open positions, your manual orders and positions, fees and funding still reduce the base.
Example: base 26, margin 2.60
| Item | Calculation | USDT |
|---|---|---|
| Available on the exchange | after positions and resting orders | 20.00 |
| Wallbot's own pending entries | margin held by its resting entry orders | 6.00 |
| Sizing base | 20.00 + 6.00 (then the live balance cap, if set) | 26.00 |
| Margin per entry | 10% (margin_pct) x 26.00 | 2.60 |
| Gate: needed | 2.60 x (1 + 5% buffer) | 2.73 |
| Gate: free | the exchange's free balance | 20.00 |
| Decision | 20.00 covers 2.73 | placed |
Illustrative numbers, not a real trade. The quantity is rounded down to the step, so the real margin is slightly lower (at 2.4961 and 75x: 78.1 coins, 2.5993 USDT), and the gate uses that real figure.
Entry sizing: available 20.00 + own pending 6.00 -> base 26.00; margin 2.60 (10%); free at the check 20.00
The gate fails when pending entries hold most of the money. With 1.40 USDT free and 20.00 USDT in Wallbot's pending entries, the base is 21.40, the margin 2.14 and the need 2.25. 1.40 does not cover it, so nothing is placed. The order is never shrunk to fit.
Skipped wall: not enough free balance: need 2.25, free 1.40 (pending entries hold 20.00, open positions 10.00)
Movers and max positions
Every pending entry and every open trade takes one slot of max_positions (default 3). With the top movers group on (movers_enabled), the scanner adds the movers_count (3) coins with the largest 24h change, but at most movers_max_positions (1) movers trades may be open or pending at once. Movers trades also count toward max_positions. A coin that is both core and a mover counts as core.
Example: max_positions 3, movers_max_positions 1
| Already open or pending | New core entry? | New movers entry? |
|---|---|---|
| nothing | yes | yes |
| 1 core (pending) | yes | yes |
| 1 core + 1 movers | yes (third slot) | no: movers slots full |
| 2 core | yes (third slot) | yes (third slot) |
| 2 core + 1 movers | no: all 3 slots used | no |
| 3 core | no | no |
Illustrative. So with these settings you can have at most 3 trades in total, of which at most 1 is a movers trade. The 3 movers coins are watched and recorded, but only one of them can trade at a time.
When the movers cap blocks an entry, the log says so once per coin: Entry skipped: movers slots full (1 open or pending movers trade(s)). A full max_positions is silent: the bot simply does not try. Other limits apply on top:
- one trade per coin and side, and only one side per coin unless
allow_both_sidesis on with a Hedge Mode account; - the correlation guard,
max_same_direction_correlated(2): at most 2 trades in the same direction on coins whose 15m returns correlate above 0.8; - the free-balance gate from the previous example.
Note. On its first start the Trading instance (8788) presets 1 trade, no movers and no second side. With max_positions at 1, one pending entry anywhere blocks every other coin until it fills or is cancelled.