I'd like to plotchar or barcolor only when the signal line corss the midline in TSI indicator. I tried with crossover but without lucky
TSI indicator from built-in library. Added a barcolor
function with a conditional. Used cross
function, so it will highlight the cross in any direction. If you want to specify - use crossunder
or crossover
//@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")