# Liquidity

`liquidity`

Equal highs and lows (EQH, EQL), resting liquidity above swing highs and below swing lows, and the sweeps that take it.

## Inputs

| Name | Type | Default | Range |
| --- | --- | --- | --- |
| confirm_bars | int | 3 | 1 to 50 |
| margin_atr | float | 0.1 | 0 to 5 |
| atr_period | int | 10 | 1 to 500 |

## Outputs

| Name | Kind |
| --- | --- |
| eqh | value |
| eql | value |
| sweep_high | event |
| sweep_low | event |
| buyside | value |
| sellside | value |

Warm-up: 2 * confirm_bars bars (6 at the defaults).

Repaints: Yes.

## Formula

A swing high is a bar whose high is above every high within confirm_bars bars on each side; it is known confirm_bars bars later, and values are written then. Swing lows mirror it.

EQH marks a swing high within margin_atr times the ATR of the previous swing high. The ATR is Wilder's average true range over atr_period bars. EQL mirrors it.

Every swing high leaves buyside liquidity at its price, and every swing low sellside liquidity. When a bar trades above a buyside level it is taken; if the bar closes back below it, that is a sweep (sweep_high). Sellside mirrors it (sweep_low).

buyside is the nearest untaken buyside level above price and sellside the nearest untaken sellside level below it. Forge keeps the fifty newest levels per side. A missing bar starts again.
