//version=5 indicator("Custom Horizontal Ray Indicator", overlay=true)
// تنظیم تعداد کندلهای بررسیشده length = 7200
// متغیرهای ذخیره خطوط var greenLines = array.new_line() var redLines = array.new_line()
// تابعی برای رسم خط و افزودن به آرایه draw_line(array, price, color) => var l = line.new(x1=bar_index, y1=price, x2=bar_index + 1000, y2=price, color=color, width=2) array.push(array, l)
// بررسی کندلهای صعودی (A) و رسم خطوط سبز if (close > open) and (high[1] < (low + high) / 2) draw_line(greenLines, high[1], color.green)
// بررسی کندلهای نزولی (B) و رسم خطوط قرمز if (close < open) and (low[1] > (low + high) / 2) draw_line(redLines, low[1], color.red)
// تابعی برای حذف خطوط هنگام برخورد قیمت remove_lines(array, is_green) => for i = array.size(array) - 1 to 0 var l = array.get(array, i) var line_price = line.get_y1(l) if (is_green and high >= line_price) or (not is_green and low <= line_price) line.delete(l) array.remove(array, i)
// حذف خطوط سبز هنگام برخورد قیمت remove_lines(greenLines, true)
// حذف خطوط قرمز هنگام برخورد قیمت remove_lines(redLines, false)
// تعریف شرایط اعلانها در بخش سراسری greenLineCondition = array.size(greenLines) > 0 and high >= line.get_y1(array.get(greenLines, array.size(greenLines) - 1)) redLineCondition = array.size(redLines) > 0 and low <= line.get_y1(array.get(redLines, array.size(redLines) - 1))
// ایجاد اعلانها برای خطوط سبز alertcondition(greenLineCondition, title="برخورد با خط سبز", message="قیمت به خط سبز برخورد کرد")
// ایجاد اعلانها برای خطوط قرمز alertcondition(redLineCondition, title="برخورد با خط قرمز", message="قیمت به خط قرمز برخورد کرد")
No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.