Support/Resistance Role-Reversal State Machine
Install and import#
npm install fintech-algorithmsimport { supportResistanceRoleReversalStateMachine } from "fintech-algorithms/geometric-chart-patterns/level-confluence-and-zone-scoring/support-resistance-role-reversal-state-machine";Signature#
supportResistanceRoleReversalStateMachine(input)Processes closes through active-role, break, retest, confirmation, and invalidation transitions for one zone.
Parameters#
| Name | Type | Notes |
|---|---|---|
input | { zone_lower: number; zone_upper: number; break_buffer: number; confirmation_closes: number; initial_role: string; closes: number[] } | Record containing zone bounds, break buffer, required confirmation closes, initial role, and non-empty close observations. |
Returns#
{ state, final_role, confirmed, retest_seen, transitions, observations }
One state-machine record with final role, confirmation flag, retest flag, observation count, and transition trace.
Errors#
- When zone bounds, role, confirmation count, buffer, or close observations are invalid — 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#
{
"zone_lower": 99.5,
"zone_upper": 100.5,
"break_buffer": 0.2,
"confirmation_closes": 2,
"initial_role": "support",
"closes": [101, 100.2, 99.2, 99.1, 99.8, 99.1]
}Call#
supportResistanceRoleReversalStateMachine(input)Returns#
object with 6 fields: state, final_role, confirmed, retest_seen, transitions, observations
{
"state": "confirmed-resistance",
"final_role": "resistance",
"confirmed": true,
"retest_seen": true,
"transitions": [
{
"index": 3,
"close": 99.1,
"from": "active-support",
"to": "awaiting-resistance-retest",
"side": "below"
},
{
"index": 5,
"close": 99.1,
"from": "awaiting-resistance-retest",
"to": "confirmed-resistance",
"side": "below"
}
],
"observations": 6
}Other exports#
This module also exports
calculate, priceByVolumeProfileConstruction, pocValueAreaHvnLvnDetection, fibonacciRetracementExtensionProjection, psychologicalRoundNumberLevelGeneration, multiSourceSupportResistanceZoneFusion, supportResistanceZoneStrengthDecayScoring, 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#
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#
- Foundations of Technical Analysis: Computational Algorithms, Statistical Inference, and Empirical Implementation — Andrew W. Lo, Harry Mamaysky, and Jiang Wang
- Currency Orders and Exchange-Rate Dynamics: Explaining the Success of Technical Analysis — Carol L. Osler
- Volume profile indicators: basic concepts — TradingView
- Evidence boundary