OPEN-SOURCE SCRIPT

High Low Yesterday & Today & Last Week & Last Month

Theo ca_varungupta
//version=5
indicator("High Low Yesterday & Today & Last Week & Last Month", overlay=true, shorttitle="High Low Y/T/LW/LM")

// User inputs
chk_yh = input(true, title="PDH")
chk_yl = input(true, title="PDL")
chk_th = input(true, title="Today's High")
chk_tl = input(true, title="Today's Low")
chk_lwh = input(true, title="Last Week's High")
chk_lwl = input(true, title="Last Week's Low")
chk_1mh = input(true, title="Last Month's High")
chk_1ml = input(true, title="Last Month's Low")
show_labels = input(true, title="Show Labels?")
size_labels = input.string("normal", title="Label Font Size", options=["large", "normal", "small"])
color_labels = input.color(color.black, title="Label Font Color")

// Get High & Low prices
yesterdayHigh = request.security(syminfo.tickerid, "D", high[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
yesterdayLow = request.security(syminfo.tickerid, "D", low[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
lastweekHigh = request.security(syminfo.tickerid, "W", high[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
lastweekLow = request.security(syminfo.tickerid, "W", low[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
lastmonthHigh = request.security(syminfo.tickerid, "M", high[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
lastmonthLow = request.security(syminfo.tickerid, "M", low[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
todayHigh = high
todayLow = low

// Plot High and Low levels
plot(chk_yh ? yesterdayHigh : na, linewidth=1, title="PDH", color=color.green)
plot(chk_yl ? yesterdayLow : na, linewidth=1, title="PDL", color=color.red)
plot(chk_th ? todayHigh : na, linewidth=1, title="Today's High", color=color.black)
plot(chk_tl ? todayLow : na, linewidth=1, title="Today's Low", color=color.maroon)
plot(chk_lwh ? lastweekHigh : na, linewidth=1, title="Last Week's High", color=color.navy)
plot(chk_lwl ? lastweekLow : na, linewidth=1, title="Last Week's Low", color=color.orange)
plot(chk_1mh ? lastmonthHigh : na, linewidth=1, title="Last Month's High", color=color.purple)
plot(chk_1ml ? lastmonthLow : na, linewidth=1, title="Last Month's Low", color=color.blue)

// Draw labels
if show_labels
if chk_yh
label.new(bar_index, yesterdayHigh, text="PDH", style=label.style_none, textcolor=color_labels, size=size_labels)
if chk_yl
label.new(bar_index, yesterdayLow, text="PDL", style=label.style_none, textcolor=color_labels, size=size_labels)
if chk_th
label.new(bar_index, todayHigh, text="Today's High", style=label.style_none, textcolor=color_labels, size=size_labels)
if chk_tl
label.new(bar_index, todayLow, text="Today's Low", style=label.style_none, textcolor=color_labels, size=size_labels)
if chk_lwh
label.new(bar_index, lastweekHigh, text="Week High", style=label.style_none, textcolor=color_labels, size=size_labels)
if chk_lwl
label.new(bar_index, lastweekLow, text="Week Low", style=label.style_none, textcolor=color_labels, size=size_labels)
if chk_1mh
label.new(bar_index, lastmonthHigh, text="Month High", style=label.style_none, textcolor=color_labels, size=size_labels)
if chk_1ml
label.new(bar_index, lastmonthLow, text="Month Low", style=label.style_none, textcolor=color_labels, size=size_labels)

// Alert conditions
alertcondition(ta.crossover(close, yesterdayHigh), title="Cross over Yesterday's High", message="Price crosses over yesterday's High")
alertcondition(ta.crossunder(close, yesterdayLow), title="Cross under Yesterday's Low", message="Price crosses under yesterday's Low")
alertcondition(ta.crossover(close, todayHigh), title="Cross over Today's High", message="Price crosses over today's High")
alertcondition(ta.crossunder(close, todayLow), title="Cross under Today's Low", message="Price crosses under today's Low")
alertcondition(ta.crossover(close, lastweekHigh), title="Cross over Last Week's High", message="Price crosses over last week's High")
alertcondition(ta.crossunder(close, lastweekLow), title="Cross under Last Week's Low", message="Price crosses under last week's Low")
alertcondition(ta.crossover(close, lastmonthHigh), title="Cross over Last Month's High", message="Price crosses over last month's High")
alertcondition(ta.crossunder(close, lastmonthLow), title="Cross under Last Month's Low", message="Price crosses under last month's Low")
Chart patterns

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Thông báo miễn trừ trách nhiệm