# Smart money concepts reference

> All 7 smart money concepts in AlgoBarsX, each with its parameters, defaults, ranges and an example: order_blocks, fair_value_gaps, break_of_structure, change_of_character, liquidity_sweeps, premium_discount, optimal_trade_entry.

Source: https://algobarsx.com/docs/ref-fn-smart-money/

### `order_blocks(length = 50, new_only = false, on = bars())` → list<Zone>

Order blocks as zones with price bounds, formation time and status.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `length` | int | `50` | 1 to 5000 | Bars to scan. |
| `new_only` | bool | `false` |  | Only blocks that formed on this bar. |
| `on` | BarSet | `bars()` |  | Bars to calculate on; defaults to the script's own bars. |

```algobarsx
blocks = order_blocks(50, new_only: true)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `fair_value_gaps(length = 50, min_size = 0, new_only = false, on = bars())` → list<Zone>

Fair value gaps as zones.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `length` | int | `50` | 1 to 5000 | Bars to scan. |
| `min_size` | price | `0` |  | Smallest gap to include. |
| `new_only` | bool | `false` |  | Only gaps that formed on this bar. |
| `on` | BarSet | `bars()` |  | Bars to calculate on; defaults to the script's own bars. |

```algobarsx
gaps = fair_value_gaps(50, min_size: 0)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `break_of_structure(direction = both, swing_length = 5, on = bars())` → series<bool>

True on the bar structure breaks.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `direction` | string | `both` |  | up, down or both. |
| `swing_length` | int | `5` | 1 to 100 | Swing size in bars. |
| `on` | BarSet | `bars()` |  | Bars to calculate on; defaults to the script's own bars. |

```algobarsx
bos = break_of_structure(direction: up)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `change_of_character(direction = both, swing_length = 5, on = bars())` → series<bool>

True on the bar character changes.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `direction` | string | `both` |  | up, down or both. |
| `swing_length` | int | `5` | 1 to 100 | Swing size in bars. |
| `on` | BarSet | `bars()` |  | Bars to calculate on; defaults to the script's own bars. |

```algobarsx
choch = change_of_character(direction: down)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `liquidity_sweeps(length = 20, on = bars())` → series<bool>

True on the bar a prior high or low is swept and rejected.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `length` | int | `20` | 1 to 5000 | Number of bars in the calculation. |
| `on` | BarSet | `bars()` |  | Bars to calculate on; defaults to the script's own bars. |

```algobarsx
swept = liquidity_sweeps(20)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `premium_discount(length = 50, on = bars())` → PremiumDiscount

Premium, equilibrium and discount zones of the recent range.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `length` | int | `50` | 1 to 5000 | Number of bars in the calculation. |
| `on` | BarSet | `bars()` |  | Bars to calculate on; defaults to the script's own bars. |

#### Outputs, read with a dot

| Name | Type | What it is |
| --- | --- | --- |
| `premium` | Zone | Top of range. |
| `equilibrium` | series<price> | Midpoint. |
| `discount` | Zone | Bottom of range. |

```algobarsx
pd = premium_discount(50)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `optimal_trade_entry(swing_length = 5, low = 62%, high = 79%, on = bars())` → Zone

Optimal trade entry zone of the latest swing.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `swing_length` | int | `5` | 1 to 100 | Swing size in bars. |
| `low` | percent | `62%` |  | Shallow retracement. |
| `high` | percent | `79%` |  | Deep retracement. |
| `on` | BarSet | `bars()` |  | Bars to calculate on; defaults to the script's own bars. |

```algobarsx
ote = optimal_trade_entry(swing_length: 5)
```

Works in: strategy, indicator, alert, library. Since 1.0.
