fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Force Index

Install and import#

bash
npm install fintech-algorithms
ts
import { forceIndex } from "fintech-algorithms/technical-indicators/volume-indicators/force-index";

Signature#

forceIndex(close, volume, p)

Price change multiplied by volume, then smoothed. Combines direction, size and participation in one number — a large move on no volume scores low.

Parameters#

NameTypeNotes
closenumber[]Per-bar closing prices, chronological.
volumenumber[]Per-bar traded volume, aligned index-for-index with the price series.
pnumberEMA span applied to the raw force series.
min: 1 · integer: true

Returns#

Record<string, (number | null)[]> · length same-as-input

Parallel series: change, volume, raw_force, ema_seed and the smoothed force_index.

Warm-up#

The first p positions are null. One bar for the price change, then the EMA seed window.

Errors#

  • When p < 1 or is not an integer — throws RangeError
  • When the input series are not all the same length — throws RangeError

Complexity: time O(n), space O(n).

Worked example#

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input#

close
[100.28, 100.686113, 101.200346, 101.789282, 102.408843, 103.010585]

Showing 6 of 120 elements.

volume
[990000, 1066468.036, 1130033.236, 1170141.961, 1180511.26, 1160272.794]

Showing 6 of 120 elements.

Call#

forceIndex(close, volume, p)

Returns#

object with 5 fields: change, volume, raw_force, ema_seed, force_index

{
  "change": [
    null,
    0.40611300000000483,
    0.5142329999999902,
    0.5889360000000039,
    0.6195610000000045,
    0.6017420000000016
  ],
  "volume": [990000, 1066468.036, 1130033.236, 1170141.961, 1180511.26, 1160272.794],
  "raw_force": [
    null,
    433106.53350407316,
    581100.3810479769,
    689138.7259435005,
    731398.7367568653,
    698184.8716071498
  ],
  "ema_seed": [null, null, null, null, null, null],
  "force_index": [null, null, null, null, null, null]
}

Other exports#

This module also exports obv, accumulationDistributionLine, chaikinMoneyFlow, moneyFlowIndex, volumePriceTrend. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams#

Force Index — force index comparison
Force Index — force index mechanism

Calculation flow#

Calculation flow
flowchart LR
  A["Finalized finalized close and nonnegative volume"] --> B["Validate order, alignment, and finite values"]
  B --> C["Close change"]
  C --> D["Raw price-volume force"]
  D --> E["EMA seed / update"]
  E --> F{"History and denominator valid?"}
  F -- "No · short history" --> G["warming-up + reason"]
  F -- "No · no finite scale" --> H["undefined + reason"]
  F -- "Yes" --> I["Smoothed Force Index"]
  I --> J["ready + aligned component trace"]
Data-basis reconciliation — Force Index
flowchart LR
    A["Same instrument and identifier?"] -->|Yes| B["Same venue or consolidated scope?"]
    A -->|No| X["Stop: different measurement"]
    B -->|Yes| C["Same volume unit and bar interval?"]
    B -->|No| X
    C -->|Yes| D["Same session and close policy?"]
    C -->|No| X
    D -->|Yes| E["Same corrections and price-volume adjustment basis?"]
    D -->|No| X
    E -->|Yes| F["Same Force Index convention, seed, warm-up, and precision?"]
    E -->|No| X
    F -->|Yes| G["Compare intermediate components"]
    F -->|No| Y["Document convention difference"]
    G --> H["Compare final output"]

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

  • Elder's Force Index (EFI) — TradingView
  • Volume — TradingView
  • Consolidated Tape — U.S. Securities and Exchange Commission, Investor.gov
  • Closing Price — U.S. Securities and Exchange Commission, Investor.gov
  • What is Volume? — CME Group
  • Claim-role ledger
  • Evidence boundary
  • Enhanced claim-to-source map
  • Public evidence boundary

The rest of the Volume Indicators family#