Support/Resistance Pattern Context
Install and import#
npm install fintech-algorithmsimport { supportResistanceContext } from "fintech-algorithms/price-action-and-candlesticks/candlestick-scanning-and-context/support-resistance-pattern-context";Signature#
supportResistanceContext(data)select the nearest causally confirmed directional level and turn ATR-normalized distance into a transparent [0,1] context feature.
Parameters#
| Name | Type | Notes |
|---|---|---|
data | { pattern_price: number; atr: number; direction: string; occurrence_index: number; max_distance_atr: number; levels: { price: number; kind: string; strength: number; confirmed_index: number }[] } | Topic input record; the required fields are fixed by this topic data-contract. |
Returns#
{ state, context_score, matched_level, target_kind?, distance_atr? }
One directional context record. state is ready, no-causal-level, or unsupported-direction; score and distance are present only when their evidence exists.
Complexity: time O(n log n) worst case; see README for topic-specific n,
space O(n).
Worked example#
verified This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.
Input#
{
"pattern_price": 100,
"atr": 2,
"direction": "bullish",
"occurrence_index": 10,
"max_distance_atr": 2,
"levels": [
{
"price": 99,
"kind": "support",
"strength": 0.8,
"confirmed_index": 9
},
{
"price": 101,
"kind": "resistance",
"strength": 0.9,
"confirmed_index": 8
},
{
"price": 100.2,
"kind": "support",
"strength": 1,
"confirmed_index": 11
}
]
}Call#
supportResistanceContext(data)Returns#
object with 4 fields: state, target_kind, distance_atr, context_score
{
"state": "ready",
"target_kind": "support",
"distance_atr": 0.5,
"context_score": 0.75
}Diagrams#
Calculation flow#
Decision flow
flowchart LR
A["Validated point-in-time input"] --> B["Choose direction-relevant level kind"]
B --> C["Remove future-confirmed levels"]
C --> D{"Boundary satisfied?"}
D -->|"Yes"| E["Reason-coded ready output"]
D -->|"No"| F["Explicit rejected or unavailable state"]
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#
- TA-Lib function catalog and pattern-recognition group — TA-Lib project
- TA-Lib C/C++ Core API — TA-Lib project
- Binance Spot kline/candlestick stream — Binance
- CME Group chart types and support/resistance lessons — CME Group
- Foundations of Technical Analysis — Andrew W. Lo, Harry Mamaysky, and Jiang Wang
- Evidence and licensing boundary