Indicator · Pine Script v6 · On the chart

Horizontal Ray from Specified Date

by theonetrade· code credited to finallynitin

This indicator projects a horizontal ray extending right from a specific user-defined date on the price chart.

View on GitHub

GitHub stars34on the repository
Pine versionv6current
Lines of code79
Settings12inputs
LicenceMIT
Last update2 weeks ago8 Nov 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

79 lines of Pine Script v6 from assets/indicator/bit-exact/horizontal_ray_from_specified_date_orqI6kAw.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

horizontal_ray_from_specified_date_orqI6kAw.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © finallynitin

//@version=6
indicator('Horizontal Ray from Specified Date', overlay = true)

// ── Inputs ──────────────────────────────────────────────
in_day   = input.int(15,   'Date (D / M / Y)', minval = 1,    maxval = 31,   inline = 'date')
in_month = input.int(9,    '',                 minval = 1,    maxval = 12,   inline = 'date')
in_year  = input.int(2026, '',                 minval = 1990, maxval = 2100, inline = 'date')

src_in = input.string('High', 'Price Source', options = ['High', 'Low', 'Close', 'Open'])

col_above     = input.color(color.green, 'Color: Close Above', inline = 'col')
col_below     = input.color(color.red,   'Below',              inline = 'col')
ray_thickness = input.int(2, 'Ray Thickness', minval = 1, maxval = 5)
ray_style_in  = input.string('Solid', 'Ray Style', options = ['Solid', 'Dashed', 'Dotted'])

show_text   = input.bool(true, 'Show Text', inline = 'txt')
ray_text    = input.string('', '', inline = 'txt', tooltip = 'Leave blank to show the date')
show_price  = input.bool(true, 'Show Price in Text')
text_offset = input.int(15, 'Text Position (bars right of last candle)', minval = 0, maxval = 400)

ray_style = switch ray_style_in
    'Dashed' => line.style_dashed
    'Dotted' => line.style_dotted
    => line.style_solid

// ── Find the day ────────────────────────────────────────
t0      = timestamp(syminfo.timezone, in_year, in_month, in_day, 0, 0)
day_key = year(time) * 10000 + month(time) * 100 + dayofmonth(time)

var line  ray       = na
var label ray_lbl   = na
var int   lock_key  = na
var int   lock_time = na
var float lvl       = na
var int   lvl_bar   = na

if na(lock_key) and time_close > t0
    lock_key  := day_key
    lock_time := time
    lvl       := src_in == 'High' ? high : src_in == 'Low' ? low : src_in == 'Close' ? close : open
    lvl_bar   := bar_index
    ray       := line.new(lvl_bar, lvl, lvl_bar + 1, lvl, xloc = xloc.bar_index, extend = extend.right,
                     color = col_below, width = ray_thickness, style = ray_style)

else if not na(lock_key) and day_key == lock_key
    if src_in == 'High' and high > lvl
        lvl := high, lvl_bar := bar_index
    else if src_in == 'Low' and low < lvl
        lvl := low, lvl_bar := bar_index
    else if src_in == 'Close'
        lvl := close, lvl_bar := bar_index
    line.set_xy1(ray, lvl_bar, lvl)
    line.set_xy2(ray, lvl_bar + 1, lvl)

// ── Colour: green if latest close is above the ray ──────
is_above = not na(lvl) and close > lvl
cur_col  = is_above ? col_above : col_below

if barstate.islast and not na(ray)
    line.set_color(ray, cur_col)
    if show_text
        date_str = str.format_time(lock_time, 'dd MMM yyyy', syminfo.timezone)
        base_txt = ray_text == '' ? date_str : ray_text
        txt      = show_price ? base_txt + ' · ' + str.tostring(lvl, format.mintick) : base_txt
        if na(ray_lbl)
            ray_lbl := label.new(bar_index + text_offset, lvl, txt, xloc = xloc.bar_index,
                         style = label.style_label_lower_right, color = color.new(color.white, 100), textcolor = cur_col)
        else
            label.set_xy(ray_lbl, bar_index + text_offset, lvl)
            label.set_text(ray_lbl, txt)
            label.set_textcolor(ray_lbl, cur_col)

// ── Values for the Pine Screener (hidden on chart) ──────
plot(lvl,                                    'Ray Level',  display = display.data_window)
plot(na(lvl) ? na : (is_above ? 1 : 0),      'Above Ray',  display = display.data_window)
plot(na(lvl) ? na : (close - lvl) / lvl * 100, 'Distance %', display = display.data_window)

Overview

Horizontal Ray from Specified Date locks onto the selected target date and tracks the specified price source, such as high, low, close, or open. The horizontal ray dynamically updates its line color depending on whether the current closing price is above or below the level. It also plots a customizable label to the right of the latest candle displaying the date and price value.

Details

Published by

theonetrade on GitHub

Code credit

finallynitin, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Date (D / M / Y)int15in_day
in_monthint9in_month
in_yearint2026in_year
Price SourcestringHighsrc_in
Color: Close Abovecolorcolor.greencol_above
Belowcolorcolor.redcol_below
Ray Thicknessint2ray_thickness
Ray StylestringSolidray_style_in
Show Textbooltrueshow_text
ray_textstringray_text
Show Price in Textbooltrueshow_price
Text Position (bars right of last candle)int15text_offset
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

947 stars

Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us

Indicator v4 Moving averagesSupport & resistance
Updated 5 weeks ago · GPL-3.0 GitHub repository of Moving Average Channel

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows
368 stars

This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale

Indicator v5 Support & resistanceScreeners & dashboards
Updated 3 months ago · None stated GitHub repository of Multi Alert Long/Short [Alorse]

This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur

Indicator v5 VolumeSupport & resistance
Updated 8 days ago · MIT GitHub repository of Volume Profile and Indicator by DGT

Swing labels

by tradoor-terminal
320 stars

Calculates swing highs and swing lows on the price chart using pivot high and pivot low detection over a specified length. It places labels above pivot highs and below pivot lows to highlight key structural swing points. The indicator measures and displays the

Indicator v6 Support & resistanceTrend
Updated 3 days ago · AGPL-3.0 GitHub repository of Swing labels

BZ-tracker

by Allen1212
302 stars

The BZ-tracker indicator marks ARK Invest buy and sell transactions on stock charts with labels. It plots green labels for purchases and red labels for sales, each annotated with a multiplier such as X1 or X2 to show the number of ARK ETFs trading the stock on

Indicator v4 Support & resistanceScreeners & dashboards
Updated 3 years ago · None stated GitHub repository of BZ-tracker

More Support & resistance scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers