I'm trying to offset the colored histogram bars to the left 2 spaces(offset= -2). The colored bars represent up and down fractals above and below the Zeroline. I've gotten this far but I can't figure out where or how to accomplish this. The offset work fine with a plots.
Any help is appreciated
I have no experience in scripting, just copy and paste and some trouble shooting, but I been stuck on this one for a couple of week. So I figure I better reach out for help.
I tried applying the offset command to various histogram related line to no avail.
//@version=4
study("TSI histogram Fractal Alerts", shorttitle='TSI Alerts', precision=1)
long = input(title="Long Length", type=input.integer, defval=16)
short = input(title="Short Length", type=input.integer, defval=8)
sig1 = input(title="Sig1 Length", type=input.integer, defval=6)
price = close
pc = change(price)
src = input(close, "source")
Zeroline = 0
check = input(true, "Histogram Alert Points")
offset=-2
double_smooth(src, long, short) =>
fist_smooth = ema(src, long)
ema(fist_smooth, short)
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)
hist = tsi_value - ema(tsi_value, sig1)
signal = ema(tsi_value, sig1)
// //////////////////////////////////////////////////////////////
h1 = hist[4]
h2 = hist[3]
h3 = hist[2]
h4 = hist[1]
h5 = hist[0]
l1 = hist[4]
l2 = hist[3]
l3 = hist[2]
l4 = hist[1]
l5 = hist[0]
histhi = h1 < h2 and h2 < h3 and h3 > h4 and h4 > h5
histlo = l1 > l2 and l2 > l3 and l3 < l4 and l4 < l5
// histogram pattern -----
hist_up_plus = hist >= 0 and histhi
hist_down_plus = hist <= 0 and histlo
hist_up_minus = hist <= 0 and histhi
hist_down_minus = hist >= 0 and histlo
hist_color =
hist_up_plus ? color.rgb(234, 54, 54) :
hist_down_plus ? color.rgb(39, 154, 89) :
hist_up_minus ? color.rgb(67, 85, 187) :
hist_down_minus ? color.rgb(183, 172, 50) : color.rgb (242, 244, 244)
// plot -----
plot(hist, "Histogram", hist_color, 1, plot.style_columns)
plot(signal, "Signal", #f1cb0a, 1, transp=0, linewidth=1)
plot(tsi_value, "TSI", #0094ff, 1, transp=95, linewidth=1)
// alert -----
plotchar(check and (hist[1] < 0 and hist[0] > 0), "Histogram Crossover", "▔", location.top, color.rgb(247, 225, 61), 20)
plotchar(check and (hist[1] > 0 and hist[0] < 0), "Histogram Crossunder", "▁", location.bottom, color.rgb(247, 225, 61), 20)
plotchar(check and (crossover(signal, +0)), "Signal Line Crossover", "▔", location.top, color.rgb(96, 162, 243), 20)
plotchar(check and (crossunder(signal, -0)), "Signal Line Crossover", "▁", location.bottom, color.rgb(96, 162, 243), 20)
// Line plots
hline(0, title="Zeroline", color=color.rgb(50, 49, 49, transp=50), linewidth=1)
hline(40, title="Overbought", color=color.rgb(36, 140, 36, transp=50), linewidth=1)
hline(-40, title="Oversold", color=color.rgb(197, 49, 49, transp=50), linewidth=1)
hline(20, title="Neutral Zone_T", color=color.rgb(50, 49, 49, transp=50), linewidth=1)
hline(-20, title="Neutral Zone_B", color=color.rgb(50, 49, 49, transp=50), linewidth=1)