在 TradingView 的 pine 脚本中在该月的第一根柱线处绘制垂直线

cod*_*ody -1 plot line draw pine-script

我想在一个月(对于每日和每周图表)或一年(对于每月图表)的每个第一个柱上绘制一条垂直虚线。我怎样才能做到这一点?我不知道如何获取这些条形索引。

添加: 我在 这篇文章中读到 ,“line.new”的每个指标最多 54 行的限制。但是,当以直方图样式使用绘图函数时(=仅绘制单个垂直直方图条),我无法绘制虚线...并且我更喜欢带有虚线的解决方案...

Pin*_*ucF 5

这是 midtownsk8rguy 代码的改编

//@version=4
study("Periodic Vline", overlay=true)
p = timeframe.ismonthly ? "12M" : "M"
vline(BarIndex, Color, LineStyle, LineWidth) =>
    return = line.new(BarIndex, low - tr, BarIndex, high + tr, xloc.bar_index, extend.both, Color, LineStyle, LineWidth)
if change(time(p))
    vline(bar_index, #FF800080, line.style_dashed, 1)
Run Code Online (Sandbox Code Playgroud)