# Pine Script Indicators

Open-source TradingView indicators that codify Syndotc's FibLab vocabulary. Pine Script v6.

> **What this is:** rule-codified educational implementations. Paste them on any chart, see the levels Syndotc draws by hand, verify your eye against the algorithm.
>
> **What this isn't:** a replacement for the paid FibLab dashboard. The dashboard's edge — cross-TF aggregation, native exchange-close candles, singularity discovery across thousands of levels, the bias scanner across 540 tokens — isn't reproducible from Pine alone.

## Indicators

| File | What it draws | Phase |
|---|---|---|
| [`fiblab-method-core.pine`](fiblab-method-core.pine) | Holds, Breaks (+ Pure/Non-Pure), Origins, BUT levels | **1 — done** |
| [`fiblab-trends.pine`](fiblab-trends.pine) | Topside/bottom-side trends with body-clear pivot validation, break detection, cycle counter (4-6 array reversal threshold) | **2 — done** |
| [`fiblab-assistant.pine`](fiblab-assistant.pine) | Decision layer — 12 manual level slots (tagged by TF, anchored to origin candle), rules-engine panel that surfaces which setup the method endorses, blocks, or recommends waiting on | **3 — done** |
| [`fiblab-assistant-auto.pine`](fiblab-assistant-auto.pine) | Same decision panel as Phase 3, but levels are auto-detected on the chart TF (no manual input). Trade-off: single-TF only, less learning friction. | **3b — done** |
| `fiblab-greedy-ladder.pine` | Time-arrayed ladder helper (4H → 15m sub-levels, refinement search via `request.security_lower_tf`) | 4 — planned |

Add **all three** indicators to the same chart for the full picture: auto-detected levels (Phase 1) + trends with cycle stage (Phase 2) + a rules-engine decision panel that reads your manually-curated levels (Phase 3).

## Install (60 seconds)

1. **TradingView** → open any chart.
2. **Pine Editor** (bottom panel) → "Open" → "New Indicator" → paste the contents of `fiblab-method-core.pine`.
3. **Save** (`Ctrl+S`) → name it "FibLab Method Core" → click **"Add to chart"**.
4. Done — indicators are in your library, attach to any chart.

To update: edit the script in Pine Editor → save → it re-applies on every chart it's attached to.

## What you'll see (FibLab Trends)

| Visual | Logic |
|---|---|
| 🟡 Yellow/cream solid line | Active topside trend (descending resistance through yellow wicks) |
| 🔵 Blue solid line | Active bottom-side trend (ascending support through blue wicks) |
| ⬛ Gray dashed (faded) | Broken trend — anchor frozen at the bar where it broke |
| 📊 Top-left table | Cycle stage: arrays counted per side, with "early / near reversal / REVERSAL ZONE" stage label |

**Pivot detection:** uses a symmetric lookback window. A bar is a pivot high when its high is the highest in the surrounding 2N+1 bars (default N=5) AND it's a yellow candle. Same logic mirrored for blue pivot lows.

**Body-clear validation:** when toggled on (default), a candidate trend between two pivots is only drawn if all bars between them have bodies that don't cross the projected line. Wicks may touch — bodies may not. This is Syndotc's strict rule.

**Break detection:** a topside trend breaks when the current bar is a yellow candle whose body is fully ABOVE the trend's projection at this bar. Bottom-side trends break on a blue candle whose body is fully BELOW.

**Cycle counter:**
- 0–3 arrays: "early" (gray) — expect continuation, not reversal
- 4–5 arrays: "near reversal" (yellow)
- 6+ arrays: "REVERSAL ZONE" (orange) — Syndotc's threshold for major time-frame reversals

## What you'll see (FibLab Assistant)

A live decision panel that applies Syndotc's rule book to your manually-typed levels and the current cycle stage.

| Panel section | What it tells you |
|---|---|
| **Cycle (current TF)** | Topside / bottom-side array counts auto-computed from pivot detection on the chart TF. ⚠ flag appears at ≥ 6 (Reversal Zone). |
| **HTF alignment** (optional) | If you toggle it on, you type in the cycle counts you read from FibLab Trends on the 4H and 1D. Panel shows whether all TFs agree. |
| **Current zone** | Nearest level above and below price (filtered by TF rank), plus ATR-normalized distance to each. |
| **Action now** *(Auto)* | Plain-language calls per level — `BUY — take the first hold off this origin`, `BUY — bounce expected; SELL / get out if it doesn't`, `CAREFUL — first touch is ~50/50, wait for a close back inside`, `MAGNET — ~95% retest`. A **Now** line picks the level within range (`"In range" threshold` input, default 0.75 ATR) and prepends a `⚠ reversal zone — half size` caution when the cycle ≥ 6. The nearest level above & below are also tagged on the chart itself (e.g. `ORIGIN · BUY`) — toggle with **Add action verb to nearest level labels**. |
| **Setup (rule-book)** | The verdict: `WAIT (long-only)`, `BIAS LONG — wait reclaim`, `BIAS SHORT — wait retest`, `NEAR REVERSAL — half size`, or `EARLY CYCLE — continuation`. Long-only mode blocks short suggestions. |
| **Triggers** | Concrete: "Long unlock = close above X (4H ORIGIN) + retest" / "Bear confirm = close below Y (1D BREAK) + retest". |

### Inputting your levels

Twelve slots in **Manual Levels**. Each slot has three fields on one row, plus an optional anchor below:

```
Slot 01:   [ price ]  [ Type ▾ ]  [ TF ▾ ]
           e.g.  49.0    ORIGIN     4H
           anchor:  [ time-picker — click crosshair, click the candle ]
```

- **Price** — click the crosshair icon to pick directly off the chart.
- **Type** — `ORIGIN`, `BUT`, `BREAK`, `HOLD-T`, `HOLD-B`, or `OFF` to disable the slot.
- **TF** — `Current`, `5m`, `15m`, `1H`, `4H`, `1D`, `1W`, `1M`. Tagging the right TF is what lets the script apply the HTF bias hierarchy correctly — a `1D ORIGIN` is treated as heavier than a `1H ORIGIN`.
- **Anchor** — *optional*. Click the time-picker crosshair, then click the candle the level formed on. The line will start at that candle and extend right. Leave at the default (1970) to draw across the visible chart with no fixed anchor.

### TF auto-filter

When you switch chart TF, the panel automatically adjusts which levels are visible per **Level display → Show levels by TF rank**:

- **This TF and higher** *(default)* — on 1H you see 1H, 4H, 1D, 1W. On 1D you only see 1D, 1W. Higher TF lines render thicker.
- **This TF only** — hide everything else.
- **All TFs** — show every enabled slot regardless of chart TF.

You only need to type each level once; the filter handles the rest.

### What it doesn't do (intentionally)

- **No probability output.** Pine can't honestly emit "67% chance up." The panel emits *rule-book status* — which setup is endorsed, blocked, or marginal. The discipline that produces returns is following the rule book, not chasing percentages a script invented.
- **No automated alerts on setup transitions** (yet). Only cycle-threshold alerts fire (topside / bottom-side crossing 6). If you want "alert me when long unlocks" or "alert me when 40 BREAK closes below," ask and I'll add per-trigger alertcondition lines.

## What you'll see (FibLab Core)

| Visual | What it means |
|---|---|
| **Green dashed line** | Bottom-side hold (support) — formed by yellow engulfing blue |
| **Pink dashed line** | Topside hold (resistance) — formed by blue engulfing yellow |
| **Gray solid line** | Pure break (2-candle range) |
| **Gray dotted line** | Non-pure break (3+ candle range — true level lives on a higher TF) |
| **Orange line** | Origin level (a break that failed — touched but didn't close past, then reversed) |
| **Purple dashed line** | BUT (Broken Untested) — a level price hard-closed past, magnet for retest |
| **Top-right table** | Live counts of each level type detected on this chart |

## Settings reference

### Show / Hide
Each level type has its own toggle. Turn off what you don't want to see.

### Filters & Behavior
- **Hold quality: flag front-side holds as CAREFUL** *(Auto, default on)* — only **back-side** holds (structure stacked above → price came all the way down) get a `BUY` call; a **front-side** hold (the leading edge, clear air above) is downgraded to `CAREFUL`. Heuristic: a hold with no level stacked beyond it counts as front-side. Turn off to treat every hold as a plain `BUY`.
- **Hold: minimum candle move %** (default 0.4%) — Syndotc's standard filter. Smaller engulfments are eaten by fees and ignored.
- **Max active levels on chart** — pruned FIFO when exceeded. Keeps the chart readable.
- **Bars after touch to convert break → origin** (default 5) — controls how patient the origin detector is. Lower = stricter (only fast reversals count); higher = catches slower failed breaks.
- **Extend levels to right edge** — keeps the lines visible into the future.

### Colors & Style
All level colors and line widths customizable.

## How to verify it's correct

The fastest sanity check:

1. Open a daily BTC or SOL chart you've already studied with Syndotc's method.
2. Add the indicator.
3. Scroll back through history. The lines should land on the candles where you'd hand-draw them yourself.

Specific examples to look for:
- After a clean two-blue-candle distribution range, the next yellow that engulfs the last blue should produce a green hold line at the engulfed body's top.
- The two-blue range itself should produce a gray break line at the highest wick.
- If the next yellow that touches the break level fails to hard-close above and price drops, that gray line should turn orange (origin).

If something's off, check:
- **Time frame** — the indicator detects on the active TF only. A "non-pure" break on the daily means the true level exists on a higher TF.
- **Min move %** — filtering out engulfments smaller than this. Lower the threshold to see more.

## Known limitations vs the paid suite

| Capability | This script | FibLab Dashboard |
|---|---|---|
| Detect on current chart | ✓ | ✓ |
| Cross-TF level discovery | ✗ | ✓ |
| Native exchange-close candles | ✗ (uses TV anchor) | ✓ |
| Singularity scan | ✗ | ✓ |
| Multi-symbol bias scanner | ✗ | ✓ (540 tokens) |
| Refinement (sub-TF) search | ✗ | ✓ |
| Origin Bot Discord alerts | ✗ | ✓ |

## Why it's not a perfect match

A few intentional simplifications:

1. **Origin detection is conservative** — only converts a break to an origin if price touches AND fails to hard-close within the lookback window. The dashboard uses more sophisticated "range hit" detection (origins formed before parent range closes) which this version omits — could be added in a v2.
2. **No reverse hold (50%) detection** — only standard body engulfments register as holds. Reverse holds on virtual HTF candles are a separate concept that would need its own logic.
3. **No hard-cap on level age** — only count-based pruning. If you want to limit by bar age, easy to add.

## Pine v6 specifics used

- `type Level` — custom type with named fields
- `array<Level>` — typed array storage for active levels
- `barstate.isconfirmed` — only act on closed bars (no repaint)
- `line.style_dotted` for non-pure breaks (visual distinction)
- `extend.right` for forward-extended level lines

## Want it adjusted?

Easy fixes I'd consider:
- Tag origins with the originating range size (e.g., "ORIGIN·3D" if from a 3-bar range)
- Auto-color levels by HTF (gray for chart-TF, brighter for higher-TF non-pure)
- Detect "first hold after origin" with its own tag
- Range hit origin tagging

Just say which.
