Wallbot

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.

ItemValue usedWhy it matters
Coin rulestick 0.0001, quantity step 0.1, minimum notional 5 USDT, maximum leverage 75xPrices snap to the tick, quantities round down to the step
Maintenance margin0.5% (one bracket, no maintenance amount)Sets the liquidation price
Fees0.02% maker (entry, take profit), 0.05% taker (stop, market exit)Round trip maker + taker = 0.07% of notional
Slippage5 bps on stop and market exits (paper_slippage_bps)The stop fills a little past its trigger
MarginIsolated; 10% of a 100 USDT available balance (about 10 USDT per trade)One trade can lose at most its own margin
SettingsDefaults: wall hug, stop 0.5% behind the wall, buffer 8% of margin, 10 ticks minimum, max fees 15% of marginSee 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

ItemCalculationResult
Entrynear edge 2.4960 + 1 tick (entry_ticks)2.4961
Stopfar edge 2.4950 x (1 - 0.5%) = 2.482525, rounded down2.4825
Quantity10 x 75 / 2.4961 = 300.47, rounded down to the 0.1 step300.4 coins
Notional and margin300.4 x 2.4961 = 749.83; / 75749.83 USDT; 10.00 USDT
LiquidationBinance formula, isolated wallet = margin minus the opening fee2.4757 (204 ticks, 0.82% below entry)
Liquidation checkstop fill after slippage 2.4825 x 0.9995 = 2.48126; room to liquidation 55 ticks; needed max(8% of margin = 27 ticks, 10 ticks) = 27passes
Fees check(0.02% + 0.05%) x 75 = 5.25% of margin, limit 15%passes
Loss at the stopprice move 4.09 + fees 0.52 + slippage 0.374.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:

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

ItemCalculationUSDT
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 insteadfill 2.48126 after slippage, taker fee-4.98 (-49.8%)

Illustrative numbers, not a real trade.

Long trade levels: counter wall and take profit above price, entry just above the support wall below price, the stop below the wall and liquidation below the stop higher lower Counter wall 2.5400-2.5411 Take profit 2.5398 Order armed from 2.5322 (0.3% away) Price 2.5150 Entry 2.4961 (1 tick in front) Support wall, core 2.4950-2.4960 Stop 2.4825 (0.5% behind far edge) Liquidation about 2.4757
The long in example A. Spacing is not to scale. The take profit sits in front of the counter wall, the stop behind the support wall, and liquidation further away than the stop.

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

ItemLong (example A)Short
Wallsupport 2.4945-2.4961, below priceresistance 2.5340-2.5356, above price
Entrynear edge + 1 tick = 2.4961near edge - 1 tick = 2.5339
Stop2.4950 x (1 - 0.5%), rounded down = 2.48252.5350 x (1 + 0.5%) = 2.547675, rounded up = 2.5477
Leverage75x75x
Quantity, margin300.4 coins, 10.00 USDT295.9 coins, 10.00 USDT
Liquidation2.4757, below entry2.5544, above entry (0.81%)
Loss at the stop4.98 USDT (49.8%)4.99 USDT (49.9%)
Counter wallresistance 2.5400-2.5411support 2.4900-2.4911 (near edge 2.4910)
Take profit2.5400 - 2 ticks = 2.53982.4910 + 2 ticks = 2.4912
Reward/risk3.082.97
Take profit armed from2.5322 (0.3% below the target)2.4987 (0.3% above the target)
Trailing switches on at2.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

WallCore edgesDistance from 2.4960 to its far edgeIn the stack?
Wall 1 (nearest)2.4960 to 2.49500.04%yes, the anchor
Wall 22.4900 to 2.4890(2.4960 - 2.4890) / 2.4960 = 0.28%yes, the farthest member
Wall 32.4570 to 2.4560(2.4960 - 2.4560) / 2.4960 = 1.60%no, beyond 1.5%
ItemSingle wall (example A)Stack (walls 1 and 2)
Entry2.49612.4961 (still in front of wall 1)
Stop2.4825 (behind wall 1)2.4890 x 0.995 = 2.476555, rounded down = 2.4765 (behind wall 2)
Leverage75x68x: at 69x the stop's fill (2.47526) is only 25 ticks before liquidation 2.47279, and 29 are needed
Quantity, margin300.4 coins, 10.00 USDT272.4 coins, 10.00 USDT
Liquidation2.47572.4723 (238 ticks, 0.96% below entry)
Loss at the stop4.98 USDT (49.8%)6.15 USDT (61.5%)
Reward/risk to 2.53983.082.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%.

Wall stack: wall 1 and wall 2 are within 1.5% of wall 1's near edge, wall 3 is beyond that limit; the entry is above wall 1 and the stop below wall 2 Price 2.5150 Entry 2.4961 Wall 1, the anchor Wall 2, farthest in the stack Stop 2.4765 (0.5% behind wall 2) Liquidation 2.4723 (68x) 1.5% span limit, 2.4586 Wall 3, outside the span span
Walls 1 and 2 form the stack. The stop goes behind wall 2, and the leverage steps down until liquidation is behind that stop with the buffer. Spacing is not to scale.

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 pulledGross ROENet ROEWhat 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.

Two panels. Left: wall 1 pulled, wall 2 still above the stop, the trade re-anchors. Right: the only wall pulled, nothing above the stop, the trade exits or moves the stop to breakeven depending on net ROE With a backup wall Without a backup wall price wall 1 pulled wall 2: new anchor stop 2.4765 stays Position kept, re-anchor #1 price only wall pulled stop 2.4825 Net ROE below 5%: exit at market 5% or more: stop to breakeven 2.4991
A backup wall in front of the stop always wins. Without one, the net ROE threshold decides between exiting and holding at breakeven.

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.

StepMark priceNet ROEStopLog
Fill2.4961-5.2%2.4825protected by the wall below
Dip through the zone (best bid 2.4940)2.4942-11.0%2.4825Wall at 2.4945 broken. price moved through the wall, then the "below 5%" line
Recovery2.4990+3.5%2.4825still below 5%: the stop stays (no new line)
Recovery2.5000+6.5%2.4991stop moved to breakeven
If price falls back2.4991 hitabout 0filled near 2.4979result 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".

Price over time: after the fill price dips through the wall, which is reported broken, then recovers; when net ROE reaches 5% the stop steps up from 2.4825 to the breakeven price 2.4991 time price wall broken entry 2.4961 stop 2.4825 stop 2.4991 (breakeven) net ROE reaches 5% at about 2.4996
The wall breaks but the stop holds. When the recovery lifts net ROE to 5%, the stop steps up to breakeven + fees + slippage. Spacing is not to scale.

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:

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 reachedPrice at the peakfixed_gap lockfixed_gap stopkeep_pct lockkeep_pct stop
+50%2.5127not active2.4825not active2.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 pathfixed_gapkeep_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 outstop 2.5460 (+150%)
Drop to +100% (2.5294)already outstop 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.

ROE over the path: up to 150, down to 90, up to 300, down to 100. The fixed gap stop is hit on the pullback at plus 100; the keep share stop survives the pullback and is hit on the final drop at plus 150 0% 100% 200% 300% fixed_gap out at +100% keep_pct out at +150% ROE path (bright line)
Same path, two modes. The coral dashed steps are the fixed_gap stop, the teal dotted steps the keep_pct stop. The squares mark where each one is hit.

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

ItemCalculationUSDT
Available on the exchangeafter positions and resting orders20.00
Wallbot's own pending entriesmargin held by its resting entry orders6.00
Sizing base20.00 + 6.00 (then the live balance cap, if set)26.00
Margin per entry10% (margin_pct) x 26.002.60
Gate: needed2.60 x (1 + 5% buffer)2.73
Gate: freethe exchange's free balance20.00
Decision20.00 covers 2.73placed

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)
Bars: available 20 plus own pending 6 make a sizing base of 26; 10 percent is a margin of 2.60; the gate needs 2.73 and the free balance is 20 Sizing base available 20.00 own pending 6.00 = 26.00 Margin 10% 2.60 USDT Gate need 2.73 free 20.00: passes
Pending entries do not shrink the next entry, but the free balance must still cover the planned margin plus 5%.

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 pendingNew core entry?New movers entry?
nothingyesyes
1 core (pending)yesyes
1 core + 1 moversyes (third slot)no: movers slots full
2 coreyes (third slot)yes (third slot)
2 core + 1 moversno: all 3 slots usedno
3 corenono

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:

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.