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

Fibonacci Retracement and Extension Projection

Install and import#

bash
npm install fintech-algorithms
ts
import { fibonacciRetracementExtensionProjection } from "fintech-algorithms/geometric-chart-patterns/level-confluence-and-zone-scoring/fibonacci-retracement-extension-projection";

Signature#

fibonacciRetracementExtensionProjection(input)

Projects declared retracement and extension ratios from a directed price leg and snaps every level to the nearest tick.

Parameters#

NameTypeNotes
input{ start_price: number; end_price: number; retracement_end_price: number; tick_size: number; retracement_ratios: number[]; extension_ratios: number[] }Record containing leg anchors, retracement-end anchor, tick size, and non-empty retracement and extension ratio lists.

Returns#

{ state, direction, leg_size, retracement_levels, extension_levels, rounding }

One calculated projection record; each level reports its ratio, raw price, and tick-snapped price.

Errors#

  • When anchors coincide, tick size is invalid, ratios are empty, or ratios fall outside allowed ranges — throws

Complexity: time , space .

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#

input
{
  "start_price": 100,
  "end_price": 120,
  "retracement_end_price": 112,
  "tick_size": 0.1,
  "retracement_ratios": [0.236, 0.382, 0.5, 0.618, 0.786],
  "extension_ratios": [1, 1.272, 1.618, 2]
}

Call#

fibonacciRetracementExtensionProjection(input)

Returns#

object with 6 fields: state, direction, leg_size, retracement_levels, extension_levels, rounding

{
  "state": "calculated",
  "direction": "up",
  "leg_size": 20,
  "retracement_levels": [
    {
      "ratio": 0.236,
      "raw_price": 115.28,
      "price": 115.3
    },
    {
      "ratio": 0.382,
      "raw_price": 112.36,
      "price": 112.4
    },
    {
      "ratio": 0.5,
      "raw_price": 110,
      "price": 110
    }
  ],
  "extension_levels": [
    {
      "ratio": 1,
      "raw_price": 132,
      "price": 132
    },
    {
      "ratio": 1.272,
      "raw_price": 137.44,
      "price": 137.4
    },
    {
      "ratio": 1.618,
      "raw_price": 144.36,
      "price": 144.4
    }
  ],
  "rounding": "nearest tick, half away from zero"
}

Other exports#

This module also exports calculate, priceByVolumeProfileConstruction, pocValueAreaHvnLvnDetection, psychologicalRoundNumberLevelGeneration, multiSourceSupportResistanceZoneFusion, supportResistanceZoneStrengthDecayScoring, supportResistanceRoleReversalStateMachine, breakoutAndRetestDetection, marketWideZoneProximityScannerRanking. 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#

Fibonacci Retracement and Extension Projection — system map

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#

The rest of the Level Confluence and Zone Scoring family#