# Bollinger Band Squeeze & Breakout AI Agent (MCP Script)

> Call `eterna.getBollingerBands()` alongside `eterna.getTickers()` inside one `execute_code` script to rank coins with the tightest band width `(upper - lower) / middle`. When price closes outside a compressed band with expanding 24h turnover, your agent enters in the breakout direction with a stop at the middle band.

- Canonical URL: https://ai.eterna.exchange/strategies/bollinger-band-breakout-agent
- Last updated: November 23, 2026
- Author: Eterna Quant & AI Team (Systematic Execution & MCP Playbooks)
- MCP endpoint: https://mcp.eterna.exchange/mcp

Volatility is mean-reverting: extreme compression precedes explosive moves. Measuring Bollinger Band width across 20 liquid pairs in a single sandbox call uncovers squeezes before retail traders notice.

## Key Facts

| Metric | Value | Notes |
|--------|-------|-------|
| Core SDK Method | getBollingerBands() | Upper, middle, lower bands |
| Compression Metric | Bandwidth % | (upper - lower) / middle |
| Invalidation | Middle Band (20 SMA) | Clean structural stopLoss |
| Execution Speed | <200ms | Low slippage on breakout fills |

## 1. Runnable Bollinger Squeeze Scanner

### bollinger-squeeze-scan.ts

```typescript
const watchlist = ["BTCUSDT", "ETHUSDT", "SOLUSDT", "AVAXUSDT", "DOGEUSDT", "ARBUSDT", "OPUSDT"];
const results = [];

for (const symbol of watchlist) {
  const [ticker, bb] = await Promise.all([
    eterna.getTickers({ symbol }),
    eterna.getBollingerBands({ symbol, interval: "60", period: 20, stdDev: 2 }),
  ]);

  const price = Number(ticker[0].lastPrice);
  const upper = Number(bb.upper);
  const middle = Number(bb.middle);
  const lower = Number(bb.lower);
  const bandwidthPct = ((upper - lower) / middle) * 100;

  results.push({
    symbol,
    price,
    bandwidthPct: Number(bandwidthPct.toFixed(2)),
    breakout: price > upper ? "UPPER_BREAK" : price < lower ? "LOWER_BREAK" : "INSIDE",
  });
}

return results.sort((a, b) => a.bandwidthPct - b.bandwidthPct);
```

**Returns:** Watchlist sorted from tightest volatility compression to widest, flagging live band breaks.

## Frequently Asked Questions

### How do I filter out false Bollinger breakouts?

Require a candle close outside the band on 1h or 4h timeframes, confirm healthy orderbook depth with `eterna.getOrderbook()`, and avoid entering right before major scheduled macro announcements.

## References & Primary Sources

- [Automated Technical Analysis Guide](https://ai.eterna.exchange/guides/automated-technical-analysis-mcp): Indicator inputs and multi-timeframe combinations.

## Related Guides

- [VWAP Intraday Pullback AI Trading Agent (MCP Script)](https://ai.eterna.exchange/strategies/vwap-intraday-agent)
- [EMA 20/50 Trend-Following AI Crypto Trading Agent (MCP Script)](https://ai.eterna.exchange/strategies/ema-crossover-trend-agent)
- [AI Trading for Ethereum (ETHUSDT) via Eterna MCP](https://ai.eterna.exchange/markets/eth)
- [Automated Crypto Technical Analysis with MCP: RSI, MACD, EMA, Bollinger Bands & VWAP](https://ai.eterna.exchange/guides/automated-technical-analysis-mcp)
