Fibonacci Retracement and Extension Projection
Install and import#
npm install fintech-algorithmsimport { 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#
| Name | Type | Notes |
|---|---|---|
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#
{
"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#
Calculation flow#
Fibonacci Retracement and Extension Projection calculation flow
flowchart LR
S1["Validate distinct leg anchors and positive tick size"]
S2["Resolve leg direction and absolute magnitude"]
S3["Project each declared retracement from B"]
S4["Project each declared extension from C"]
S5["Snap raw prices half away from zero and retain both va"]
S1 --> S2
S2 --> S3
S3 --> S4
S4 --> S5
S5 --> D{"raw projected prices are snapped to the nearest declared i"}
D --> O["retracement_levels + diagnostics"]
O --> A["Audit: The output is a deterministic function of validated inputs"]
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.
References#
- Auto Fib Retracement — TradingView
- Trend-based Fib Extension drawing tool — TradingView
- Foundations of Technical Analysis: Computational Algorithms, Statistical Inference, and Empirical Implementation — Andrew W. Lo, Harry Mamaysky, and Jiang Wang
- Evidence boundary