【发布时间】:2022-11-10 10:24:16
【问题描述】:
我写了一个代码,绘制两个两条线的角度 我得到了这个功能,但是根据 (a1 = ta.valuewhen(time==time_s,bar_index,astart) 的条件,我对柱的数量有疑问 我试图为该值绘制一个新标签,但我认为它给了我图表上的第一个条形索引
//@version=5
indicator("test",overlay=true)
astart = input(0,"last bar")
src = input(close,"Source")
ho = hour==04?hour:hour==00?hour:hour==08?hour:hour==12?hour:hour==16?hour:hour==20?hour:na
time_s = timestamp(year, month, dayofmonth, ho, 00, 00)
a1 = ta.valuewhen(time==time_s,bar_index,astart)
b1 = ta.valuewhen(time==time_s,close,astart)
line_color = b1 < src ? color.lime : color.red
upper = line.new(a1,b1,bar_index,b1, extend=extend.right,color=line_color,width=2)
lower = line.new(a1,b1,bar_index,src, extend=extend.right,color=line_color,width=2)
line.delete(upper[1])
line.delete(lower[1])
calcDegree(srcc, period) =>
rad2degree = 180 / 3.14159265359
ang = rad2degree * math.atan((srcc[0] - srcc[period]) / period)
angle = calcDegree(close, b1)
lab = label.new(bar_index, high*1.02, text=str.tostring(angle), color=color.green)
label.delete(lab[1])
【问题讨论】:
标签: pine-script