仅当信号穿过 TSI 指标中线时的 plotchar

plotchar only if signal cross a midline in TSI indicator

我只想在信号线穿过 TSI 指标中线时绘制字符或条形图。我试过交叉但没有幸运

来自内置库的 TSI 指标。添加了带条件的 barcolor 函数。使用了cross函数,所以它会在任何方向高亮十字。如果要指定 - 使用 crossundercrossover

//@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")