OPEN-SOURCE SCRIPT
Telah dikemas kini

Daily Levels [cryptalent]

99
Daily High / Low / Mid / Open Levels is a session-based reference indicator designed to visualize key daily price levels directly on the chart.

This indicator automatically plots the Daily High, Daily Low, Daily Midpoint (High + Low / 2), and Daily Open as horizontal lines for each trading day. These levels help traders quickly identify important structural prices where liquidity, reactions, or acceptance often occur.

Key Features
Automatic Daily Levels
  • Plots Daily High (H), Low (L), Mid (M), and Open (O) using higher-timeframe daily data.

  • Levels update in real time as the current day develops.


Multi-Day History
  • Displays daily levels for a configurable number of past days.

  • Older levels are automatically removed to keep the chart clean.


Line Extension
  • Current day levels can be extended forward by a user-defined number of bars.

  • Useful for projecting intraday reaction zones and liquidity targets.


Visual Customization
  • Independent line width and color settings for each level.

  • Mid level is shown as a dashed line for quick visual distinction.


Labels & Price Tags
  • Optional letter labels (H / L / M / O) displayed near the extended levels.

  • Optional price labels showing the exact level values on the right side of the chart.

  • Labels update dynamically and only display for the active trading day.


Performance-Oriented Design
  • Efficient line and label management using arrays.

  • Automatically cleans up unused objects to stay within TradingView limits.


Use Cases
  • Identifying intraday support and resistance

  • Tracking daily range behavior

  • Monitoring mean reversion vs. range expansion

  • Aligning intraday execution with higher-timeframe structure


This indicator is particularly useful for traders who rely on market structure, session behavior, and objective price references rather than subjective trend lines.
Nota Keluaran
//version=5
indicator(title="Daily High/Low/Mid/Open Levels", shorttitle="Daily Levels", overlay=true, max_lines_count=500, max_labels_count=500)

// Input Settings
active = input.bool(true, title="Show On Chart")
lineWidthHigh = input.int(2, title="High Line Width", minval=1, maxval=10)
lineWidthLow = input.int(2, title="Low Line Width", minval=1, maxval=10)
lineWidthMid = input.int(1, title="Mid Line Width", minval=1, maxval=10)
lineWidthOpen = input.int(2, title="Open Line Width", minval=1, maxval=10)
lineExtension = input.int(10, title="Line Extension (Bars)", minval=0, maxval=50)
daysToShow = input.int(7, title="Days To Show", minval=1, maxval=30)
showLabels = input.bool(true, title="Show Letter Labels")
showPrice = input.bool(true, title="Show Price Labels")

// Color Settings
colorHigh = input.color(#808080, title="High Line Color")
colorLow = input.color(#808080, title="Low Line Color")
colorMid = input.color(#808080, title="Mid Line Color")
colorOpen = input.color(#3179f5, title="Open Line Color")

// Get Daily Data (real-time updates)
dHigh = request.security(syminfo.tickerid, 'D', high, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
dLow = request.security(syminfo.tickerid, 'D', low, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
dOpen = request.security(syminfo.tickerid, 'D', open, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
dMid = (dHigh + dLow) / 2

// Detect New Day
isNewDay = ta.change(time('D')) != 0

// Type Definition for Daily Lines
type DayLines
line high
line low
line mid
line open
int startBar
int endBar
float highPrice
float lowPrice
float midPrice
float openPrice
bool isToday

// Store Labels (for today's labels)
var label todayLabelH = na
var label todayLabelL = na
var label todayLabelM = na
var label todayLabelO = na

var label todayPriceH = na
var label todayPriceL = na
var label todayPriceM = na
var label todayPriceO = na

// Store All Days' Lines
var array<DayLines> allDays = array.new<DayLines>()

// When New Day Starts
if active and isNewDay
// Mark Previous Day as Ended
if array.size(allDays) > 0
prevDay = array.get(allDays, array.size(allDays) - 1)
prevDay.isToday := false
prevDay.endBar := bar_index - 1
line.set_x2(prevDay.high, bar_index - 1)
line.set_x2(prevDay.low, bar_index - 1)
line.set_x2(prevDay.mid, bar_index - 1)
line.set_x2(prevDay.open, bar_index - 1)

// Create New Day's Lines
newDay = DayLines.new(high=line.new(bar_index, dHigh, bar_index, dHigh, color=colorHigh, width=lineWidthHigh), low=line.new(bar_index, dLow, bar_index, dLow, color=colorLow, width=lineWidthLow), mid=line.new(bar_index, dMid, bar_index, dMid, color=colorMid, width=lineWidthMid, style=line.style_dashed), open=line.new(bar_index, dOpen, bar_index, dOpen, color=colorOpen, width=lineWidthOpen), startBar=bar_index, endBar=bar_index, highPrice=dHigh, lowPrice=dLow, midPrice=dMid, openPrice=dOpen, isToday=true)

array.push(allDays, newDay)

// Delete Old Lines Beyond Display Days
while array.size(allDays) > daysToShow
oldDay = array.shift(allDays)
line.delete(oldDay.high)
line.delete(oldDay.low)
line.delete(oldDay.mid)
line.delete(oldDay.open)

// Update Today's Lines to Current Bar + Extension
if active and array.size(allDays) > 0
today = array.get(allDays, array.size(allDays) - 1)
if today.isToday
// Update prices to current daily values
today.highPrice := dHigh
today.lowPrice := dLow
today.midPrice := dMid
today.openPrice := dOpen

// Update line positions
extendedBar = bar_index + lineExtension
line.set_x2(today.high, extendedBar)
line.set_y1(today.high, dHigh)
line.set_y2(today.high, dHigh)

line.set_x2(today.low, extendedBar)
line.set_y1(today.low, dLow)
line.set_y2(today.low, dLow)

line.set_x2(today.mid, extendedBar)
line.set_y1(today.mid, dMid)
line.set_y2(today.mid, dMid)

line.set_x2(today.open, extendedBar)
line.set_y1(today.open, dOpen)
line.set_y2(today.open, dOpen)

today.endBar := extendedBar

// Delete and Recreate Letter Labels
if showLabels
label.delete(todayLabelH)
label.delete(todayLabelL)
label.delete(todayLabelM)
label.delete(todayLabelO)

labelPos = extendedBar - 2
todayLabelH := label.new(labelPos, dHigh, text="H", style=label.style_none, textcolor=colorHigh, size=size.normal, textalign=text.align_center)
todayLabelL := label.new(labelPos, dLow, text="L", style=label.style_none, textcolor=colorLow, size=size.normal, textalign=text.align_center)
todayLabelM := label.new(labelPos, dMid, text="M", style=label.style_none, textcolor=colorMid, size=size.normal, textalign=text.align_center)
todayLabelO := label.new(labelPos, dOpen, text="O", style=label.style_none, textcolor=colorOpen, size=size.normal, textalign=text.align_center)

// Delete and Recreate Price Labels
if showPrice and barstate.islast
label.delete(todayPriceH)
label.delete(todayPriceL)
label.delete(todayPriceM)
label.delete(todayPriceO)

todayPriceH := label.new(extendedBar, dHigh, text=str.tostring(dHigh, format.mintick), style=label.style_label_left, color=colorHigh, textcolor=color.white, size=size.small)
todayPriceL := label.new(extendedBar, dLow, text=str.tostring(dLow, format.mintick), style=label.style_label_left, color=colorLow, textcolor=color.white, size=size.small)
todayPriceM := label.new(extendedBar, dMid, text=str.tostring(dMid, format.mintick), style=label.style_label_left, color=colorMid, textcolor=color.white, size=size.small)
todayPriceO := label.new(extendedBar, dOpen, text=str.tostring(dOpen, format.mintick), style=label.style_label_left, color=colorOpen, textcolor=color.white, size=size.small)

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.