Indicator · Pine Script v5 · On the chart

Higher Timeframe High & Low [ChartPrime]

by theonetrade· code credited to ChartPrime

Higher Timeframe High & Low [ChartPrime] plots the high and low price levels of a user-selected higher timeframe directly on the main price chart.

View on GitHub

Repaints

GitHub stars34on the repository
Pine versionv5runs as is
Lines of code187
Settings5inputs
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

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

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

//@version=5
indicator(title='Higher Timeframe High & Low [ChartPrime]', 
          shorttitle='H/L HTF [ChartPrime]', 
          overlay=true, 
          max_lines_count = 2, 
          max_labels_count = 10
          )

// ---------------------------------------------------------------------------------------------------------------------}
// 𝙄𝙉𝙋𝙐𝙏𝙎
// ---------------------------------------------------------------------------------------------------------------------{
extension  = input.int(50, "Extension to the right of High and Low", group = "Settings")
timeframe  = input.timeframe("D", "timeframe", tooltip = "Use Higher Timeframe then Current", group = "Settings")

separator  = input.bool(false, "Period Separator")
show_trend = input.bool(false, "Show Trend?")
show_break = input.bool(false, "Show Breakout Labels?")


// Variables Declaration
var color color = na
color color1    = na
var bool check  = na

color colorDn   = #d41919
color colorUp   = #13b818


// ---------------------------------------------------------------------------------------------------------------------}
// 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎
// ---------------------------------------------------------------------------------------------------------------------{
// To avoid differences on historical and realtime bars: 
// returns a value from the higher timeframe on the bar after it completes:
indexHighTF = barstate.isrealtime ? 1 : 0
indexCurrTF = barstate.isrealtime ? 0 : 1

pricehigh   = request.security(syminfo.tickerid, timeframe, high[indexHighTF])[indexCurrTF]
pricelow    = request.security(syminfo.tickerid, timeframe,  low[indexHighTF])[indexCurrTF]
price_avg   = math.avg(pricelow, pricehigh)

high_break = ta.crossover(close, pricehigh)
low_break  = ta.crossunder(close, pricelow)


// BreakOuts Checker (to avoid multiple labels) and color change
switch 
    high_break => check := true,  color1 := colorUp, color := colorUp
    low_break  => check := false, color1 := colorDn, color := colorDn


// ---------------------------------------------------------------------------------------------------------------------}
// 𝙑𝙄𝙎𝙐𝘼𝙇𝙄𝙕𝘼𝙏𝙄𝙊𝙉
// ---------------------------------------------------------------------------------------------------------------------{
// BreakOut labels
if high_break and check[1] == false and show_break
    
    label.new(x = bar_index, y = low*0.99, 
             text = timeframe + "\nHigh Break",
             style = label.style_label_up,
             textcolor = chart.fg_color, 
             color = #0e4e11, 
             size = size.small
             )

if low_break and check[1] == true and show_break

    label.new(x = bar_index, y = high*1.01, 
             text      = timeframe + "\nLow Break", 
             style     = label.style_label_down, 
             textcolor = chart.fg_color, 
             color     = #6e1414, 
             size      = size.small
             )

// High and Low plots from HTF
change_hl = not ta.change(pricehigh) or not ta.change(pricelow)


ph = plot(series    = change_hl and not show_trend ? pricehigh : show_trend ? pricehigh : na, 
          title     ='High', 
          style     = plot.style_linebr, 
          linewidth = 2, 
          color     = not show_trend ? colorDn : color.new(colorDn, 80)
          )

pm = plot(series   = change_hl and not show_trend ? price_avg : show_trend ? price_avg : na, 
         title     ='L & H Avg', 
         style     = show_trend ? plot.style_stepline_diamond : plot.style_circles, 
         linewidth = 1, 
         color     = show_trend ? color.new(chart.fg_color, 90) : color.new(chart.fg_color, 50)
         )

pl = plot(series    = change_hl and not show_trend ? pricelow  : show_trend ? pricelow : na,
          title     = 'Low', 
          style     = plot.style_linebr,  
          linewidth = 2, 
          color     = not show_trend ? colorUp : color.new(colorUp, 80)
          )


// Plot triangles if High or Low weren't broken
plotchar(series   = ta.crossunder(high, pricehigh), 
         title    = "Resistance", 
         char     = "◆", 
         location = location.abovebar, 
         offset   = -1, 
         color    = colorDn, 
         size     = size.tiny
         )

plotchar(series   = ta.crossover(low, pricelow), 
         title    = "Support",
         char     = "◆", 
         location = location.belowbar,
         offset   = -1, 
         color    = colorUp, 
         size     = size.tiny
         )


// Extension High and Low to a future
if barstate.islast

    label.new(point = chart.point.from_index(bar_index + extension, pricehigh), 

              text      = "⮪ " + timeframe + " High", 
              style     = label.style_label_left, 
              textcolor = chart.fg_color, 
              color     = colorDn, 
              size      = size.normal
              )

    label.new(point = chart.point.from_index(bar_index + extension, pricelow),

              text      = "⮨ " + timeframe + " Low",  
              style     = label.style_label_left, 
              textcolor = chart.fg_color, 
              color     = #158d19, 
              size      = size.normal
              )

if change_hl and barstate.islast

    h_Left         = chart.point.from_index(bar_index,           pricehigh)
    h_Right        = chart.point.from_index(bar_index+extension, pricehigh)

    line.new(h_Left, h_Right, color = colorDn, style = line.style_solid, width = 2)

    l_Left         = chart.point.from_index(bar_index,           pricelow)
    l_Right        = chart.point.from_index(bar_index+extension, pricelow)

    line.new(l_Left, l_Right, color = colorUp, width = 2)

    m_Left         = chart.point.from_index(bar_index,           math.avg(pricelow, pricehigh))
    m_Right        = chart.point.from_index(bar_index+extension, math.avg(pricelow, pricehigh))

    line.new(m_Left, m_Right, 
                 color = chart.fg_color, 
                 width = show_trend ? 1 : 2, 
                 style = show_trend ? line.style_solid : line.style_dotted
                 )


// BreakOut Bar Color of Trend Color
barcolor(show_trend ? color : color1)


bgcolor(separator ? (not change_hl
                      ? color.new(chart.fg_color, 90): na) 
                      : na
                      )


// Fill OB and OS Zones
fill(plot1        = ph,
     plot2        = pl,
     top_value    = pricehigh,
     bottom_value = pricelow, 
     top_color    = not show_trend ? color.new(colorDn, chart.bg_color == color.white ?  80 : 92) : na,
     bottom_color = not show_trend ? color.new(colorUp, chart.bg_color == color.white ?  80 : 92) : na
     )

    
// ---------------------------------------------------------------------------------------------------------------------}

Overview

Higher Timeframe High & Low [ChartPrime] detects when price breaks above or below these higher timeframe boundaries and can display breakout labels. Optional settings allow customizing line extensions, period separators, trend coloring, and breakout label visibility. Note that real-time and historical bar calculations use different indexing logic, which may cause discrepancies between historical bars and live price action.

Details

Published by

theonetrade on GitHub

Code credit

ChartPrime, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

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
Extension to the right of High and Lowint50extension
timeframetimeframeDtimeframe
Period Separatorboolfalseseparator
Show Trend?boolfalseshow_trend
Show Breakout Labels?boolfalseshow_break
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

Sideway Zones Live

by dearvn
257 stars

Sideway Zones Live is an overlay indicator that estimates inner and outer sideways bands from recent highs and lows with a rational quadratic kernel. It tracks swing pivots over a loopback period and counts bars that remain between the outer high and low. Afte

Indicator v5 TrendSupport & resistance
Updated 2 months ago · None stated GitHub repository of Sideway Zones Live
56 stars

This indicator calculates dynamic upper and lower trendlines from pivot highs and pivot lows across a specified bar length. Trendline slopes are derived using ATR, standard deviation, or linear regression methods. It plots trendlines and breakout signal labels

Indicator v5 TrendSupport & resistance Repaints
Updated 3 months ago · None stated GitHub repository of Trendlines With Breaks [LUX]

Reversal Breakout System

by TamaraKGreen
47 stars

This indicator detects inside candles inside larger parent candles on the price chart. It plots colored boxes around inside and parent candles, fills them with user-adjustable transparency, draws Fibonacci retracement lines and mother candle range lines, and d

Indicator v6 Candlestick patternsBreakout
Updated 2 months ago · None stated GitHub repository of Reversal Breakout System

The Mathematical Indicator calculates session bias by evaluating previous daily and 4-hour closed candles. It draws timeframe support and resistance levels using candle bodies, highlights clean trading zones, and identifies setup patterns involving consolidati

Indicator v6 TrendSupport & resistance Repaints
Updated 3 days ago · MIT GitHub repository of The Mathematical Indicator · 2-Candle Bias
28 stars

This indicator maps Smart Money Concepts (SMC) market structure directly onto the price chart. It detects internal and swing structure breaks (BOS and CHoCH), tracks bullish and bearish order blocks, identifies fair value gaps (FVG), highlights equal highs and

Indicator v5 SMC / ICT / price actionSupport & resistance Repaints
Updated 5 weeks ago · Custom licence GitHub repository of Smart Money Concepts [LuxAlgo] Test B

The Market Tradability Engine calculates multi-factor tradability, balance, compression, and direction scores to evaluate market regime quality. It classifies market conditions into eight distinct states, including Balance, Compression, Ready, Breakout, Trend,

Indicator v6 TrendVolatility & bands
Updated 4 weeks ago · MIT GitHub repository of Market Tradability Engine [WavesUnchained]

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