fintech-algorithms

Causal Pivot Detection

Install and import

bash
npm install fintech-algorithms
ts
import { detectCausalPivots } from "fintech-algorithms/geometric-chart-patterns/pivots-and-levels/causal-pivot-detection";

Signature

detectCausalPivots(bars, leftSpan, rightSpan, minSeparation)

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

bars
[
  {
    "timestamp": "2026-01-01T00:00:00Z",
    "high": 10,
    "low": 8,
    "close": 9
  },
  {
    "timestamp": "2026-01-01T01:00:00Z",
    "high": 12,
    "low": 10,
    "close": 11
  },
  {
    "timestamp": "2026-01-01T02:00:00Z",
    "high": 15,
    "low": 13,
    "close": 14
  }
]

Showing 3 of 5 elements.

leftSpan
2
rightSpan
2
minSeparation
0

Call

detectCausalPivots(bars, leftSpan, rightSpan, minSeparation)

Returns

array of 1 object

[
  {
    "kind": "high",
    "event_index": 2,
    "confirmation_index": 4,
    "price": 15,
    "separation": 2,
    "latency": 2
  }
]

Diagrams

Causal Pivot Detection — failure atlas
Causal Pivot Detection — family handoff
Causal Pivot Detection — knowledge time
Causal Pivot Detection — parameter boundary

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

  • Pine Script Techniques: pivots — TradingView
  • Pine Script Concepts: Repainting — TradingView
  • scipy.signal.find_peaks — SciPy project