Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/CMO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Chande Momentum Oscillator (CMO)

The Chande Momentum Oscillator (CMO) is a momentum indicator that measures the difference between the sum of recent gains and losses over a specified period.

## Formula
CMO = 100 × (Sum of Gains − Sum of Losses) / (Sum of Gains + Sum of Losses)
- Gains: sum of positive changes over period
- Losses: sum of absolute value of negative changes over period

## Parameters
- `period` (default: 14): Period for calculation

## Usage Example
```ts
import { CMO } from '../src/cmo';

const cmo = new CMO();
const result = cmo.nextValue(close);
// result: CMO value
```

## Returns
A single number: the CMO value for the current input.
27 changes: 27 additions & 0 deletions docs/DMI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Directional Movement Index (DMI)

The Directional Movement Index (DMI) is a trend indicator that consists of two lines: +DI and -DI. Optionally, the Average Directional Index (ADX) can be included to measure trend strength.

## Lines
- **+DI:** Smoothed positive directional movement
- **-DI:** Smoothed negative directional movement
- **ADX (optional):** Average Directional Index, measures trend strength

## Parameters
- `period` (default: 14): Period for smoothing
- `withADX` (default: false): Whether to calculate ADX as well

## Usage Example
```ts
import { DMI } from '../src/dmi';

const dmi = new DMI();
const result = dmi.nextValue(high, low, close);
// result: { plusDI, minusDI } or { plusDI, minusDI, adx }
```

## Returns
An object with the following properties:
- `plusDI`: Positive Directional Indicator (+DI)
- `minusDI`: Negative Directional Indicator (-DI)
- `adx`: Average Directional Index (if withADX is true)
22 changes: 22 additions & 0 deletions docs/DPO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Detrended Price Oscillator (DPO)

The Detrended Price Oscillator (DPO) is used to eliminate the long-term trends in prices by comparing the price to a shifted moving average.

## Formula
DPO = Price − SMA(shifted)
- The SMA is shifted back by (period / 2 + 1) bars

## Parameters
- `period` (default: 20): Period for SMA

## Usage Example
```ts
import { DPO } from '../src/dpo';

const dpo = new DPO();
const result = dpo.nextValue(close);
// result: DPO value
```

## Returns
A single number: the DPO value for the current input.
24 changes: 24 additions & 0 deletions docs/ElderRay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Elder Ray Index (Bull Power / Bear Power)

The Elder Ray Index is a trend-following indicator that measures the strength of bulls and bears in the market.

## Formula
- Bull Power = High − EMA
- Bear Power = Low − EMA

## Parameters
- `period` (default: 13): Period for EMA

## Usage Example
```ts
import { ElderRay } from '../src/elder-ray';

const elderRay = new ElderRay();
const result = elderRay.nextValue(high, low, close);
// result: { bull, bear }
```

## Returns
An object with the following properties:
- `bull`: Bull Power value
- `bear`: Bear Power value
27 changes: 27 additions & 0 deletions docs/Envelopes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Moving Average Envelopes

Moving Average Envelopes are lines plotted at a fixed percentage above and below a moving average (usually SMA). They help identify overbought and oversold conditions, as well as trend direction.

## Lines
- **Upper Envelope:** SMA + (SMA * percent / 100)
- **Middle Line:** Simple Moving Average (SMA)
- **Lower Envelope:** SMA - (SMA * percent / 100)

## Parameters
- `period` (default: 20): Period for the moving average
- `percent` (default: 2): Envelope distance in percent

## Usage Example
```ts
import { Envelopes } from '../src/envelopes';

const envelopes = new Envelopes();
const result = envelopes.nextValue(close);
// result: { lower, middle, upper }
```

## Returns
An object with the following properties:
- `lower`: Lower envelope value
- `middle`: Middle line (SMA) value
- `upper`: Upper envelope value
21 changes: 21 additions & 0 deletions docs/ForceIndex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Force Index

The Force Index is a volume-based oscillator that measures the strength of bulls and bears by combining price and volume.

## Formula
Force Index = (Current Close − Previous Close) × Volume

## Parameters
- None (uses raw calculation)

## Usage Example
```ts
import { ForceIndex } from '../src/force-index';

const fi = new ForceIndex();
const result = fi.nextValue(close, volume);
// result: Force Index value
```

## Returns
A single number: the Force Index value for the current input.
25 changes: 25 additions & 0 deletions docs/Fractal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Fractal Indicator (Bill Williams Fractals)

The Fractal Indicator identifies local highs and lows (fractals) in price data.

## Definition
- A fractal up is a high that is higher than two bars to the left and right.
- A fractal down is a low that is lower than two bars to the left and right.

## Parameters
- `left` (default: 2): Number of bars to the left
- `right` (default: 2): Number of bars to the right

## Usage Example
```ts
import { Fractal } from '../src/fractal';

const fractal = new Fractal();
const result = fractal.nextValue(high, low);
// result: { up, down }
```

## Returns
An object with the following properties:
- `up`: Fractal up value (if found)
- `down`: Fractal down value (if found)
33 changes: 33 additions & 0 deletions docs/IchimokuCloud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Ichimoku Cloud (Ichimoku Kinko Hyo)

Ichimoku Cloud is a comprehensive indicator that defines support and resistance, identifies trend direction, gauges momentum, and provides trading signals.

## Lines
- **Tenkan-sen (Conversion Line):** (highest high + lowest low) / 2 for the last 9 periods (default)
- **Kijun-sen (Base Line):** (highest high + lowest low) / 2 for the last 26 periods (default)
- **Senkou Span A (Leading Span A):** (Tenkan-sen + Kijun-sen) / 2, plotted 26 periods ahead
- **Senkou Span B (Leading Span B):** (highest high + lowest low) / 2 for the last 52 periods (default), plotted 26 periods ahead
- **Chikou Span (Lagging Span):** Closing price, plotted 26 periods back

## Parameters
- `periodTenkan` (default: 9): Period for Tenkan-sen
- `periodKijun` (default: 26): Period for Kijun-sen
- `periodSenkouB` (default: 52): Period for Senkou Span B
- `displacement` (default: 26): Displacement for Senkou and Chikou lines

## Usage Example
```ts
import { Ichimoku } from '../src/ichimoku';

const ichimoku = new Ichimoku();
const result = ichimoku.nextValue(high, low, close);
// result: { tenkan, kijun, senkouA, senkouB, chikou }
```

## Returns
An object with the following properties:
- `tenkan`: Tenkan-sen value
- `kijun`: Kijun-sen value
- `senkouA`: Senkou Span A value (current, forward shift is handled on chart)
- `senkouB`: Senkou Span B value (current, forward shift is handled on chart)
- `chikou`: Chikou Span value (close, shifted backward)
27 changes: 27 additions & 0 deletions docs/KeltnerChannel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Keltner Channel

Keltner Channel is a volatility-based envelope set above and below an exponential moving average (EMA). The channel uses the Average True Range (ATR) to set the distance of the bands.

## Lines
- **Upper Band:** EMA + (ATR * multiplier)
- **Middle Band:** Exponential Moving Average (EMA)
- **Lower Band:** EMA - (ATR * multiplier)

## Parameters
- `period` (default: 20): Period for EMA and ATR
- `multiplier` (default: 2): ATR multiplier for channel width

## Usage Example
```ts
import { KeltnerChannel } from '../src/keltner';

const keltner = new KeltnerChannel();
const result = keltner.nextValue(high, low, close);
// result: { lower, middle, upper }
```

## Returns
An object with the following properties:
- `lower`: Lower band value
- `middle`: Middle band (EMA) value
- `upper`: Upper band value
24 changes: 24 additions & 0 deletions docs/TEMA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Triple Exponential Moving Average (TEMA)

TEMA is a moving average that reduces lag by combining a single, double, and triple EMA. It is more responsive to price changes than a traditional EMA.

## Formula
TEMA = 3 × EMA1 − 3 × EMA2 + EMA3
- EMA1 = EMA of price
- EMA2 = EMA of EMA1
- EMA3 = EMA of EMA2

## Parameters
- `period` (default: 20): Period for all EMAs

## Usage Example
```ts
import { TEMA } from '../src/tema';

const tema = new TEMA();
const result = tema.nextValue(close);
// result: TEMA value
```

## Returns
A single number: the TEMA value for the current input.
22 changes: 22 additions & 0 deletions docs/TRIX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# TRIX (Triple Exponential Average Oscillator)

TRIX is a momentum oscillator that displays the percent rate of change of a triple exponentially smoothed moving average. It is used to identify oversold and overbought markets, as well as momentum.

## Formula
TRIX = [(TEMA - previous TEMA) / previous TEMA] × 100
- TEMA is the triple EMA of price

## Parameters
- `period` (default: 15): Period for all EMAs

## Usage Example
```ts
import { TRIX } from '../src/trix';

const trix = new TRIX();
const result = trix.nextValue(close);
// result: TRIX value
```

## Returns
A single number: the TRIX value for the current input.
26 changes: 26 additions & 0 deletions docs/UltimateOscillator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Ultimate Oscillator

The Ultimate Oscillator is a momentum oscillator that combines short, intermediate, and long-term price action into one value.

## Formula
UO = 100 × (4 × avg7 + 2 × avg14 + avg28) / (4 + 2 + 1)
- avgN = sum(BP, N) / sum(TR, N)
- BP = Close − min(Low, PrevClose)
- TR = max(High, PrevClose) − min(Low, PrevClose)

## Parameters
- `period1` (default: 7): Short period
- `period2` (default: 14): Medium period
- `period3` (default: 28): Long period

## Usage Example
```ts
import { UltimateOscillator } from '../src/ultimate-oscillator';

const uo = new UltimateOscillator();
const result = uo.nextValue(high, low, close);
// result: Ultimate Oscillator value
```

## Returns
A single number: the Ultimate Oscillator value for the current input.
22 changes: 22 additions & 0 deletions docs/VolumeOscillator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Volume Oscillator

The Volume Oscillator measures the difference between two moving averages of volume.

## Formula
Volume Oscillator = SMA(short) − SMA(long)

## Parameters
- `shortPeriod` (default: 14): Short period for SMA
- `longPeriod` (default: 28): Long period for SMA

## Usage Example
```ts
import { VolumeOscillator } from '../src/volume-oscillator';

const vo = new VolumeOscillator();
const result = vo.nextValue(volume);
// result: Volume Oscillator value
```

## Returns
A single number: the Volume Oscillator value for the current input.
13 changes: 13 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,17 @@ export { Sampler } from './src/providers/sampler';
export { VolumeProfile } from './src/volume-profile'; /** BETA UNSTABLE */
export { ChaikinOscillator } from './src/chaikin';
export { AMA } from './src/ama';
export { Ichimoku } from './src/ichimoku';
export { Envelopes } from './src/envelopes';
export { KeltnerChannel } from './src/keltner';
export { DMI } from './src/dmi';
export { TEMA } from './src/tema';
export { TRIX } from './src/trix';
export { CMO } from './src/cmo';
export { DPO } from './src/dpo';
// export { OrderBlock } from './src/order-block';
export { UltimateOscillator } from './src/ultimate-oscillator';
export { ElderRay } from './src/elder-ray';
export { ForceIndex } from './src/force-index';
export { Fractal } from './src/fractal';
export { VolumeOscillator } from './src/volume-oscillator';
Loading