OPEN-SOURCE SCRIPT

Attique Golden Pocket Indicator

668
What this indicator does
Swing Fib draws a swing-based Fibonacci retracement grid on the price chart after the script decides there is a completed impulse leg between two anchored pivots. It is not a manual Fib tool: the anchors, direction (bull vs bear leg), and whether anything is drawn are all rule-based from pivot logic and a volatility filter.

The overlay includes:

A dashed blue line between the two swing anchors (the impulse leg).
Horizontal levels for a fixed set of retracement ratios (see below).
Optional Golden Pocket (GP) zone: two gold boundary lines (defaults 61.8% and 78.6% between the same anchors) and optional shading between them.
Optional retention of the previous fib when a new valid leg appears (prior leg is dimmed rather than deleted immediately).
How the anchors and “impulse” are defined
Pivots
The script uses TradingView’s standard pivothigh / pivotlow with configurable left and right bar counts:

Chart timeframe = Fib pivot timeframe (see next section): pivots use liqLeft / liqRight on the chart series.
Fib pivot timeframe higher than chart: pivots are read from the higher timeframe via request.security using fibPivotL / fibPivotR.
A pivot is only confirmed after right bars have printed to the right of the swing. Until then, the pivot can change or disappear on history as new bars form. That is normal pivot behavior, not a bug.

Bull vs bear leg (which fib you get)
Bullish fib leg: the script uses the most recently confirmed swing high and swing low such that the high pivot occurs after the low pivot in time, and high price > low price. Conceptually this is a push up from the swing low toward the swing high; retracements are measured back down from the high toward the low.
Bearish fib leg: the low pivot occurs after the high pivot, still with high price > low price (the swing high is the structural high of the leg). Conceptually a push down from the swing high toward the swing low; retracements are measured back up from the low toward the high.
ATR minimum range filter
Even if pivot structure qualifies, the fib does not draw unless the impulse range (high minus low of the anchored leg) is at least:

fibMinRangeAtrCh × ATR(atrLen)

This suppresses tiny, noisy swings. If the chart looks “empty,” lower fibMinRangeAtrCh slightly; if it is too busy, raise it.

How Fib prices are computed (important for reading the levels)
For both directions the math is anchored as:

0% = impulse high price, 100% = impulse low price

So the same formula maps ratios into the range between the two swing prices, with 0% at the top of the leg and 100% at the bottom. The BULLISH FIB vs BEARISH FIB title tells you which time ordering of pivots was used; the numeric labels still refer to that high → low retracement scale.

Standard levels drawn (labels match these ratios)
Between the anchored high and low, the script plots (from the high toward the low):

0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 88.6%, then extension-style ratios −61.8%, −27.2%, −12.7%, and 100%.

You will also see two gold “GP” lines at the Golden Pocket inputs (defaults 61.8% and 78.6%). Because those defaults overlap the standard grid, you may see two lines near the same prices (one from the standard set, one from GP styling). That is intentional: GP is visually emphasized.

Chart timeframe vs higher-timeframe Fib
The script compares the chart period to fibAnchorTf using seconds, not fragile string matching.

Match (same duration as chart): anchors use xloc.bar_index (bar indices). The fib aligns exactly with how you see swings on that timeframe.
Higher fibAnchorTf than chart: anchors use higher-timeframe pivot prices and the pivot bar’s time on that HTF, and drawings use xloc.bar_time so the grid lines up in time on your lower chart.
Practical rule: If you want the fib to match what you see on the current chart swings, set fibAnchorTf = your chart timeframe. If you want a structure map from a slower TF (for example 15m or 1h swings on a 1m or 2m chart), set fibAnchorTf higher and accept that the leg definition is HTF pivot-based, not the same as every small chart swing.

Visual and UX options
Extend levels right: horizontal lines extend to the right by fibExtendBarsCh bars (and update as bar_index advances).
Level labels: optional text for each ratio; position Right, Left, or Middle along the span.
Prior fib: optional freeze + dim of the last fib when a new valid leg forms, useful for comparing previous vs current swing context.

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。