# Stochastic oscillator

`stoch`

Where the close sits in the recent high to low range, with a signal line.

## Inputs

| Name | Type | Default | Range |
| --- | --- | --- | --- |
| k_period | int | 5 | 1 to 5000 |
| d_period | int | 3 | 1 to 5000 |
| slowing | int | 3 | 1 to 5000 |
| basis | choice | high_low |  |

## Outputs

| Name | Kind |
| --- | --- |
| k | value |
| d | value |

Warm-up: k_period + slowing + d_period - 3 bars (8 at the defaults).

Repaints: No.

## Formula

The highest high and lowest low over K period (the highest and lowest close with close_close)

%K = 100 * sum(close - lowest, slowing) / sum(highest - lowest, slowing)

%D = the simple average of %K over D period

A window with no range reads 50.
