pine-script - 如何将 Pivot Points H/L 与 TradingView Pine 中的一条线连接起来?
问题描述
我发现枢轴 H/L 的脚本如下所示:
但我希望 H 和 L 用一条线连接,如下所示:
这是脚本:
study(title="Pivot Points H/L", shorttitle="Pivots H/L", overlay=true)
len = input(14, minval=1, title="Length")
//The length defines how many periods a high or low must hold to be a "relevant pivot"
h = highest(len)
//The highest high over the length
h1 = dev(h, len) ? na : h
//h1 is a pivot of h if it holds for the full length
hpivot = fixnan(h1)
//creates a series which is equal to the last pivot
l = lowest(len)
l1 = dev(l, len) ? na : l
lpivot = fixnan(l1)
//repeated for lows
plot(hpivot, color=blue, linewidth=2, offset= -len+1)
plot(lpivot, color=purple, linewidth=2, offset= -len+1)
//plot(h1, color=black, style=circles, linewidth=4, offset= -len+1)
//plot(l1, color=black, style=circles, linewidth=4, offset= -len+1)
谢谢你。
解决方案
无需深入研究代码,您就可以使用 pine 代码生成第二张图片。
您应该在一个变量中记录高点,并在另一个变量中记录枢轴处于活动状态的信号。当枢轴活动代码触发时,您可以使用偏移量进行绘图。
假设您正在寻找价值较低的 2 根右蜡烛的价格支点。在 2 根蜡烛之后,您将收到信号,表明之前有 2 根蜡烛,您有您的支点,然后您应该执行以下操作:
plot(is_pivoth ? pivot_high_price : na, location=location.absolute, offset=-2)
推荐阅读
- flutter - 首次运行应用程序出现此错误
- python - 如果我们不在 kafka 中使用传递回调,在生产之后调用 poll() 是否有任何意义?
- python - pandas countif 使用 where() 为负数
- wordpress - 如何在 Gravity Forms 中制作文件上传进度条?
- amazon-web-services - AWS SSM:传递标签名称而不是实例 ID
- python - 有没有办法让 dask read_csv 忽略空文件?
- java - Java中的一维数组
- c# - 如何修复 Unity 2D 中的空引用异常
- spring-boot - 处理存储在 DB 中的字典值 - Spring
- python - 如何交错两个迭代器,其中 x% 的样本来自一个迭代器,(1-x)% 来自另一个迭代器