Skip to main content

Module squeeze

Module squeeze 

Source
Expand description

§The squeeze clock

A squeeze is a stretch of bars where price has gone unusually quiet: the Bollinger Bands (which measure how spread out closes are) have shrunk inside the Keltner Channels (which measure how far price usually travels per bar). Quiet markets do not stay quiet forever. When the bands burst back out, the squeeze has fired, and the move that follows is what SD tries to ride.

This file is the finite-state machine from the paper, written once so that both the classic indicator (classic.rs) and SD v2 (features.rs) run on the very same clock. The only thing that differs between them is which compression series and which “momentum flipped” series they feed in.

           comp rises above 0                comp drops below the
  (none) ───────────────────────▶ SQUEEZE ─── highest tier reached ──▶ FIRED
     ▲                               ▲                                   │
     │        comp climbs again      │                                   │
     │        ("unfire")             └───────────────────────────────────┤
     │                                                                   │
     └──── time runs out (τ > ⌈θ⌉) or momentum flips ◀── ACTIVE while ───┘
                                                         neither happens

Structs§

ClockSeries
Everything the clock knows at one bar.

Constants§

THETA_WINDOW
Window used to learn “how long does a squeeze usually last here?”.

Functions§

group_c
Group C lexical code from (effective highest tier, current tier): 1=*** 2=**. 3=*.. 4=... 5=** 6=*. 7=.. 8=* 9=. 0=none.
run_clock
Run the paper’s state machine over a whole compression series.