Public
Binance USDT-M futures bot: scored strategy + safety rails
binancecronfuturestelegramtrading
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

Binance USDT-M Futures Bot

A real-money Binance perpetual-futures trading bot with a real scored strategy (no placeholder points) and a full set of safety rails. It is a separate val from the Jupiter paper bot — it never touches that code or its account.

⚠️ This trades real money. It places live market orders, sets 5x leverage, and parks reduce-only stop-loss / take-profit brackets on Binance USDT-M futures. Start with a tiny funded account and watch it in paper/forward-test mode first.

Files

FileRole
main.tsCron entrypoint — scans, scores, and trades
strategy.tsOrder-flow scalping signal from HVN/LVN + footprint imbalance
flow.tsBuilds the volume profile (POC, HVN, LVN, Core Zone) + footprint from trades
safety.tsKill switch, daily loss/trade caps, drawdown guard, dedup, cooldown, reconcile
config.tsAll tunable settings in one place
telegram.tsTelegram alerts
control.tsHTTP webhook — status + remote kill switch
README.mdThis file

Market universe

Every 2 hours the bot re-scans the whole Binance USDT-M market and rebuilds its watchlist. A symbol is included only if it meets all of:

  • 24h quote volume ≥ MIN_VOLUME_USD ($20M)
  • It is a USDT perpetual (/USDT:USDT)
  • Base is not BTC or ETH (EXCLUDED_BASES)
  • Price ≤ MAX_BASE_PRICE_USD ($1,000)

Strategy (Option B) — Order Flow (HVN / LVN / Footprint)

The strategy is built on order flow, not lagging indicators. For each symbol it pulls up to the last 2h of trades and:

  1. Volume profile — buckets trade volume into 40 price bins → finds:
    • POC (Point of Control): the price level with the most traded volume
    • HVN (High Volume Nodes): bins ≥ 1.5× average volume — strong support/resistance that price gravitates to
    • LVN (Low Volume Nodes): bins ≤ 0.3× average volume — weak zones price slices through quickly
    • Core Zone (value area): the range containing 70% of traded volume
  2. Footprint — for the latest 15m candle, sums buy-volume vs sell-volume at the aggressor level:
    • Delta = buy − sell volume
    • Imbalance = (buy − sell) / (buy + sell), in −1..1

Signal logic:

  • Long when price is trading off an HVN support and the footprint shows a taker-buy imbalance (delta > 0, imbalance > 0.25).
  • Short when price is rejecting off an HVN resistance with taker-sell imbalance.
  • LVN proximity adds "fuel" points (room to run through the weak zone).

Gates: the setup must be off an HVN and backed by a strong footprint imbalance — never a blind one-sided entry. Trades only at score ≥ 70. Stop = 25% of the observed trading range; target = 2× stop distance (R:R 1:2).

Safety rails (Option C)

  • Kill switch — halts all new entries. Flip it via the control webhook (CONTROL_TOKEN) or by setting KILL_SWITCH-style DB state.
  • Daily loss cap — stops opening new trades once realized loss hits MAX_DAILY_LOSS_USD (default $50).
  • Daily trade capMAX_DAILY_TRADES (default 10) per UTC day.
  • Drawdown guard — stops new entries once unrealized loss on open positions hits MAX_DRAWDOWN_USD (default $100).
  • Max open tradesMAX_OPEN_TRADES (default 2), counted correctly for shorts (|contracts| > 0).
  • Position dedup — never opens a second position on a symbol already held.
  • Cooldown — no re-entry on a symbol for SYMBOL_COOLDOWN_MS after a trade.
  • Reconciliation — each run syncs the DB ledger with Binance's live positions, booking closed positions' PnL and updating marks.

Setup

  1. Set env vars on this val:
    • BINANCE_API_KEY, BINANCE_SECRET_KEY — futures-enabled API keys
    • TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID — alerts (optional)
    • CONTROL_TOKEN — secret to authorize kill-switch toggles (optional)
  2. Confirm the interval schedule on main.ts (default: every 15 min).
  3. Test with a tiny balance first. Watch Telegram + the control webhook before trusting it with real size.

Control webhook

  • GET → JSON status (kill switch, today's PnL/trades, open positions)
  • POST {"action":"kill","state":true} with header X-Control-Token: <token> → flips the kill switch. Refused unless CONTROL_TOKEN is set.