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

Market Structure, Breakouts, and Regimes

18 algorithms in Geometric Chart Patterns · 18 with asserted arithmetic.

In this family#

  1. Highest-High and Lowest-Low Primitives verified

    The two rolling extremes every breakout rule is built on: the highest high and lowest low over a window of period bars ending at, and including, the current bar.

    highestHighAndLowestLowPrimitives(input)
  2. Single-Asset New-High/New-Low Signal verified

    Flags whether a single instrument's close has cleared the highest high or undercut the lowest low of the preceding period bars. The channel excludes the current bar, so the comparison is against a level that was already known.

    singleAssetNewHighNewLowSignal(input)
  3. Breakout Strength verified

    Expresses how far a close sits beyond its Donchian channel in units of ATR, so a two-tick break in a quiet market and a two-tick break in a violent one do not score the same. Values are negative while price is inside the channel.

    breakoutStrength(input)
  4. Donchian Breakout verified

    The Donchian channel over the preceding period bars plus the two breakout booleans it implies. This shares a byte-identical implementation with the single-asset new-high/new-low signal.

    donchianBreakout(input)
  5. Opening Range Breakout verified

    Fixes the high and low of the session's first opening_bars bars and then tests every later close against that frozen range. Unlike the rolling breakout topics the level never moves once the opening range is set.

    openingRangeBreakout(input)
  6. Price Compression Index verified

    Compares short-horizon volatility to long-horizon volatility as 100 × ATR(short_period) / ATR(long_period). Readings well under 100 mark a market whose recent ranges have compressed against its own baseline.

    priceCompressionIndex(input)
  7. Range Expansion Index verified

    Scores directional conviction as the signed sum of close-to-close changes over period bars divided by the sum of their absolute values, scaled to ±100. It is the net move as a percentage of the distance actually travelled.

    rangeExpansionIndex(input)
  8. Fractal Dimension Index verified

    Compares the total path length walked by close over a window against the straight-line span of that window, on a log scale, and clamps the result to [1, 2]. Near 1 the path is a line; near 2 it fills the range.

    fractalDimensionIndex(input)
  9. Hurst Exponent verified

    A rolling rescaled-range estimate: over each window of period closes it takes the range of the mean-adjusted cumulative sum, divides by the window's standard deviation, and reports log(R/S) / log(period).

    hurstExponent(input)
  10. Efficiency Ratio verified

    Kaufman's ratio of net displacement to gross travel: the absolute change in close over period bars divided by the sum of the absolute bar-to-bar changes across the same span. Near 1 the market went somewhere; near 0 it churned.

    efficiencyRatio(input)
  11. Market Meanness Index verified

    Counts how often close crosses the median of its own period-bar window and reports that as a percentage of the period - 1 opportunities. High readings mean the series keeps returning to its centre.

    marketMeannessIndex(input)
  12. Trend/Range Regime Classifier verified

    Labels each bar trend, range or uncertain by requiring two independent readings to agree: efficiency ratio at or above 0.55 with Choppiness at or below 45 gives trend, efficiency at or below 0.25 with Choppiness at or above 55 gives range, and anything else is uncertain.

    trendRangeRegimeClassifier(input)
  13. Volatility Regime Classifier verified

    Computes realized volatility as the standard deviation of simple close returns over period bars, then ranks each reading against the last rank_period of them: bottom quartile is low, top quartile is high, everything between is normal.

    volatilityRegimeClassifier(input)
  14. Directional Persistence verified

    Maps each bar to +1, -1 or 0 by the sign of its close-to-close change, sums those signs over period bars, and reports the absolute total divided by period. It measures one-sidedness without caring which side.

    directionalPersistence(input)
  15. Swing Structure Detector verified

    Confirms five-bar swing highs and lows and labels each one against the previous swing of the same kind - HH, LH, HL, LL, or swing-high/swing-low for the first of each. The confirmation is causal: a swing at bar p is only reported at bar p+2.

    swingStructureDetector(input)
  16. Higher-High/Lower-Low Structure verified

    Reduces price to the higher-high / lower-low sequence traders read structure from, labelling each confirmed five-bar swing HH, LH, HL or LL against the previous swing of its kind. It shares a byte-identical state transition with the swing structure detector.

    higherHighLowerLowStructure(input)
  17. Inside/Outside Bar Structure verified

    Classifies each bar against its immediate predecessor as inside (high not above and low not below), outside (high not below and low not above), or neither. A bar that exactly repeats the previous range is classified inside, because that test is evaluated first.

    insideOutsideBarStructure(input)
  18. Market Entropy verified

    Treats each bar as one of three states by the sign of its close change, then reports the Shannon entropy of the state distribution over a period-bar window, normalised by log(3) so a perfectly balanced mix scores 1.

    marketEntropy(input)

What they share#

Every topic here is a record-transform, so once you have called one the rest follow the same shape. Import paths differ only in the final segment:

ts
import { highestHighAndLowestLowPrimitives } from "fintech-algorithms/geometric-chart-patterns/market-structure-breakouts-and-regimes/highest-high-and-lowest-low-primitives";
import { singleAssetNewHighNewLowSignal } from "fintech-algorithms/geometric-chart-patterns/market-structure-breakouts-and-regimes/single-asset-new-high-new-low-signal";

Read them in the order above — the sequence is pedagogical, not alphabetical.

Where this sits#

Geometric Chart Patterns collects 64 algorithms across 7 families. For the concept behind this family rather than the call signatures, see the concept guides.