pine-script - 是否可以使用 line.new() 函数绘制水平线
问题描述
我从一个开源脚本中借用了代码。它绘制枢轴高/低趋势线。我还希望它从每个枢轴上绘制水平支撑/阻力,但我不确定它是如何完成的。
我尝试了一些可能性,但因为 line.new() 没有 offset 或 show_last,我无法解决我的问题。
问题/解决方案:x2 需要在枢轴之后设置,但 bar_index[-1] 是不可能的
我有一些不好的结果:(1)这条线是从枢轴后面的前一个柱子画出来的。(2) 确认枢轴点后,在 20 根柱线后绘制线。(3) 除最近的枢轴外,绘制线。
这是代码。top3 是枢轴高变量。第一个 if 语句是我写的。接近尾声的第二个 if 语句用于对角线趋势线
ltop3 = valuewhen(top3, top3, 1)
bst3 = 0
bst3 := top3 ? 1 : nz(bst3[1]) + 1
float t_angle3 = 0.0
t_angle3 := t_angle3[1]
if not na(ltop3) and not na(top3)
line tline = na
line hline = na
dt = time - time[1]
if top3
hline := line.new(bar_index - bst3 - rb3, high[bst3 + rb3], bar_index - rb3, high[bst3 + rb3], color = color.purple, extend = extend.right)
if ltop3 > top3
tline := line.new(bar_index - bst3[1] - rb3, high[bst3[1] + rb3], bar_index - rb3, high[rb3], color = color.red, extend = extend.right)
解决方案
固定的。我将 y1 和 y2 设置为枢轴高点,x1 向后偏移 25 根柱线,因此从枢轴高点开始
if top3
hline := line.new(bar_index[25], top3, bar_index, top3, color = color.purple, extend = extend.right)
推荐阅读
- bash - 实时监控,IP不可封
- java - 如何反序列化当前对象
- makefile - 在执行期间多次调用先决条件
- python - 在python中将字符串变量转换为正则表达式
- android - Expo:在 Chrome 浏览器中从网站深度链接到 Android 应用程序
- python - 保存视频的功能(OpenCV python)
- java - 项目构建错误:org.jboss.quickstarts.fuse:cxf-soap:6.2.1.redhat-084 的不可解析父 POM
- java - java.lang.RuntimeException:无法复制数据库文件。尝试预填充 ROOM 数据库时发生
- postgresql - golang-migrate 找不到 postgres 驱动程序
- .net - 安装 dotnet-sdk-3.1 没有效果