# Momentum reference

> All 15 momentum in AlgoBarsX, each with its parameters, defaults, ranges and an example: rsi, stoch, stoch_rsi, macd, cci, williams_r, roc, momentum, tsi, ultimate_osc and 5 more.

Source: https://algobarsx.com/docs/ref-fn-momentum/

### `rsi(source = close, length = 14)` → series<number>

Relative strength index, from 0 to 100.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `source` | series<number> | `close` |  | Series to calculate from. |
| `length` | int | `14` | 1 to 5000 | Number of bars in the calculation. |

**Formula** Wilder's smoothing (rma) of gains and losses.

**Warm-up** length + 1 bars

```algobarsx
r = rsi(close, 14)
```

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

### `stoch(k_length = 14, k_smoothing = 3, d_smoothing = 3, on = bars())` → Stoch

Stochastic oscillator.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `k_length` | int | `14` | 1 to 5000 | %K lookback. |
| `k_smoothing` | int | `3` | 1 to 500 | %K smoothing. |
| `d_smoothing` | int | `3` | 1 to 500 | %D smoothing. |
| `on` | BarSet | `bars()` |  | Bars to calculate on; defaults to the script's own bars. |

#### Outputs, read with a dot

| Name | Type | What it is |
| --- | --- | --- |
| `k` | series<number> | %K. |
| `d` | series<number> | %D. |

```algobarsx
s = stoch(14, 3, 3)
```

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

### `stoch_rsi(source = close, rsi_length = 14, stoch_length = 14, k = 3, d = 3)` → Stoch

Stochastic RSI.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `source` | series<number> | `close` |  | Series to calculate from. |
| `rsi_length` | int | `14` | 1 to 5000 | RSI length. |
| `stoch_length` | int | `14` | 1 to 5000 | Stochastic length. |
| `k` | int | `3` | 1 to 500 | %K smoothing. |
| `d` | int | `3` | 1 to 500 | %D smoothing. |

#### Outputs, read with a dot

| Name | Type | What it is |
| --- | --- | --- |
| `k` | series<number> | %K. |
| `d` | series<number> | %D. |

```algobarsx
srsi = stoch_rsi(close, 14, 14, 3, 3)
```

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

### `macd(source = close, fast = 12, slow = 26, signal = 9)` → Macd

Moving average convergence divergence.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `source` | series<number> | `close` |  | Series to calculate from. |
| `fast` | int | `12` | 1 to 5000 | Fast EMA length. |
| `slow` | int | `26` | 1 to 5000 | Slow EMA length. |
| `signal` | int | `9` | 1 to 5000 | Signal EMA length. |

#### Outputs, read with a dot

| Name | Type | What it is |
| --- | --- | --- |
| `macd` | series<number> | MACD line. |
| `signal` | series<number> | Signal line. |
| `histogram` | series<number> | MACD minus signal. |

```algobarsx
m = macd(close, 12, 26, 9)
```

```algobarsx
rising = macd(close).histogram > 0
```

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

### `cci(source = hlc3, length = 20)` → series<number>

Commodity channel index.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `source` | series<number> | `hlc3` |  | Series to calculate from. |
| `length` | int | `20` | 1 to 5000 | Number of bars in the calculation. |

```algobarsx
c = cci(hlc3, 20)
```

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

### `williams_r(length = 14, on = bars())` → series<number>

Williams %R.

#### Parameters

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

```algobarsx
wr = williams_r(14)
```

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

### `roc(source = close, length = 9)` → series<number>

Rate of change in percent.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `source` | series<number> | `close` |  | Series to calculate from. |
| `length` | int | `9` | 1 to 5000 | Number of bars in the calculation. |

```algobarsx
change = roc(close, 9)
```

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

### `momentum(source = close, length = 10)` → distance of source

Difference from the value length bars ago.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `source` | series<number> | `close` |  | Series to calculate from. |
| `length` | int | `10` | 1 to 5000 | Number of bars in the calculation. |

```algobarsx
mom = momentum(close, 10)
```

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

### `tsi(source = close, long = 25, short = 13, signal = 13)` → Tsi

True strength index.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `source` | series<number> | `close` |  | Series to calculate from. |
| `long` | int | `25` | 1 to 5000 | Long smoothing. |
| `short` | int | `13` | 1 to 5000 | Short smoothing. |
| `signal` | int | `13` | 1 to 5000 | Signal length. |

#### Outputs, read with a dot

| Name | Type | What it is |
| --- | --- | --- |
| `tsi` | series<number> | TSI line. |
| `signal` | series<number> | Signal line. |

```algobarsx
t = tsi(close, 25, 13, 13)
```

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

### `ultimate_osc(fast = 7, middle = 14, slow = 28, on = bars())` → series<number>

Ultimate oscillator.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `fast` | int | `7` | 1 to 5000 | Fast length. |
| `middle` | int | `14` | 1 to 5000 | Middle length. |
| `slow` | int | `28` | 1 to 5000 | Slow length. |
| `on` | BarSet | `bars()` |  | Bars to calculate on; defaults to the script's own bars. |

```algobarsx
uo = ultimate_osc(7, 14, 28)
```

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

### `awesome_osc(fast = 5, slow = 34, on = bars())` → series<number>

Awesome oscillator.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `fast` | int | `5` | 1 to 5000 | Fast length. |
| `slow` | int | `34` | 1 to 5000 | Slow length. |
| `on` | BarSet | `bars()` |  | Bars to calculate on; defaults to the script's own bars. |

```algobarsx
ao = awesome_osc(5, 34)
```

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

### `ppo(source = close, fast = 12, slow = 26, signal = 9)` → Macd

Percentage price oscillator.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `source` | series<number> | `close` |  | Series to calculate from. |
| `fast` | int | `12` | 1 to 5000 | Fast EMA length. |
| `slow` | int | `26` | 1 to 5000 | Slow EMA length. |
| `signal` | int | `9` | 1 to 5000 | Signal EMA length. |

#### Outputs, read with a dot

| Name | Type | What it is |
| --- | --- | --- |
| `macd` | series<number> | PPO line. |
| `signal` | series<number> | Signal line. |
| `histogram` | series<number> | PPO minus signal. |

```algobarsx
pp = ppo(close, 12, 26, 9)
```

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

### `cmo(source = close, length = 9)` → series<number>

Chande momentum oscillator.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `source` | series<number> | `close` |  | Series to calculate from. |
| `length` | int | `9` | 1 to 5000 | Number of bars in the calculation. |

```algobarsx
chande = cmo(close, 9)
```

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

### `trix(source = close, length = 18)` → series<number>

Triple-smoothed EMA rate of change.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `source` | series<number> | `close` |  | Series to calculate from. |
| `length` | int | `18` | 1 to 5000 | Number of bars in the calculation. |

```algobarsx
tx = trix(close, 18)
```

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

### `mfi(length = 14, on = bars())` → series<number>

Money flow index.

#### Parameters

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

```algobarsx
flow_index = mfi(14)
```

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