当我的函数为true时,我想获取过去的自定义点栏索引。我怎么才能得到它?
isWolf(1) and not isWolf(1)[1]
是我的病情,我想获取a的柱线索引。 我尝试
valuewhen(isWolf(1) and not isWolf(1)[1], bar_index[a], 0)
但是没有用。
答案 0 :(得分:0)
应该工作。使用图来测试您的条件和结果:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PineCoders
//@version=4
study("", "", true)
indexOffset = input(0)
f_barUp() => close > open
cond = f_barUp() and not f_barUp()[1]
b = valuewhen(cond, bar_index[indexOffset], 0)
if cond
label.new(bar_index, high, tostring(bar_index[indexOffset]), xloc.bar_index, yloc.price, color.yellow, label.style_labeldown, color.gray)
else
label.new(bar_index, high, tostring(b), xloc.bar_index, yloc.price, color.orange, label.style_labeldown, color.gray)
// For debugging in Data Window
plotchar(bar_index, "bar_index", "", location.top)
plotchar(b, "b", "", location.top)