pine-script - pivothigh/pivotlow 没有按预期工作
问题描述
为什么这段代码向我显示错误的数据透视高点?它正在计算左侧和右侧的每一秒栏,而不仅仅是一个...如果我更改为:
bar_index % 1 == 0
,它工作正常。
这是我的代码:
//@version=4
study("fckn test", overlay=true)
if bar_index % 2 == 0
ph = pivothigh(1,1)
label.new(bar_index-1, low, tostring(ph))
解决方案
不太确定您要做什么。也许这个?
//@version=4
study("fckn test", overlay=true)
pivotLegs = 1
// Find pivot outside `if` block because needs to run on every bar.
ph = pivothigh(pivotLegs, pivotLegs)
// Detect a new pivot.
newPh = not na(ph)
// If a new pivot is found, save the bar index where it was found.
bh = newPh ? bar_index - pivotLegs : na
if bar_index % 2 == 0 and not na(ph)
label.new(bh, high[pivotLegs], tostring(ph))
推荐阅读
- cross-platform - SIP(会话发起协议)与。MGCP(媒体网关控制协议)
- algorithm - 有人知道 Google Charts 对其直方图存储桶使用什么算法吗?
- python - InvalidArgumentError: indices[24,0] = 335 不在 [0, 304) [[{{node user-embedding-mlp_1/GatherV2}}]]
- javascript - 如何使用 jQuery 动态添加删除线文本动画?
- model - 从 3d 模型中删除边框
- java - 如何在杰克逊的 XmlMapper 中强制关闭标签为空或空值?
- automation - 自动化出勤的最聪明方法
- python - 当 urllib2.urlopen 抛出异常时捕获响应正文
- javascript - ngb-pagination for angular - 如何只使用下一个和上一个按钮?
- asp.net-core - 如何在 ASP.NET Core 中读取 SOAP 信封头/正文?