Pine script 仅当信号穿过TSI指示器的中线时才显示plotchar

Pine script 仅当信号穿过TSI指示器的中线时才显示plotchar,pine-script,Pine Script,我只想在信号线穿过TSI指示器中线时绘制字符或条形图。我尝试了交叉,但没有内置库中的幸运TSI指示器。添加了带条件的barcolor函数。使用了cross功能,因此它将在任何方向高亮显示十字。如果要指定-请在或交叉下使用交叉 //@version=4 study("True Strength Indicator", shorttitle="TSI", format=format.price, precision=4, resolution="&q

我只想在信号线穿过TSI指示器中线时绘制字符或条形图。我尝试了交叉,但没有内置库中的幸运TSI指示器。添加了带条件的
barcolor
函数。使用了
cross
功能,因此它将在任何方向高亮显示十字。如果要指定-请在或交叉下使用
交叉

//@version=4
study("True Strength Indicator", shorttitle="TSI", format=format.price, precision=4, resolution="")
long = input(title="Long Length", type=input.integer, defval=25)
short = input(title="Short Length", type=input.integer, defval=13)
signal = input(title="Signal Length", type=input.integer, defval=13)
price = close
double_smooth(src, long, short) =>
    fist_smooth = ema(src, long)
    ema(fist_smooth, short)
pc = change(price)
double_smoothed_pc = double_smooth(pc, long, short)
double_smoothed_abs_pc = double_smooth(abs(pc), long, short)
tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
tsi_signal = ema(tsi_value, signal)


tsi_cross = crossover(tsi_value, 0)
barcolor(timeframe.period == '240' and tsi_cross ? color.yellow : na)

plot(tsi_value, color=#3BB3E4)
plot(tsi_signal, color=#FF006E)
hline(0, title="Zero")

你能指定什么是不相等的吗?如果tsi_信号在零线的一侧,下一个条在零线的另一侧-它将突出显示该条。对不起,我的错误!:)我甚至只想在4h时间范围内着色:
barcolor(timeframe.period='4h'?(交叉(tsi_值,0)?color.yellow:na):na)
但我不明白为什么不是黄色。交叉函数应该在全局范围内初始化<代码>tsi_交叉=交叉(tsi_值,0),barcolor(timeframe.period='4h'?tsi_交叉?color.yellow:na)
tsi_交叉=交叉(tsi_值,0)barcolor(timeframe.period='4h'?tsi_交叉?color.yellow:na)
没有第二个na我得到错误,第二个na我没有将黄色条“4h”更改为“240”。ps:用代码更新了答案。