Rising/Falling Three Methods
Install and import#
npm install fintech-algorithmsimport { risingFallingThreeMethods } from "fintech-algorithms/price-action-and-candlesticks/multi-candle-patterns/rising-falling-three-methods";Signature#
risingFallingThreeMethods(input)Scans five-bar windows for a long candle, three bars whose ranges stay inside it, and a fifth candle of the same colour that closes beyond the first one's close.
Parameters#
| Name | Type | Notes |
|---|---|---|
input | TopicInput | bars is a chronologically ordered array of OHLCV rows; each needs a non-empty timestamp strictly greater than the previous row's and finite open, high, low, close and volume. The pattern family validates tick_tolerance (default 0.01, at least 0) and doji_body_ratio (default 0.05, within 0..1) on every call, but this topic reads only tick_tolerance, the slack allowed at each end of the first bar's range when checking that the three middle bars stay inside it. |
Returns#
TopicResult
series.matched is the boolean verdict for the window ending at that index, and series.label is "rising" for the bullish continuation, "falling" for the bearish one, and "none" otherwise. latest carries the last value of each. The warm-up is the four leading bars that cannot close a five-bar window.
Warm-up#
The first 4 bars positions are null. The pattern needs a five-bar window, so both series hold null at indexes 0 through 3 and ready_at is 4. From index 4 onward matched is false or true, and false is a real verdict rather than a warm-up placeholder, so ready_at does not depend on any pattern ever firing. An input of one to four bars returns null throughout, with ready_at null and state "waiting".
Errors#
- When a bar has a non-finite price or volume, a negative volume, a
highbelow its own open/low/close, alowabove them, or atimestampthat does not advance — throws Error - When
tick_toleranceis not a finite number or is negative, ordoji_body_ratiofalls outside 0..1 — throws Error - When
inputis not an object,input.parametersis not an object, orbarsis not an array holding at least one bar — throws Error
Complexity: time O(n),
space O(n).
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": "2024-01-02",
"basis": "synthetic-unadjusted",
"open": 100,
"high": 101.45,
"low": 98.695,
"close": 100,
"volume": 750000,
"benchmark": 200
},
{
"timestamp": "2024-01-03",
"basis": "synthetic-unadjusted",
"open": 101.49111452,
"high": 103.38381693,
"low": 100.05480022,
"close": 101.78791214,
"volume": 795117,
"benchmark": 200.56326135
},
{
"timestamp": "2024-01-04",
"basis": "synthetic-unadjusted",
"open": 102.45519048,
"high": 104.6701838,
"low": 100.91147007,
"close": 102.9549389,
"volume": 840234,
"benchmark": 201.11020913
}
],
"parameters": {}
}Call#
risingFallingThreeMethods(input)Returns#
object with 9 fields: topic_id, title, state, ready, ready_at, series, latest, parameters, …
{
"topic_id": "D06-F04-A11",
"title": "Rising/Falling Three Methods",
"state": "calculated",
"ready": true,
"ready_at": 4,
"series": {
"label": [null, null, null, null, "none", "none"],
"matched": [null, null, null, null, false, false]
},
"latest": {
"label": "none",
"matched": false
},
"parameters": {},
"diagnostics": {
"causal": true,
"input_count": 96
}
}Diagrams#
Calculation flow#
Rising/Falling Three Methods calculation flow
flowchart LR
A["an ordered OHLC sequence, tick size, gap policy, body scal"] --> B["Validate order, basis, and finite values"]
B --> C["Apply the selected Rising/Falling Three Methods convention"]
C --> D["Emit value, readiness, and diagnostics"]
D --> E["Interpret descriptively; test outcomes separately"]
B -->|invalid or insufficient| X["Withhold output with a reason"]
Rising/Falling Three Methods readiness and evidence states
stateDiagram-v2
[*] --> Waiting
Waiting --> Ready: enough valid causal observations
Waiting --> Rejected: malformed or unsupported input
Ready --> Calculated: selected formula applied
Calculated --> Interpreted: diagnostic and limitation retained
Interpreted --> Ready: next observation arrives
Rejected --> Waiting: corrected input and deterministic reset
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#
- TA-Lib pattern-recognition catalog — see linked primary or authoritative record
- CME Group candlestick chart lesson — see linked primary or authoritative record
- Japanese Candlestick Charting Techniques — see linked primary or authoritative record
- Evidence decision
- Level 1 evidence map