# Squeeze Breakout

> Squeeze Breakout is a strategy that trades NAS100 on 15-minute bars. It holds at most 1 open trade and waits 200 bars before trading.

Source: https://algobarsx.com/docs/ex-31-squeeze-breakout/

```algobarsx
strategy "Squeeze Breakout"
    market: NAS100
    bars: 15m
    max_open: 1
    warmup: 200

bb = bollinger(close, 20, multiplier: 2.0)
kc = keltner(close, 20, multiplier: 1.5)
squeeze_on = bb.upper < kc.upper and bb.lower > kc.lower
released = ends(squeeze_on)
momentum_up = linreg_slope(close, 20) > 0

when released and momentum_up and close > kc.upper:
    buy risk: 1%, stop: kc.middle, target: 2R:
        trail by: atr(14) * 2, after: 1R

when released and not momentum_up and close < kc.lower:
    sell risk: 1%, stop: kc.middle, target: 2R:
        trail by: atr(14) * 2, after: 1R

background orange.fade(90), when: squeeze_on
```
What this script says

Squeeze Breakout is a strategy that trades NAS100 on 15-minute bars. It holds at most 1 open trade and waits 200 bars before trading.

It calculates `bb` as the Bollinger Bands (source the close, length 20, multiplier 2.0), `kc` as the Keltner Channels (source the close, length 20, multiplier 1.5), `squeeze_on` as whether `bb.upper` is below `kc.upper` and `bb.lower` is above `kc.lower`, `released` as whether `squeeze_on` stops being true and `momentum_up` as whether the linreg slope (source the close, length 20) is above 0.

When `released` and `momentum_up` and the close is above `kc.upper`, it buys at market, risking 1% of the balance, with a stop at `kc.middle` and with a target 2R from the entry; once open, it trails the stop by 2 × the 14-bar ATR once the trade reaches 1R.

When `released` and not `momentum_up` and the close is below `kc.lower`, it sells at market, risking 1% of the balance, with a stop at `kc.middle` and with a target 2R from the entry; once open, it trails the stop by 2 × the 14-bar ATR once the trade reaches 1R.

On the chart, it shades the background when `squeeze_on`.
