dateRange

The Date Range tool measures the distance in time between two points on your chart. It’s perfect for checking how long a run-up, pullback, or consolidation lasted. Think of it as a stopwatch placed between two candles.

Syntax (one line)

dateRange(fromPoint, toPoint, styles?)

Parameters

fromPoint (PricedData) · First anchor (time & price) where the measurement starts. toPoint (PricedData) · Second anchor (time & price) where the measurement ends. styles (PriceDateRangeLineToolOverrides) · Visual and label options (inherits all from PriceRangeLineToolOverrides, plus the border controls below):

  • backgroundColor (RGBAColor | BaseColors) · Fill color behind the range.

  • bold (boolean) · Make label text bold.

  • color (RGBAColor | BaseColors) · Line/outline color of the range.

  • extendLeft (boolean) · Extend the range box/line to the left.

  • extendRight (boolean) · Extend the range box/line to the right.

  • fillBackground (boolean) · Fill the background of the range area.

  • fillLabelBackground (boolean) · Fill the label’s background box.

  • fontSize (number) · Base font size for text.

  • italic (boolean) · Italicize label text.

  • labelBackgroundColor (RGBAColor | BaseColors) · Color for the label’s background.

  • labelFontSize (number) · Font size for the label.

  • labelTextColor (RGBAColor | BaseColors) · Text color inside the label.

  • linewidth (number) · Thickness of the range outline.

  • showLabel (boolean) · Show/hide the label that displays the duration.

  • textcolor (RGBAColor | BaseColors) · General text color.

  • transparency (number) · Transparency for fills (0=opaque, 100=transparent).

  • showBorders (boolean) · Show borders around the range box.

  • borderColor (RGBAColor | BaseColors) · Border color of the range box.

  • borderWidth (number) · Border thickness of the range box.

Return Value

(string) · The drawing ID of the created Date Range.

Example

What this does: Every 52 candles, it measures time between two pivots (earlier and more recent), fills softly, shows a clear label, and draws a thin border.

Tips

  • Pair dateRange with priceRange on the same move to see both time and size at a glance.

  • If labels feel crowded, reduce labelFontSize or increase transparency for a lighter fill.

  • Use extendRight: true when you want the box to remain visible as new bars print.

Warning

  • Don’t pass raw time() or price numbers directly—always wrap anchors with newPoint(time(offset), priceValue) or the drawing won’t be created.

Good Practice

  • Keep a small set of presets (e.g., blue for rallies, red for pullbacks) so ranges are recognizable instantly.

  • Use showBorders with a thin borderWidth for clarity without overpowering candles.

Last updated