Professional Documents
Culture Documents
0 at
https://mozilla.org/MPL/2.0/
// © tradeforopp
//@version=5
indicator("ICT Killzones", "ICT-KZ", true, max_labels_count = 500, max_lines_count
= 500, max_boxes_count = 500)
// ---------------------------------------- Inputs
--------------------------------------------------
var g_SETTINGS = "设置"
max_days = input.int(5, "时区绘制限定数量", 1, tooltip = "Only this many
drawings will be kept on the chart, for each selected drawing type (killzone boxes,
pivot lines, open lines, etc.)", group = g_SETTINGS)
tf_limit = input.timeframe("60", "时间周期限定范围", tooltip = "Drawings
will not appear on timeframes greater than or equal to this", group = g_SETTINGS)
gmt_tz = input.string('GMT-4', "时区", options = ['GMT-12','GMT-
11','GMT-10','GMT-9','GMT-8','GMT-7','GMT-6','GMT-5','GMT-4','GMT-3','GMT-2','GMT-
1','GMT+0','GMT+1','GMT+2','GMT+3','GMT+4','GMT+5','GMT+6','GMT+7','GMT+8','GMT+9',
'GMT+10','GMT+11','GMT+12','GMT+13','GMT+14'], tooltip = "Note GMT is not adjusted
to reflect Daylight Saving Time changes", group = g_SETTINGS)
lb_size = input.string('Tiny', "标签字体大小", options = ['Auto', 'Tiny',
'Small', 'Normal', 'Large', 'Huge'], group = g_SETTINGS)
lb_color = input.color(color.black, "标签字体颜色", group = g_SETTINGS)
use_cutoff = input.bool(true, "绘制截止时间", inline = "CO", tooltip = "When
enabled, all highs and lows will stop extending after this time", group =
g_SETTINGS)
cutoff = input.session("1200-1201", "", inline = "CO", group =
g_SETTINGS)
transparent = #ffffff00
get_line_type(_style) =>
result = switch _style
'Solid' => line.style_solid
'Dotted' => line.style_dotted
'Dashed' => line.style_dashed
result
_hlabel.set_x(bar_index)
_hlabel.set_y(high)
if low < _lline.get_y1()
_lline.set_xy1(bar_index, low)
_lline.set_y2(low)
_box.set_bottom(low)
_llabel.set_x(bar_index)
_llabel.set_y(low)
check_high(_line) =>
result = false
broke = false
_line.set_x2(bar_index)
if high > _line.get_y1()
result := true
broke := true
else if (use_cutoff ? t_co : false)
result := true
[result, broke]
check_low(_line) =>
result = false
broke = false
_line.set_x2(bar_index)
if low < _line.get_y1()
result := true
broke := true
else if (use_cutoff ? t_co : false)
result := true
[result, broke]
check_array(_arr) =>
if _arr.size() > max_days
_arr.pop().delete()
// ---------------------------------------- Functions
--------------------------------------------------
lb_size := get_label_size(lb_size)
as_broke_hi = false
as_broke_lo = false
lo_broke_hi = false
lo_broke_lo = false
na_broke_hi = false
na_broke_lo = false
nl_broke_hi = false
nl_broke_lo = false
np_broke_hi = false
np_broke_lo = false
if show_kz
as_box.unshift(box.new(bar_index, high, bar_index, low,
border_color = as_box_color, bgcolor = as_box_color, text = show_kz_text ?
asia_text : na, text_color = as_text_color))
if as_label
as_hi_label.unshift(label.new(bar_index, high, ash_str, color =
transparent, textcolor = lb_color, style = label.style_label_down, size = lb_size))
as_lo_label.unshift(label.new(bar_index, low, asl_str, color =
transparent, textcolor = lb_color, style = label.style_label_up, size = lb_size))
else if t_as and as_box.size() > 0
adjust(as_hi_line.get(0), as_lo_line.get(0), as_label ?
as_hi_label.get(0) : na, as_label ? as_lo_label.get(0) : na, as_label, show_kz ?
as_box.get(0) : na)
else if not t_as and as_box.size() > 0
if not as_stop_hi
[_r, _b] = check_high(as_hi_line.get(0))
if _r
as_stop_hi := true
if _b
as_broke_hi := true
if as_alert
alert("Broke" + str.tostring(ash_str),
alert.freq_once_per_bar)
if not as_stop_lo
[_r, _b] = check_low(as_lo_line.get(0))
if _r
as_stop_lo := true
if _b
as_broke_lo := true
if as_alert
alert("Broke" + str.tostring(asl_str),
alert.freq_once_per_bar)
// London
if use_london
if t_lo and not t_lo[1]
lo_stop_hi := false
lo_stop_lo := false
if show_kz
lo_box.unshift(box.new(bar_index, high, bar_index, low,
border_color = lo_box_color, bgcolor = lo_box_color, text = show_kz_text ?
london_text : na, text_color = lo_text_color))
if lo_label
lo_hi_label.unshift(label.new(bar_index, high, loh_str, color =
transparent, textcolor = lb_color, style = label.style_label_down, size = lb_size))
lo_lo_label.unshift(label.new(bar_index, low, lol_str, color =
transparent, textcolor = lb_color, style = label.style_label_up, size = lb_size))
else if t_lo and lo_box.size() > 0
adjust(lo_hi_line.get(0), lo_lo_line.get(0), lo_label ?
lo_hi_label.get(0) : na, lo_label ? lo_lo_label.get(0) : na, lo_label, show_kz ?
lo_box.get(0) : na)
else if not t_lo and lo_box.size() > 0
if not lo_stop_hi
[_r, _b] = check_high(lo_hi_line.get(0))
if _r
lo_stop_hi := true
if _b
lo_broke_hi := true
if lo_alert
alert("Broke" + str.tostring(loh_str),
alert.freq_once_per_bar)
if not lo_stop_lo
[_r, _b] = check_low(lo_lo_line.get(0))
if _r
lo_stop_lo := true
if _b
lo_broke_lo := true
if lo_alert
alert("Broke" + str.tostring(lol_str),
alert.freq_once_per_bar)
// NY AM
if use_nyam
if t_na and not t_na[1]
na_stop_hi := false
na_stop_lo := false
if na_label
na_hi_label.unshift(label.new(bar_index, high, nah_str, color =
transparent, textcolor = lb_color, style = label.style_label_down, size = lb_size))
na_lo_label.unshift(label.new(bar_index, low, nal_str, color =
transparent, textcolor = lb_color, style = label.style_label_up, size = lb_size))
else if t_na and na_box.size() > 0
adjust(na_hi_line.get(0), na_lo_line.get(0), na_label ?
na_hi_label.get(0) : na, na_label ? na_lo_label.get(0) : na, na_label, show_kz ?
na_box.get(0) : na)
else if not t_na and na_box.size() > 0
if not na_stop_hi
[_r, _b] = check_high(na_hi_line.get(0))
if _r
na_stop_hi := true
if _b
na_broke_hi := true
if na_alert
alert("Broke" + str.tostring(nah_str),
alert.freq_once_per_bar)
if not na_stop_lo
[_r, _b] = check_low(na_lo_line.get(0))
if _r
na_stop_lo := true
if _b
na_broke_lo := true
if na_alert
alert("Broke" + str.tostring(nal_str),
alert.freq_once_per_bar)
// NY Lunch
if use_nylu
if t_nl and not t_nl[1]
nl_stop_hi := false
nl_stop_lo := false
if show_kz
nl_box.unshift(box.new(bar_index, high, bar_index, low,
border_color = nl_box_color, bgcolor = nl_box_color, text = show_kz_text ?
nylu_text : na, text_color = nl_text_color))
if nl_label
nl_hi_label.unshift(label.new(bar_index, high, nlh_str, color =
transparent, textcolor = lb_color, style = label.style_label_down, size = lb_size))
nl_lo_label.unshift(label.new(bar_index, low, nll_str, color =
transparent, textcolor = lb_color, style = label.style_label_up, size = lb_size))
else if t_nl and nl_box.size() > 0
adjust(nl_hi_line.get(0), nl_lo_line.get(0), nl_label ?
nl_hi_label.get(0) : na, nl_label ? nl_lo_label.get(0) : na, nl_label, show_kz ?
nl_box.get(0) : na)
else if not t_nl and nl_box.size() > 0
if not nl_stop_hi
[_r, _b] = check_high(nl_hi_line.get(0))
if _r
nl_stop_hi := true
if _b
nl_broke_hi := true
if nl_alert
alert("Broke" + str.tostring(nlh_str),
alert.freq_once_per_bar)
if not nl_stop_lo
[_r, _b] = check_low(nl_lo_line.get(0))
if _r
nl_stop_lo := true
if _b
nl_broke_lo := true
if nl_alert
alert("Broke" + str.tostring(nll_str),
alert.freq_once_per_bar)
// NY PM
if use_nypm
if t_np and not t_np[1]
np_stop_hi := false
np_stop_lo := false
if show_kz
np_box.unshift(box.new(bar_index, high, bar_index, low,
border_color = np_box_color, bgcolor = np_box_color, text = show_kz_text ?
nypm_text : na, text_color = np_text_color))
if np_label
np_hi_label.unshift(label.new(bar_index, high, nph_str, color =
transparent, textcolor = lb_color, style = label.style_label_down, size = lb_size))
np_lo_label.unshift(label.new(bar_index, low, npl_str, color =
transparent, textcolor = lb_color, style = label.style_label_up, size = lb_size))
else if t_np and np_box.size() > 0
adjust(np_hi_line.get(0), np_lo_line.get(0), np_hi_label.get(0),
np_lo_label.get(0), np_label, np_box.get(0))
else if not t_np and np_box.size() > 0
if not np_stop_hi
[_r, _b] = check_high(np_hi_line.get(0))
if _r
np_stop_hi := true
if _b
np_broke_hi := true
if np_alert
alert("Broke" + str.tostring(nph_str),
alert.freq_once_per_bar)
if not np_stop_lo
[_r, _b] = check_low(np_lo_line.get(0))
if _r
np_stop_lo := true
if _b
np_broke_lo := true
if np_alert
alert("Broke" + str.tostring(npl_str),
alert.freq_once_per_bar)
// Vertical Lines
if use_v1
if t_v1 and not t_v1[1]
v1_line.unshift(line.new(bar_index, high, bar_index, low, style =
v_style, width = v_width, extend = extend.both, color = v1_color))
if use_v2
if t_v2 and not t_v2[1]
v2_line.unshift(line.new(bar_index, high, bar_index, low, style =
v_style, width = v_width, extend = extend.both, color = v2_color))
if use_v3
if t_v3 and not t_v3[1]
v3_line.unshift(line.new(bar_index, high, bar_index, low, style =
v_style, width = v_width, extend = extend.both, color = v3_color))
if use_v4
if t_v4 and not t_v4[1]
v4_line.unshift(line.new(bar_index, high, bar_index, low, style =
v_style, width = v_width, extend = extend.both, color = v4_color))
// Horizontal Lines
if use_h1
if t_h1 and not t_h1[1]
h1_co := false
if use_h2
if t_h2 and not t_h2[1]
h2_co := false
if use_h3
if t_h3 and not t_h3[1]
h3_co := false
h3_line.unshift(line.new(bar_index, open, bar_index, open, style =
h_style, width = h_width, color = h3_color))
h3_label.unshift(label.new(bar_index, open, h3_text, style =
label.style_label_left, color = transparent, textcolor = lb_color, size = lb_size))
else if not t_h3 and h3_line.size() > 0
if not h3_co
if not check_open(h3_line.get(0), h3_label.get(0))
h3_label.get(0).set_x(bar_index)
else
h3_co := true
if use_h4
if t_h4 and not t_h4[1]
h4_co := false
// DWM - Separators
if ds
if d_o != d_o[1]
d_sep_line.unshift(line.new(bar_index, high, bar_index, low, style =
dwm_style, width = dwm_width, extend = extend.both, color = d_color))
if ws
if w_o != w_o[1]
w_sep_line.unshift(line.new(bar_index, high, bar_index, low, style =
dwm_style, width = dwm_width, extend = extend.both, color = w_color))
if ms
if m_o != m_o[1]
m_sep_line.unshift(line.new(bar_index, high, bar_index, low, style =
dwm_style, width = dwm_width, extend = extend.both, color = m_color))
if show_w_open
if w_o != w_o[1]
w_line.unshift(line.new(bar_index, w_o, bar_index, w_o, style =
dwm_style, width = dwm_width, color = w_color))
w_label.unshift(label.new(bar_index, w_o, w_open_str, style =
label.style_label_left, color = transparent, textcolor = lb_color, size = lb_size))
else if w_line.size() > 0
if not check_open(w_line.get(0), w_label.get(0))
w_label.get(0).set_x(bar_index)
if show_m_open
if m_o != m_o[1]
m_line.unshift(line.new(bar_index, m_o, bar_index, m_o, style =
dwm_style, width = dwm_width, color = m_color))
m_label.unshift(label.new(bar_index, m_o, m_open_str, style =
label.style_label_left, color = transparent, textcolor = lb_color, size = lb_size))
else if m_line.size() > 0
if not check_open(m_line.get(0), m_label.get(0))
m_label.get(0).set_x(bar_index)
check_array(as_hi_line)
check_array(as_lo_line)
check_array(as_hi_label)
check_array(as_lo_label)
check_array(as_box)
check_array(lo_hi_line)
check_array(lo_lo_line)
check_array(lo_hi_label)
check_array(lo_lo_label)
check_array(lo_box)
check_array(na_hi_line)
check_array(na_lo_line)
check_array(na_hi_label)
check_array(na_lo_label)
check_array(na_box)
check_array(nl_hi_line)
check_array(nl_lo_line)
check_array(nl_hi_label)
check_array(nl_lo_label)
check_array(nl_box)
check_array(np_hi_line)
check_array(np_lo_line)
check_array(np_hi_label)
check_array(np_lo_label)
check_array(np_box)
check_array(v1_line)
check_array(v2_line)
check_array(v3_line)
check_array(v4_line)
check_array(h1_line)
check_array(h2_line)
check_array(h3_line)
check_array(h4_line)
check_array(h1_label)
check_array(h2_label)
check_array(h3_label)
check_array(h4_label)
if not ds_unlimited
check_array(d_sep_line)
check_array(d_line)
check_array(d_label)
if not ws_unlimited
check_array(w_sep_line)
check_array(w_line)
check_array(w_label)
if not ms_unlimited
check_array(m_sep_line)
check_array(m_line)
check_array(m_label)