PROTECTED SOURCE SCRIPT

Previous Day OHLC Levels (Single Day with Labels)

//version=5
indicator("Previous Day OHLC Levels (Single Day with Labels)", overlay=true)

// Inputs for customization
show_open = input.bool(true, "Show Open Level")
show_high = input.bool(true, "Show High Level")
show_low = input.bool(true, "Show Low Level")
show_close = input.bool(true, "Show Close Level")

open_color = input.color(color.blue, "Open Line Color")
high_color = input.color(color.green, "High Line Color")
low_color = input.color(color.red, "Low Line Color")
close_color = input.color(color.orange, "Close Line Color")

line_width = input.int(2, "Line Width", minval=1, maxval=5)

// Fetch previous day's OHLC data
prev_open = request.security(syminfo.tickerid, "D", open[1])
prev_high = request.security(syminfo.tickerid, "D", high[1])
prev_low = request.security(syminfo.tickerid, "D", low[1])
prev_close = request.security(syminfo.tickerid, "D", close[1])

// Variables for lines and labels
var line high_line = na
var line low_line = na
var line open_line = na
var line close_line = na

var label high_label = na
var label low_label = na
var label open_label = na
var label close_label = na

// Reset lines and labels at the start of a new day
is_new_day = (ta.change(time("D")))
if is_new_day
// Delete old lines
if na(high_line) == false
line.delete(high_line)
if na(low_line) == false
line.delete(low_line)
if na(open_line) == false
line.delete(open_line)
if na(close_line) == false
line.delete(close_line)

// Delete old labels
if na(high_label) == false
label.delete(high_label)
if na(low_label) == false
label.delete(low_label)
if na(open_label) == false
label.delete(open_label)
if na(close_label) == false
label.delete(close_label)

// Draw new lines and labels
if show_high
high_line := line.new(bar_index, prev_high, bar_index + 1, prev_high, color=high_color, width=line_width, extend=extend.right)
high_label := label.new(bar_index, prev_high, str.tostring(prev_high), style=label.style_label_right, color=high_color, textcolor=color.white)

if show_low
low_line := line.new(bar_index, prev_low, bar_index + 1, prev_low, color=low_color, width=line_width, extend=extend.right)
low_label := label.new(bar_index, prev_low, str.tostring(prev_low), style=label.style_label_right, color=low_color, textcolor=color.white)

if show_open
open_line := line.new(bar_index, prev_open, bar_index + 1, prev_open, color=open_color, width=line_width, extend=extend.right)
open_label := label.new(bar_index, prev_open, str.tostring(prev_open), style=label.style_label_right, color=open_color, textcolor=color.white)

if show_close
close_line := line.new(bar_index, prev_close, bar_index + 1, prev_close, color=close_color, width=line_width, extend=extend.right)
close_label := label.new(bar_index, prev_close, str.tostring(prev_close), style=label.style_label_right, color=close_color, textcolor=color.white)
aainathbhalagaurishankarStandard Deviationsuthar

受保護腳本

該腳本是閉源發佈的,您可以自由使用。您可以把它加入到常用以在圖表上使用它。您無法查看或修改其原始碼。

想在圖表上使用此腳本?

免責聲明