YTI02 v2
YTI02 v2
upColor = color.white
midColor = #90bff9
downColor = color.blue
// Source
src = input(defval = close, title = 'Source')
// Sampling Period
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
per = input.int(defval = 100, minval = 1, title = 'Sampling Period')
// Range Multiplier
mult = input.float(defval = 3.0, minval = 0.1, title = 'Range Multiplier')
ta.sma(vidya_value, 15)
// CALCULATION
S――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
――――――――――――{
// Calculate the Average True Range (ATR)
float atr_value = ta.atr(200) // ATR calculation with length of 200
liquidity_lines_low.push(pivot_line)
volume_value := math.sum(volume, pivot_right_bars + pivot_left_bars) /
(pivot_right_bars + pivot_left_bars)
volume_value
liquidity_lines_high.push(pivot_line)
volume_value := math.sum(-volume, pivot_right_bars + pivot_left_bars) /
(pivot_right_bars + pivot_left_bars)
volume_value
// Range Filter
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r
: x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
// Filter Direction
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 :
nz(downward[1])
// Target Bands
hband = filt + smrng
lband = filt - smrng
// Colors
filtcolor = upward > 0 ? upColor : downward > 0 ? downColor : midColor
barcolor = src > filt and src > src[1] and upward > 0 ? upColor : src > filt and
src < src[1] and upward > 0 ? upColor : src < filt and src < src[1] and downward >
0 ? downColor : src < filt and src > src[1] and downward > 0 ? downColor : midColor
// Break Outs
longCond = bool(na)
shortCond = bool(na)
longCond := src > filt and src > src[1] and upward > 0 or src > filt and src <
src[1] and upward > 0
shortCond := src < filt and src < src[1] and downward > 0 or src < filt and src >
src[1] and downward > 0
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1
// PLOT
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
――――――――――――――――――――――――――{
// Display labels for volume and trend statistics on the last bar
if barstate.islast
label.delete(label.new(bar_index, smoothed_value, 'Buy: ' +
str.tostring(up_trend_volume, format.volume) + '\n Sell: ' +
str.tostring(down_trend_volume, format.volume) + '\nDelta Volume: ' + delta_volume,
color = color.new(trend_color, 90), style = is_trend_up ?
label.style_label_upper_left : label.style_label_lower_left, textcolor =
chart.fg_color)[1])