# Three Outside Up/Down

`D06-F04-A06` · Price Action and Candlesticks → Multi-Candle Patterns · archetype `record-transform` · difficulty 4/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/price-action-and-candlesticks/multi-candle-patterns/three-outside-up-down/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { threeOutsideUpDown } from "fintech-algorithms/price-action-and-candlesticks/multi-candle-patterns/three-outside-up-down";
```

## Signature

```ts
threeOutsideUpDown(inputs)
```

Evaluates exactly three candles against explicit outside-pair engulfing, confirmation, scale, and trend-context conventions.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `inputs` | `{ candles: { open: number; high: number; low: number; close: number }[]; trend_context: string; prior_bodies: number[]; prior_ranges: number[]; tick_size: number; penetration_fraction: number }` | yes | Record containing three `candles`, trend context, prior body/range history, tick size, and penetration fraction. |

## Returns

`{ topic_id, pattern, matched, state, direction, trend_context, required_context, history_count, body_scale, range_scale, geometry_score, checks, failed_checks, reason, thresholds, candles }`

One three-candle pattern record. `state` is `warmup`, `wrong-context`, `matched`, or `not-matched`; readiness is record state, not positional output.

## Warm-up

The first `5 prior observations` positions are `state: warmup`. The detector returns one readiness record before five prior body/range observations are available; it does not emit a positional null prefix.

## Errors

- When the record does not contain exactly three valid candles or scale/context inputs are invalid — throws

## Complexity

Time `undefined`, space `undefined`.

## Worked example

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

`inputs`:

```json
{
  "candles": [
    {
      "open": 103,
      "high": 103.3,
      "low": 100.7,
      "close": 101
    },
    {
      "open": 100.5,
      "high": 103.8,
      "low": 100.3,
      "close": 103.5
    },
    {
      "open": 103,
      "high": 104.7,
      "low": 102.8,
      "close": 104.5
    }
  ],
  "trend_context": "downtrend",
  "prior_bodies": [2, 2.1, 1.9, 2.2, 2, 2.1],
  "prior_ranges": [3, 3.2, 2.9, 3.1, 3, 3.3],
  "tick_size": 0.1,
  "penetration_fraction": 0.5
}
```

### Call

```ts
threeOutsideUpDown(inputs)
```

### Returns

object with 16 fields: topic_id, pattern, matched, state, direction, trend_context, required_context, history_count, …

```json
{
  "topic_id": "D06-F04-A06",
  "pattern": "Three Outside Up/Down",
  "matched": true,
  "state": "matched",
  "direction": "bullish",
  "trend_context": "downtrend",
  "required_context": "downtrend",
  "history_count": 10,
  "body_scale": 2,
  "range_scale": 3,
  "geometry_score": 1,
  "checks": {
    "opposite_first_pair": true,
    "second_body_engulfs": true,
    "third_confirms_beyond_second_close": true
  },
  "failed_checks": [],
  "reason": "all declared checks pass"
}
```

Showing 14 of 16 fields.

## Other exports

`calculate`, `morningStar`, `eveningStar`, `threeWhiteSoldiers`, `threeBlackCrows`, `threeInsideUpDown`, `abandonedBaby`. 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.

## Verification and provenance

Tier: **contract**.

The module loads, the entry point is callable and its declared signature matches the compiled code. The example below is real captured output, but no independently published figure asserts the numbers.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.12.0.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/price-action-and-candlesticks/multi-candle-patterns/three-outside-up-down/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/price-action-and-candlesticks/multi-candle-patterns/three-outside-up-down/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/price-action-and-candlesticks/llms.txt
