Previous Day Close (subtle)

LusoBull · study · 31 行 · 点赞 4 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LusoBull
 
//@version=6
indicator("Previous Day Close (subtle)", overlay = true, max_lines_count = 500)
 
// Inputs
lineColor = input.color(color.new(color.gray, 45), "Cor")
showLabel = input.bool(true, "Mostrar etiqueta 'PDC'")
 
// Fecho do dia anterior (sem repaint)
pdClose = request.security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)
 
var line pdLine = na
var label pdLabel = na
 
if timeframe.isintraday and not na(pdClose)
    if timeframe.change("D")
        // Nova linha no início de cada dia
        pdLine := line.new(bar_index, pdClose, bar_index + 1, pdClose,
             color = lineColor, style = line.style_dotted, width = 1)
    else
        // Estende a linha do dia atual
        line.set_x2(pdLine, bar_index)
 
    // Etiqueta pequena apenas na última barra
    if showLabel and barstate.islast
        label.delete(pdLabel)
        pdLabel := label.new(bar_index, pdClose, "PDC",
             style = label.style_label_left, color = color.new(color.white, 100),
             textcolor = lineColor, size = size.tiny)

← 返回列表