> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meridiandata.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Imbalance bars

> Adaptive Lopez de Prado-style tick imbalance bars with continuous state.

Meridian's imbalance bars use signed price-tick direction and an adaptive threshold.

## Tick direction

For each aggTrade price:

```text theme={null}
price increased  → +1
price decreased  → -1
price unchanged  → carry the previous non-zero direction
```

The processor maintains an exponentially weighted average of tick signs:

```text theme={null}
alpha = 2 / (expected_ticks_per_bar + 1)
ema_tick_signs = alpha × tick + (1 - alpha) × previous_ema
```

## Adaptive close threshold

After the warmup period, each signed tick is added to cumulative imbalance. The current threshold is:

```text theme={null}
dynamic_threshold = max(
  expected_ticks_per_bar × abs(ema_tick_signs),
  expected_ticks_per_bar × min_threshold_fraction
)
```

The bar closes when:

```text theme={null}
abs(cumulative_imbalance) >= dynamic_threshold
```

## Parameters

| Parameter                | Meaning                                                 |
| ------------------------ | ------------------------------------------------------- |
| `expected_ticks_per_bar` | Baseline expected bar length and EMA span               |
| `warmup_ticks`           | Initial ticks used to establish directional expectation |
| `min_threshold_fraction` | Lower bound preventing a zero or near-zero threshold    |

Warmup defaults to `expected_ticks_per_bar`. No imbalance bar is emitted during warmup.

## Continuous state

The checkpoint stores the EMA, cumulative imbalance, global tick counter, previous price and direction, pending trades, and emitted sequence. This prevents archive boundaries and process restarts from changing future bars.

<Warning>
  The adaptive threshold is a sampling rule, not a directional forecast. Positive or negative ending imbalance does not by itself constitute a trading signal.
</Warning>
