Causal Pivot Detection
Install and import
npm install fintech-algorithmsimport { 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
[
{
"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.
220Call
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
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
- Pine Script Techniques: pivots — TradingView
- Pine Script Concepts: Repainting — TradingView
- scipy.signal.find_peaks — SciPy project