Professional Documents
Culture Documents
Support and Resistance
Support and Resistance
0 at
https://mozilla.org/MPL/2.0/
// © kaleboraciy
//@version=4
study("Support & Ressistance by @kaleboraciy", overlay = true, max_lines_count =
500, max_labels_count = 500)
k = 0
for i = 0 to array.size(lines_upper) - 1
line_price = line.get_y2(array.get(lines_upper, i - k))
if high - inacc > line_price
x1 = line.get_x1(array.get(lines_upper, i - k))
x2 = line.get_x2(array.get(lines_upper, i - k))
y1 = line.get_y1(array.get(lines_upper, i - k))
if x1 != x2
line.new(x1, y1, bar_index, y1, extend = extend.none, color =
color.new(color.green, 50), width = width)
line.set_x2(array.get(lines_upper, i - k), bar_index)
alert("Green level at "+ tostring(y1) + " has broken!", freq =
alert.freq_once_per_bar)
if show_broken
line.new(time_close[1], y1, time_close + 1, y1, extend =
extend.right, color = color.new(color.green, 50), width = width2, xloc =
xloc.bar_time)
line.delete(array.get(lines_upper, i - k))
array.remove(lines_upper, i - k)
k := k + 1
k := 0
for i = 0 to array.size(lines_lower) - 1
line_price = line.get_y2(array.get(lines_lower, i - k))
if low + inacc < line_price
x1 = line.get_x1(array.get(lines_lower, i - k))
x2 = line.get_x2(array.get(lines_lower, i - k))
y1 = line.get_y1(array.get(lines_lower, i - k))
if x1 != x2
line.new(x1, y1, bar_index, y1, extend = extend.none, color =
color.new(color.red, 50), width = width)
line.set_x2(array.get(lines_lower, i - k), bar_index)
alert("Red level at "+ tostring(y1) + " has broken!", freq =
alert.freq_once_per_bar)
if show_broken
line.new(time_close[1], y1, time_close + 1, y1, extend =
extend.right, color = color.new(color.red, 50), width = width2, xloc =
xloc.bar_time)
line.delete(array.get(lines_lower, i - k))
array.remove(lines_lower, i - k)
k := k + 1
if ph and time_cond
bool flag = false
for i = 0 to array.size(lines_upper) - 1
line_price = line.get_y2(array.get(lines_upper, i))
if ph >= line_price - inacc and ph <= line_price + inacc
flag := true
line.set_color(array.get(lines_upper, i), color.new(color.green, 50))
line.set_x2(array.get(lines_upper, i), bar_index)
if not flag
array.push(lines_upper, line.new(bar_index[pivot_len], ph,
bar_index[pivot_len], ph, color = na, extend = extend.right, width = width))
if pl and time_cond
bool flag = false
for i = 0 to array.size(lines_lower) - 1
line_price = line.get_y2(array.get(lines_lower, i))
if pl >= line_price - inacc and pl <= line_price + inacc
flag := true
line.set_color(array.get(lines_lower, i), color.new(color.red, 50))
line.set_x2(array.get(lines_lower, i), bar_index)
if not flag
array.push(lines_lower, line.new(bar_index[pivot_len], pl,
bar_index[pivot_len], pl, color = na, extend = extend.right, width = width))
// plot(array.size(lines_upper))
// plot(ph)
// plot(pl)