OPEN-SOURCE SCRIPT
Multi-TF S/R Lines by Pivots - 15min Chart

//version=5
indicator('Multi-TF S/R Lines by Pivots - 15min Chart', overlay=true, max_lines_count=32)
// تنظیمات کاربری
pivot_lookback = input.int(5, 'تعداد کندل دو طرف پیوت')
search_bars = input.int(200, 'تعداد کندل چکشونده در هر تایمفریم')
line_expire = input.int(40, 'حداکثر کندل بیتست تا پنهان کردن سطح')
h4_color = color.new(color.teal, 0)
h1_color = color.new(color.green, 0)
d1_color = color.new(color.blue, 0)
w1_color = color.new(color.red, 0)
plot_labels = input.bool(true, 'نمایش لیبل')
label_size = input.string('tiny', 'سایز لیبل', ['auto','tiny','small','normal','large','huge'])
var float[] w1_pivothighs = array.new_float(0)
var float[] w1_pivotlows = array.new_float(0)
var float[] d1_pivothighs = array.new_float(0)
var float[] d1_pivotlows = array.new_float(0)
var float[] h4_pivothighs = array.new_float(0)
var float[] h4_pivotlows = array.new_float(0)
var float[] h1_pivothighs = array.new_float(0)
var float[] h1_pivotlows = array.new_float(0)
//----------------------
// تابع پیوتی (true اگر کندل مرکزی، پیوت سقف/کف باشد)
pivot(cF, length, dir) =>
// dir = 'high' یا 'low'
var bool isP = true
for i = 1 to length
if dir == 'high'
isP := isP and cF[length] > cF[length - i] and cF[length] > cF[length + i]
if dir == 'low'
isP := isP and cF[length] < cF[length - i] and cF[length] < cF[length + i]
isP
// جمعآوری پیوتها در تایمفریم انتخابی
get_pivots(tf, bars_limit, look, dir) =>
var float[] pivs = array.new_float(0)
pivs := array.new_float(0) // reset each call: همیشه آخرین ۲۰۰ کندل
h = request.security(tf, 'high', high)
l = request.security(tf, 'low', low)
arr = dir == 'high' ? h : l
// فقط کندلهای وسط برگردد (نه اول و آخر)
for i=look to (bars_limit - look)
if pivot(arr, look, dir)
array.unshift(pivs, arr)
pivs
// بروزرسانی آرایه پیوتها (آخرین سطوح)
if barstate.islastconfirmedhistory
w1_pivothighs := get_pivots('W', search_bars, pivot_lookback, 'high')
w1_pivotlows := get_pivots('W', search_bars, pivot_lookback, 'low')
d1_pivothighs := get_pivots('D', search_bars, pivot_lookback, 'high')
d1_pivotlows := get_pivots('D', search_bars, pivot_lookback, 'low')
h4_pivothighs := get_pivots('240', search_bars, pivot_lookback, 'high')
h4_pivotlows := get_pivots('240', search_bars, pivot_lookback, 'low')
h1_pivothighs := get_pivots('60', search_bars, pivot_lookback, 'high')
h1_pivotlows := get_pivots('60', search_bars, pivot_lookback, 'low')
//--------------
// تابع رسم سطح
draw_lines(pivArr, line_color, label_txt, expiry) =>
int count = math.min(array.size(pivArr), 8)
for i=0 to (count-1)
y = array.get(pivArr, i)
// بررسی در 40 کندل اخیر برخورد بوده یا نه؟
touched = false
for c=0 to (expiry-1)
touched := touched or (low[c] <= y and high[c] >= y)
if touched
l = line.new(bar_index-expiry, y, bar_index, y, color=line_color, width=2, extend=extend.right)
if plot_labels
label.new(bar_index, y, label_txt, color=line_color, style=label.style_label_right, textcolor=color.white, size=label_size)
// اگر طی پیشفرض expiry کندل برخورد نشده بود، خط و لیبل رسم نشود (مخفی شود)
// رسم همه خطوط
draw_lines(w1_pivothighs, w1_color, 'W1', line_expire)
draw_lines(w1_pivotlows, w1_color, 'W1', line_expire)
draw_lines(d1_pivothighs, d1_color, 'D1', line_expire)
draw_lines(d1_pivotlows, d1_color, 'D1', line_expire)
draw_lines(h4_pivothighs, h4_color, 'H4', line_expire)
draw_lines(h4_pivotlows, h4_color, 'H4', line_expire)
draw_lines(h1_pivothighs, h1_color, 'H1', line_expire)
draw_lines(h1_pivotlows, h1_color, 'H1', line_expire)
indicator('Multi-TF S/R Lines by Pivots - 15min Chart', overlay=true, max_lines_count=32)
// تنظیمات کاربری
pivot_lookback = input.int(5, 'تعداد کندل دو طرف پیوت')
search_bars = input.int(200, 'تعداد کندل چکشونده در هر تایمفریم')
line_expire = input.int(40, 'حداکثر کندل بیتست تا پنهان کردن سطح')
h4_color = color.new(color.teal, 0)
h1_color = color.new(color.green, 0)
d1_color = color.new(color.blue, 0)
w1_color = color.new(color.red, 0)
plot_labels = input.bool(true, 'نمایش لیبل')
label_size = input.string('tiny', 'سایز لیبل', ['auto','tiny','small','normal','large','huge'])
var float[] w1_pivothighs = array.new_float(0)
var float[] w1_pivotlows = array.new_float(0)
var float[] d1_pivothighs = array.new_float(0)
var float[] d1_pivotlows = array.new_float(0)
var float[] h4_pivothighs = array.new_float(0)
var float[] h4_pivotlows = array.new_float(0)
var float[] h1_pivothighs = array.new_float(0)
var float[] h1_pivotlows = array.new_float(0)
//----------------------
// تابع پیوتی (true اگر کندل مرکزی، پیوت سقف/کف باشد)
pivot(cF, length, dir) =>
// dir = 'high' یا 'low'
var bool isP = true
for i = 1 to length
if dir == 'high'
isP := isP and cF[length] > cF[length - i] and cF[length] > cF[length + i]
if dir == 'low'
isP := isP and cF[length] < cF[length - i] and cF[length] < cF[length + i]
isP
// جمعآوری پیوتها در تایمفریم انتخابی
get_pivots(tf, bars_limit, look, dir) =>
var float[] pivs = array.new_float(0)
pivs := array.new_float(0) // reset each call: همیشه آخرین ۲۰۰ کندل
h = request.security(tf, 'high', high)
l = request.security(tf, 'low', low)
arr = dir == 'high' ? h : l
// فقط کندلهای وسط برگردد (نه اول و آخر)
for i=look to (bars_limit - look)
if pivot(arr, look, dir)
array.unshift(pivs, arr)
pivs
// بروزرسانی آرایه پیوتها (آخرین سطوح)
if barstate.islastconfirmedhistory
w1_pivothighs := get_pivots('W', search_bars, pivot_lookback, 'high')
w1_pivotlows := get_pivots('W', search_bars, pivot_lookback, 'low')
d1_pivothighs := get_pivots('D', search_bars, pivot_lookback, 'high')
d1_pivotlows := get_pivots('D', search_bars, pivot_lookback, 'low')
h4_pivothighs := get_pivots('240', search_bars, pivot_lookback, 'high')
h4_pivotlows := get_pivots('240', search_bars, pivot_lookback, 'low')
h1_pivothighs := get_pivots('60', search_bars, pivot_lookback, 'high')
h1_pivotlows := get_pivots('60', search_bars, pivot_lookback, 'low')
//--------------
// تابع رسم سطح
draw_lines(pivArr, line_color, label_txt, expiry) =>
int count = math.min(array.size(pivArr), 8)
for i=0 to (count-1)
y = array.get(pivArr, i)
// بررسی در 40 کندل اخیر برخورد بوده یا نه؟
touched = false
for c=0 to (expiry-1)
touched := touched or (low[c] <= y and high[c] >= y)
if touched
l = line.new(bar_index-expiry, y, bar_index, y, color=line_color, width=2, extend=extend.right)
if plot_labels
label.new(bar_index, y, label_txt, color=line_color, style=label.style_label_right, textcolor=color.white, size=label_size)
// اگر طی پیشفرض expiry کندل برخورد نشده بود، خط و لیبل رسم نشود (مخفی شود)
// رسم همه خطوط
draw_lines(w1_pivothighs, w1_color, 'W1', line_expire)
draw_lines(w1_pivotlows, w1_color, 'W1', line_expire)
draw_lines(d1_pivothighs, d1_color, 'D1', line_expire)
draw_lines(d1_pivotlows, d1_color, 'D1', line_expire)
draw_lines(h4_pivothighs, h4_color, 'H4', line_expire)
draw_lines(h4_pivotlows, h4_color, 'H4', line_expire)
draw_lines(h1_pivothighs, h1_color, 'H1', line_expire)
draw_lines(h1_pivotlows, h1_color, 'H1', line_expire)
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.