Skip to content

Support gradient fills (Pine fill() with top_color/bottom_color value ranges) #83

@deepentropy

Description

@deepentropy

Feature Request

Pine Script's fill() function supports value-range gradient fills:

fill(tsiPlot, midLinePlot, 1, 0, top_color = bullishColor, bottom_color = color.new(bullishColor, 100), title = "Bullish Gradient Fill")
fill(tsiPlot, midLinePlot, 0, -1, top_color = color.new(bearishColor, 100), bottom_color = bearishColor, title = "Bearish Gradient Fill")

This creates fills where opacity varies based on the value position within a range (e.g., fully opaque at the extremes, fully transparent near zero).

Current state

FillData supports static single-color fills between two plots via options.color and options.transp. There is no support for:

  • Value-range based fills (the 4-parameter form: fill(plot1, plot2, topValue, bottomValue, ...))
  • Gradient between two colors (top_color / bottom_color)
  • Per-bar opacity variation based on value position

Use case

The official Trend Strength Index indicator uses this for a gradient fill between the TSI line and zero, fading from opaque near ±1 to transparent near 0. Without this, there's no way to reproduce the official display.

Suggested API

interface FillOptions {
  // existing
  color?: string;
  transp?: number;
  // new
  topValue?: number;
  bottomValue?: number;
  topColor?: string;
  bottomColor?: string;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions