OPEN-SOURCE SCRIPT
Previous Day OHLC with Labels

//version=5
indicator("Previous Day OHLC with Labels (Visible Fix)", overlay=true)
// ========== SETTINGS ==========
col_open = input.color(color.new(color.green, 0), "Open Line Color")
col_high = input.color(color.new(color.red, 0), "High Line Color")
col_low = input.color(color.new(color.blue, 0), "Low Line Color")
col_close = input.color(color.new(color.yellow, 0), "Close Line Color")
line_w = input.int(2, "Line Width", minval=1, maxval=5)
show_labels = input.bool(true, "Show Labels")
// ========== PREVIOUS DAY DATA ==========
prev_open = request.security(syminfo.tickerid, "D", open[1], lookahead=barmerge.lookahead_on)
prev_high = request.security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
prev_low = request.security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)
prev_close = request.security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_on)
prev_dow = request.security(syminfo.tickerid, "D", dayofweek[1], lookahead=barmerge.lookahead_on)
// Get day name
day_name = prev_dow == dayofweek.monday ? "Monday" :
prev_dow == dayofweek.tuesday ? "Tuesday" :
prev_dow == dayofweek.wednesday ? "Wednesday" :
prev_dow == dayofweek.thursday ? "Thursday" :
prev_dow == dayofweek.friday ? "Friday" :
prev_dow == dayofweek.saturday ? "Saturday" : "Sunday"
// ========== DRAW LINES ==========
if barstate.islast
// Extend across full chart view
line.new(bar_index - 500, prev_open, bar_index + 500, prev_open, color=col_open, width=line_w, extend=extend.both)
line.new(bar_index - 500, prev_high, bar_index + 500, prev_high, color=col_high, width=line_w, extend=extend.both)
line.new(bar_index - 500, prev_low, bar_index + 500, prev_low, color=col_low, width=line_w, extend=extend.both)
line.new(bar_index - 500, prev_close, bar_index + 500, prev_close, color=col_close, width=line_w, extend=extend.both)
if show_labels
label.new(bar_index + 2, prev_open, str.format("{0} Open {1,number,0.#####}", day_name, prev_open), style=label.style_label_left, textcolor=color.white, color=col_open)
label.new(bar_index + 2, prev_high, str.format("{0} High {1,number,0.#####}", day_name, prev_high), style=label.style_label_left, textcolor=color.white, color=col_high)
label.new(bar_index + 2, prev_low, str.format("{0} Low {1,number,0.#####}", day_name, prev_low), style=label.style_label_left, textcolor=color.white, color=col_low)
label.new(bar_index + 2, prev_close, str.format("{0} Close {1,number,0.#####}", day_name, prev_close), style=label.style_label_left, textcolor=color.white, color=col_close)
indicator("Previous Day OHLC with Labels (Visible Fix)", overlay=true)
// ========== SETTINGS ==========
col_open = input.color(color.new(color.green, 0), "Open Line Color")
col_high = input.color(color.new(color.red, 0), "High Line Color")
col_low = input.color(color.new(color.blue, 0), "Low Line Color")
col_close = input.color(color.new(color.yellow, 0), "Close Line Color")
line_w = input.int(2, "Line Width", minval=1, maxval=5)
show_labels = input.bool(true, "Show Labels")
// ========== PREVIOUS DAY DATA ==========
prev_open = request.security(syminfo.tickerid, "D", open[1], lookahead=barmerge.lookahead_on)
prev_high = request.security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
prev_low = request.security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)
prev_close = request.security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_on)
prev_dow = request.security(syminfo.tickerid, "D", dayofweek[1], lookahead=barmerge.lookahead_on)
// Get day name
day_name = prev_dow == dayofweek.monday ? "Monday" :
prev_dow == dayofweek.tuesday ? "Tuesday" :
prev_dow == dayofweek.wednesday ? "Wednesday" :
prev_dow == dayofweek.thursday ? "Thursday" :
prev_dow == dayofweek.friday ? "Friday" :
prev_dow == dayofweek.saturday ? "Saturday" : "Sunday"
// ========== DRAW LINES ==========
if barstate.islast
// Extend across full chart view
line.new(bar_index - 500, prev_open, bar_index + 500, prev_open, color=col_open, width=line_w, extend=extend.both)
line.new(bar_index - 500, prev_high, bar_index + 500, prev_high, color=col_high, width=line_w, extend=extend.both)
line.new(bar_index - 500, prev_low, bar_index + 500, prev_low, color=col_low, width=line_w, extend=extend.both)
line.new(bar_index - 500, prev_close, bar_index + 500, prev_close, color=col_close, width=line_w, extend=extend.both)
if show_labels
label.new(bar_index + 2, prev_open, str.format("{0} Open {1,number,0.#####}", day_name, prev_open), style=label.style_label_left, textcolor=color.white, color=col_open)
label.new(bar_index + 2, prev_high, str.format("{0} High {1,number,0.#####}", day_name, prev_high), style=label.style_label_left, textcolor=color.white, color=col_high)
label.new(bar_index + 2, prev_low, str.format("{0} Low {1,number,0.#####}", day_name, prev_low), style=label.style_label_left, textcolor=color.white, color=col_low)
label.new(bar_index + 2, prev_close, str.format("{0} Close {1,number,0.#####}", day_name, prev_close), style=label.style_label_left, textcolor=color.white, color=col_close)
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.