繁体   English   中英

在tradingview的松树脚本中,在当月的第一个柱线处绘制垂直线

[英]Draw vertical line at the first bar of the month in tradingview's pine script

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

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

这是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)

我碰巧找到了解决方案,但使用了 bgcolor。

targetTimeRed = timestamp(year, month, dayofweek.sunday, 00, 00, 00)
bgcolor(targetTimeRed == time ? color.red : na, transp=70, editable=false)

你会在每个月的第一天得到它。

在此处输入图片说明

虽然我不确定它是否应该这样工作......但这就是它的作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM