Back to Strategies

Order Book Imbalance

Code Reaction by 0xsDp5JzBDn·2026-07-02

// Expected payload sent to this reaction:
// { "bid_volume": 132.4, "ask_volume": 48.9, "imbalance": 0.63 }
// imbalance ranges roughly -1 (heavy sell pressure) to +1 (heavy buy pressure)

const book = JSON.parse($.Request.data);

// Strong buy-side imbalance suggests upward pressure
if (book.imbalance > 0.6 && $.Strategy.lastTrigger.action !== $.Action.LONG) {
  await $.Strategy.action($.Action.LONG, { id: "orderbook-imbalance" });
} else if (book.imbalance < -0.6 && $.Strategy.lastTrigger.action === $.Action.LONG) {
  await $.Strategy.action($.Action.EXIT);
}