fibRetracement

The Fibonacci Retracement is one of the most popular tools in trading. You pick two points (usually a swing high and a swing low), and the tool automatically draws the Fibonacci levels between them (23.6%, 38.2%, 50%, 61.8%, etc.).

Traders use these levels to guess where price might pause, bounce, or reverse during a pullback.

Syntax

fibRetracement(originPoint, targetPoint, styles?)

Parameters

  • originPoint The starting point of the retracement, often a swing high or swing low. Build with newPoint(time, price) .

  • targetPoint: The second anchor, usually the opposite swing. Example:

    newPoint(time(10), high(10))
  • Styles (FibRetracementLineToolOverrides)

    Use these root options:

    • showPrices: boolean – show price labels on each level.

    • showCoeffs: boolean – show % ratios (23.6, 38.2, 61.8…).

    • showText: boolean – show your custom text if you add it to a level.

    • coeffsAsPercents: boolean – display ratios as percents.

    • fillBackground: boolean – shade between levels.

    • transparency: number (0–100) – higher = more transparent shading.

    • reverse: boolean – flip direction of levels.

    • extendLines: boolean, extendLinesLeft: boolean – extend level lines.

    • labelFontSize: number – label size (if labels are visible).

    • horzLabelsAlign, vertLabelsAlign, horzTextAlign, vertTextAlign – fine‑tune label alignment.

    • levelsStyle: { linewidth?: number; linestyle?: number; color?: ... } – default style applied to all levels (can still be overridden per level).

    • trendline: { linewidth?: number; linestyle?: number; color?: ... } – style for the baseline (the anchor‑to‑anchor reference line), if your build shows it.

    Per‑level overrides (this is where you set colors and optional text):

    • level1 … level24: { coeff?: number; color?: RGBA | BaseColor; visible?: boolean; text?: string }

      • coeff: the Fib ratio (e.g., 0.236, 0.382, 0.5, 0.618, 0.786, 1, 1.618, …)

      • color: color for this specific line

      • visible: show/hide this line

      • text: your custom label for this line (works when showText: true)

Return Value

  • string — A unique drawing id you can use later for update or delete.

Example

This script draws a Fibonacci retracement every 50 candles, using an old low as the base and a more recent high as the target.

This creates a yellow Fibonacci retracement with shaded levels, showing both prices and % values.

Result

Tips

  • Use swing highs/lows that stand out — the cleaner the anchors, the more reliable the levels.

  • The 38.2%, 50%, and 61.8% levels are the most watched. Keep an eye on price action around them.

  • Combine with trendlines or moving averages to confirm important levels.

Warning

Good Practice

Last updated