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

Support/Resistance Role-Reversal State Machine

Install and import#

bash
npm install fintech-algorithms
ts
import { 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#

NameTypeNotes
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#

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#

Support/Resistance Role-Reversal State Machine — 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#