Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © Catered
- //@version=5
- indicator("ICT IPDA Daily Range", "ICT IPDA Daily Range", true, max_boxes_count = 500, max_labels_count = 500)
- // ---------------------------------------- Inputs --------------------------------------------------
- var g_SETTINGS = "Settings"
- max_days = input.int(5, "Session Drawing Limit", 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", "Timeframe Limit", tooltip = "Drawings will not appear on timeframes greater than or equal to this", group = g_SETTINGS)
- gmt_tz = input.string('GMT+3', "Timezone", 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('Normal', "Label Size", options = ['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group = g_SETTINGS)
- lb_color = input.color(color.black, "Label Text Color", group = g_SETTINGS)
- use_cutoff = input.bool(true, "Drawing Cutoff Time", inline = "CO", tooltip = "When enabled, all highs and lows will stop extending after this time", group = g_SETTINGS)
- cutoff = input.session("0000-0000", "", inline = "CO", group = g_SETTINGS)
- var g_KZ = "IPDA boxes"
- show_kz = input.bool(true, "Show IPDA boxes", inline = "KZ", group = g_KZ)
- show_kz_text = input.bool(true, "Display Text", inline = "KZ", group = g_KZ)
- box_transparency = input.int(70, "Box Transparency", 0, 100, group = g_KZ)
- text_transparency = input.int(50, "Text Transparency", 0, 100, group = g_KZ)
- var g_OPEN = "Opening Price"
- h_style = input.string(defval = 'Dotted', title = "Style", options = ['Solid', 'Dotted', 'Dashed'], inline = "H0", group = g_OPEN)
- h_width = input.int(1, "", inline = "H0", group = g_OPEN)
- use_h1 = input.bool(true, "", inline = "H1", group = g_OPEN)
- h1_text = input.string("Opening Price", "", inline = "H1", group = g_OPEN)
- h1 = input.session("0700-2200", "", inline = "H1", group = g_OPEN)
- h1_color = input.color(color.black, "", inline = "H1", group = g_OPEN)
- use_h2 = input.bool(false, "", inline = "H2", group = g_OPEN)
- h2_text = input.string("06:00", "", inline = "H2", group = g_OPEN)
- h2 = input.session("0600-0601", "", inline = "H2", group = g_OPEN)
- h2_color = input.color(color.black, "", inline = "H2", group = g_OPEN)
- var g_VERTICAL = "Timestamps"
- v_style = input.string(defval = 'Dotted', title = "Style", options = ['Solid', 'Dotted', 'Dashed'], inline = "V0", group = g_VERTICAL)
- v_width = input.int(1, "", inline = "V0", group = g_VERTICAL)
- use_v1 = input.bool(true, "", inline = "V1", group = g_VERTICAL)
- v1 = input.session("0700-0701", "IPDA_Start", inline = "V1", group = g_VERTICAL)
- v1_color = input.color(color.black, "", inline = "V1", group = g_VERTICAL)
- use_v2 = input.bool(true, "", inline = "V2", group = g_VERTICAL)
- v2 = input.session("2200-2201", "IPDA_End", inline = "V2", group = g_VERTICAL)
- v2_color = input.color(color.black, "", inline = "V2", group = g_VERTICAL)
- // ---------------------------------------- Inputs --------------------------------------------------
- box_info = input.bool(true, "info over box", "this will show the range of the session in pips (make sense only on forex)", "", "session in box")
- spec = input.int(70, "Transparency", 0, 100, 1, "from 0 to 100, how much you want the color transparent?", "", "Visual Features")
- // London Open session
- lno_ = input.bool(true, "London Open Killzone", "0800-1200 London", "", "Session")
- lno_b = input.bool(true, "London Open box", "", "", "session in box")
- lno_c = input.color(color.blue, "London Open Killzone", "", "", "Visual Features")
- // New York Open session
- nyo_ = input.bool(true, "New York Open Killzone", "1300-1600 London", "", "Session")
- nyo_b = input.bool(true, "New York Open box", "", "", "session in box")
- nyo_c = input.color(color.orange, "New York Open Killzone", "", "", "Visual Features")
- // London Close session
- lnc_ = input.bool(true, "London Close Killzone", "1700-1900 London", "", "Session")
- lnc_b = input.bool(true, "London Close box", "", "", "session in box")
- lnc_c = input.color(color.green, "London Close Killzone", "", "", "Visual Features")
- // Asian Range session
- asb_ = input.bool(true, "Asian Range", "0300-0700 London", "", "Session")
- asb_b = input.bool(true, "Asian Range box", "", "", "session in box")
- asb_c = input.color(color.yellow, "Asian Range", "", "", "Visual Features")
- // CBDR Range session
- cbdr_ = input.bool(true, "CBDR Range", "2100-0300 London", "", "Session")
- cbdr_b = input.bool(true, "CBDR Range box", "", "", "session in box")
- cbdr_c = input.color(color.purple, "CBDR Range", "", "", "Visual Features")
- // -------------------------------------------------- Inputs --------------------------------------------------
- cbdr_session = input.session("2100-0300", "Session", inline = "X", tooltip = "The time window whose range will be utilized for projections", group = g_SETTINGS)
- range_type = input.string('Wick', "Range Type", options = ['Wick', 'Body'], tooltip = "Wick will consider the range from high to low, whereas Body will ignore the wicks (on the current chart timeframe)", group = g_SETTINGS)
- sd_limit = input.float(1.5, "Standard Deviation Filter", tooltip = "Ranges will be filtered out/ignored if their size exceeds this number of standard deviations (measured from a history of all prior range sizes)", group = g_SETTINGS)
- var g_SD = "Standard Deviations"
- use_sd_1 = input.bool(true, "SD 1", inline = "SD1", tooltip = "The difference between the range high and low will be multiplied by this factor, added to the range high for the upper projection, and subtracted from the range low for the lower projection", group = g_SD)
- sd_1 = input.float(1, "", 0, inline = "SD1", group = g_SD)
- use_sd_2 = input.bool(true, "SD 2", inline = "SD2", tooltip = "The difference between the range high and low will be multiplied by this factor, added to the range high for the upper projection, and subtracted from the range low for the lower projection", group = g_SD)
- sd_2 = input.float(2, "", 0, inline = "SD2", group = g_SD)
- use_sd_3 = input.bool(true, "SD 3", inline = "SD3", tooltip = "The difference between the range high and low will be multiplied by this factor, added to the range high for the upper projection, and subtracted from the range low for the lower projection", group = g_SD)
- sd_3 = input.float(3, "", 0, inline = "SD3", group = g_SD)
- use_sd_4 = input.bool(true, "SD 4", inline = "SD4", tooltip = "The difference between the range high and low will be multiplied by this factor, added to the range high for the upper projection, and subtracted from the range low for the lower projection", group = g_SD)
- sd_4 = input.float(4, "", 0, inline = "SD4", group = g_SD)
- var g_DRW = "Drawings"
- show_data = input.bool(false, "Data Table", tooltip = "Shows statistics on how often price exceeds X number of standard deviations from the range", group = g_DRW)
- vert_lines = input.bool(false, "Session Delineations", tooltip = "Draws vertical lines delineating the session beginning and ending times", group = g_DRW)
- show_labels = input.bool(true, "SD Labels", tooltip = "Shows the numerical value of each projection level", group = g_DRW)
- horiz_lines = input.bool(true, "SD Projection Lines", tooltip = "Extends the projections out in time", group = g_DRW)
- show_exceed = input.bool(false, "SD Projections Exceeded", tooltip = "Shows when price exceeds any of the projection levels", group = g_DRW)
- var g_STY = "Style"
- range_box_color = input.color(color.new(color.blue, 70), "Range Box Color", group = g_STY)
- range_line_color = input.color(color.black, "Range Delineation Color", group = g_STY)
- label_color = input.color(#ffffff00, "SD Label Color", group = g_STY)
- label_text = input.color(color.black, "SD Label Text", group = g_STY)
- proj_color = input.color(color.new(color.gray, 70), "SD Projection Box Color", group = g_STY)
- proj_style = input.string('Dotted', "SD Projection Line Style", options = ['Solid', 'Dotted', 'Dashed'], group = g_STY)
- line_color = input.color(color.black, "SD Projection Line Color", group = g_STY)
- exceed_color = input.color(color.blue, "SD Exceeded Color", group = g_STY)
- // -------------------------------------------------- Inputs --------------------------------------------------
- // ---------------------------------------- Variables & Constants --------------------------------------------------
- t_co = not na(time("", cutoff, gmt_tz))
- t_h1 = not na(time("", h1, gmt_tz))
- t_h2 = not na(time("", h2, gmt_tz))
- t_v1 = not na(time("", v1, gmt_tz))
- t_v2 = not na(time("", v2, gmt_tz))
- var as_hi_line = array.new_line()
- var as_lo_line = array.new_line()
- var lo_hi_line = array.new_line()
- var lo_lo_line = array.new_line()
- var na_hi_line = array.new_line()
- var na_lo_line = array.new_line()
- var nl_hi_line = array.new_line()
- var nl_lo_line = array.new_line()
- var np_hi_line = array.new_line()
- var np_lo_line = array.new_line()
- var d_sep_line = array.new_line()
- var w_sep_line = array.new_line()
- var m_sep_line = array.new_line()
- var d_line = array.new_line()
- var w_line = array.new_line()
- var m_line = array.new_line()
- var h1_line = array.new_line()
- var h2_line = array.new_line()
- var h3_line = array.new_line()
- var h4_line = array.new_line()
- var v1_line = array.new_line()
- var v2_line = array.new_line()
- var v3_line = array.new_line()
- var v4_line = array.new_line()
- var d_label = array.new_label()
- var w_label = array.new_label()
- var m_label = array.new_label()
- var h1_label = array.new_label()
- var h2_label = array.new_label()
- var h3_label = array.new_label()
- var h4_label = array.new_label()
- var as_hi_label = array.new_label()
- var as_lo_label = array.new_label()
- var lo_hi_label = array.new_label()
- var lo_lo_label = array.new_label()
- var na_hi_label = array.new_label()
- var na_lo_label = array.new_label()
- var nl_hi_label = array.new_label()
- var nl_lo_label = array.new_label()
- var np_hi_label = array.new_label()
- var np_lo_label = array.new_label()
- var as_box = array.new_box()
- var lo_box = array.new_box()
- var na_box = array.new_box()
- var nl_box = array.new_box()
- var np_box = array.new_box()
- transparent = #ffffff00
- d_o = request.security(syminfo.tickerid, "D", open, barmerge.gaps_off, barmerge.lookahead_on)
- w_o = request.security(syminfo.tickerid, "W", open, barmerge.gaps_off, barmerge.lookahead_on)
- m_o = request.security(syminfo.tickerid, "M", open, barmerge.gaps_off, barmerge.lookahead_on)
- // ---------------------------------------- Variables & Constants --------------------------------------------------
- b_color = color.new(#000000,50)
- lno = time('', '0800-1201', gmt_tz) and lno_ and timeframe.isintraday and timeframe.multiplier <= 60
- nyo = time('', '1300-1601', gmt_tz) and nyo_ and timeframe.isintraday and timeframe.multiplier <= 60
- lnc = time('', '1700-1901', gmt_tz) and lnc_ and timeframe.isintraday and timeframe.multiplier <= 60
- asb = time('', '0300-0701', gmt_tz) and asb_ and timeframe.isintraday and timeframe.multiplier <= 60
- cbdr = time('', '2100-0301', gmt_tz) and cbdr_ and timeframe.isintraday and timeframe.multiplier <= 60
- bgcolor(lno and not lno_b and lno_? color.new(lno_c, spec) : na)
- bgcolor(nyo and not nyo_b and nyo_? color.new(nyo_c, spec) : na)
- bgcolor(lnc and not lnc_b and lnc_? color.new(lnc_c, spec) : na)
- bgcolor(asb and not asb_b and asb_? color.new(asb_c, spec) : na)
- bgcolor(cbdr and not cbdr_b and cbdr_? color.new(cbdr_c, spec) : na)
- var box lno_box = na
- var box nyo_box = na
- var box lnc_box = na
- var box asb_box = na
- var box cbdr_box = na
- var box upper_cbdr_box =na
- var box lower_cbdr_box =na
- var label lno_l = na
- var label nyo_l = na
- var label lnc_l = na
- var label asb_l = na
- var label cbdr_l = na
- var label upper_cbdr_l = na
- var label lower_cbdr_l = na
- // -------------------------------------------------- Constants & Variables --------------------------------------------------
- t = not na(time("", cbdr_session, gmt_tz))
- range_wick = range_type == 'Wick'
- range_high = (range_wick ? high : math.max(open, close))
- range_low = (range_wick ? low : math.min(open, close))
- var range_size = array.new_float()
- var box range_box = na
- var box proj_p1 = na
- var box proj_m1 = na
- var box proj_p2 = na
- var box proj_m2 = na
- var box proj_p3 = na
- var box proj_m3 = na
- var box proj_p4 = na
- var box proj_m4 = na
- var int start = 0
- var int sessions = 0
- var bool valid_range = false
- var bool passed_p1 = false
- var bool passed_p2 = false
- var bool passed_p3 = false
- var bool passed_p4 = false
- var bool passed_m1 = false
- var bool passed_m2 = false
- var bool passed_m3 = false
- var bool passed_m4 = false
- var int count_p1 = 0
- var int count_p2 = 0
- var int count_p3 = 0
- var int count_p4 = 0
- var int count_m1 = 0
- var int count_m2 = 0
- var int count_m3 = 0
- var int count_m4 = 0
- var int count_a1 = 0
- var int count_a2 = 0
- var int count_a3 = 0
- var int count_a4 = 0
- var line line_p1 = na
- var line line_p2 = na
- var line line_p3 = na
- var line line_p4 = na
- var line line_m1 = na
- var line line_m2 = na
- var line line_m3 = na
- var line line_m4 = na
- // -------------------------------------------------- Constants & Variables --------------------------------------------------
- // ---------------------------------------- Functions --------------------------------------------------
- get_label_size(_size) =>
- result = switch _size
- 'Tiny' => size.tiny
- 'Small' => size.small
- 'Normal' => size.normal
- 'Large' => size.large
- 'Huge' => size.huge
- 'Auto' => size.auto
- result
- get_line_type(_style) =>
- result = switch _style
- 'Solid' => line.style_solid
- 'Dotted' => line.style_dotted
- 'Dashed' => line.style_dashed
- result
- get_box_color(_color, _transparency) =>
- result = color.new(_color, _transparency)
- adjust(_hline, _lline, _hlabel, _llabel, _ulabel, _box) =>
- _hline.set_x2(bar_index)
- _lline.set_x2(bar_index)
- _box.set_right(bar_index)
- if high > _hline.get_y1()
- _hline.set_xy1(bar_index, high)
- _hline.set_y2(high)
- _box.set_top(high)
- _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_open(_line, _label) =>
- result = false
- _line.set_x2(bar_index)
- _label.set_x(bar_index)
- if (use_cutoff ? t_co : false)
- result := true
- result
- check_array(_arr) =>
- if _arr.size() > max_days
- _arr.pop().delete()
- // ---------------------------------------- Functions --------------------------------------------------
- // -------------------------------------------------- Functions --------------------------------------------------
- manual_stdev() =>
- mean = range_size.avg()
- accum = 0.0
- size = range_size.size()
- if size > 0
- for i = 0 to size - 1
- accum += math.pow((range_size.get(i) - mean), 2)
- sd = math.sqrt(accum / size)
- get_line_style(i) =>
- result = switch i
- 'Solid' => line.style_solid
- 'Dashed' => line.style_dashed
- 'Dotted' => line.style_dotted
- proj_style := get_line_style(proj_style)
- // -------------------------------------------------- Functions --------------------------------------------------
- // ---------------------------------------- Core Logic --------------------------------------------------
- h_style := get_line_type(h_style)
- v_style := get_line_type(v_style)
- lb_size := get_label_size(lb_size)
- var h1_co = false
- var h2_co = false
- if lno_ and lno_b and timeframe.multiplier<=60 and timeframe.isintraday
- if lno and not lno[1]
- lno_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(lno_c,spec))
- if box_info
- lno_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #000000, size = size.small,style = label.style_none)
- if lno and lno[1]
- if high > box.get_top(lno_box)
- box.set_top(lno_box,high)
- if low < box.get_bottom(lno_box)
- box.set_bottom(lno_box,low)
- box.set_right(lno_box,bar_index+1)
- if box_info
- label.set_text(lno_l,str.tostring((box.get_top(lno_box)-box.get_bottom(lno_box))/10/syminfo.mintick)+" pip")
- label.set_x(lno_l,(box.get_left(lno_box)+box.get_right(lno_box))/2)
- label.set_y(lno_l,box.get_top(lno_box))
- if not lno and lno[1]
- box.set_right(lno_box,bar_index-1)
- if nyo_ and nyo_b and timeframe.multiplier<=60 and timeframe.isintraday
- if nyo and not nyo[1]
- nyo_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(nyo_c,spec))
- if box_info
- nyo_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #000000, size = size.small,style = label.style_none)
- if nyo and nyo[1]
- if high > box.get_top(nyo_box)
- box.set_top(nyo_box,high)
- if low < box.get_bottom(nyo_box)
- box.set_bottom(nyo_box,low)
- box.set_right(nyo_box,bar_index+1)
- if box_info
- label.set_text(nyo_l,str.tostring((box.get_top(nyo_box)-box.get_bottom(nyo_box))/10/syminfo.mintick)+" pip")
- label.set_x(nyo_l,(box.get_left(nyo_box)+box.get_right(nyo_box))/2)
- label.set_y(nyo_l,box.get_top(nyo_box))
- if not nyo and nyo[1]
- box.set_right(nyo_box,bar_index-1)
- if lnc_ and lnc_b and timeframe.multiplier<=60 and timeframe.isintraday
- if lnc and not lnc[1]
- lnc_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(lnc_c,spec))
- if box_info
- lnc_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #000000, size = size.small,style = label.style_none)
- if lnc and lnc[1]
- if high > box.get_top(lnc_box)
- box.set_top(lnc_box,high)
- if low < box.get_bottom(lnc_box)
- box.set_bottom(lnc_box,low)
- box.set_right(lnc_box,bar_index+1)
- if box_info
- label.set_text(lnc_l,str.tostring((box.get_top(lnc_box)-box.get_bottom(lnc_box))/10/syminfo.mintick)+" pip")
- label.set_x(lnc_l,(box.get_left(lnc_box)+box.get_right(lnc_box))/2)
- label.set_y(lnc_l,box.get_top(lnc_box))
- if not lnc and lnc[1]
- box.set_right(lnc_box,bar_index-1)
- if asb_ and asb_b and timeframe.multiplier<=60 and timeframe.isintraday
- if asb and not asb[1]
- asb_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(asb_c,spec))
- if box_info
- asb_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #000000, size = size.small,style = label.style_none)
- if asb and asb[1]
- if high > box.get_top(asb_box)
- box.set_top(asb_box,high)
- if low < box.get_bottom(asb_box)
- box.set_bottom(asb_box,low)
- box.set_right(asb_box,bar_index+1)
- if box_info
- label.set_text(asb_l,str.tostring((box.get_top(asb_box)-box.get_bottom(asb_box))/10/syminfo.mintick)+" pip")
- label.set_x(asb_l,(box.get_left(asb_box)+box.get_right(asb_box))/2)
- label.set_y(asb_l,box.get_top(asb_box))
- if not asb and asb[1]
- box.set_right(asb_box,bar_index-1)
- if cbdr_ and cbdr_b and timeframe.multiplier<=60 and timeframe.isintraday
- if cbdr and not cbdr[1]
- cbdr_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(cbdr_c,spec))
- if box_info
- cbdr_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #000000, size = size.small,style = label.style_none)
- if cbdr and cbdr[1]
- if high > box.get_top(cbdr_box)
- box.set_top(cbdr_box,high)
- if low < box.get_bottom(cbdr_box)
- box.set_bottom(cbdr_box,low)
- box.set_right(cbdr_box,bar_index+1)
- if box_info
- label.set_text(cbdr_l,str.tostring((box.get_top(cbdr_box)-box.get_bottom(cbdr_box))/10/syminfo.mintick)+" pip")
- label.set_x(cbdr_l,(box.get_left(cbdr_box)+box.get_right(cbdr_box))/2)
- label.set_y(cbdr_l,box.get_top(cbdr_box))
- if not cbdr and cbdr[1]
- box.set_right(cbdr_box,bar_index-1)
- // 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))
- // Horizontal Lines
- if use_h1 and timeframe.multiplier<=60
- if t_h1 and not t_h1[1]
- h1_co := false
- h1_line.unshift(line.new(bar_index, open, bar_index, open, style = h_style, width = h_width, color = h1_color))
- h1_label.unshift(label.new(bar_index, open, h1_text, style = label.style_label_left, color = transparent, textcolor = lb_color, size = lb_size))
- else if not t_h1 and h1_line.size() > 0
- if not h1_co
- if not check_open(h1_line.get(0), h1_label.get(0))
- h1_label.get(0).set_x(bar_index)
- else
- h1_co := true
- // -------------------------------------------------- CBDR projection logic --------------------------------------------------
- if t and not t[1]
- range_box := box.new(bar_index, range_high, bar_index+1, range_low, border_color = range_box_color, bgcolor = range_box_color)
- start := bar_index
- valid_range := false
- if vert_lines
- line.new(bar_index, high, bar_index, low, extend = extend.both, color = range_line_color)
- else if t
- range_box.set_right(bar_index+1)
- if range_high > range_box.get_top()
- range_box.set_top(range_high)
- if range_low < range_box.get_bottom()
- range_box.set_bottom(range_low)
- else if not t and t[1]
- top = range_box.get_top()
- bot = range_box.get_bottom()
- dif = top - bot
- range_size.push(dif)
- range_box := na
- line_p1 := na
- if vert_lines
- line.new(bar_index - 1, high, bar_index - 1, low, extend = extend.both, color = range_line_color)
- if dif <= manual_stdev() * sd_limit
- valid_range := true
- sessions += 1
- if use_sd_1
- proj_p1 := box.new(start, top + dif * sd_1, bar_index , top, border_color = proj_color, bgcolor = proj_color)
- if show_labels
- label.new(bar_index, top + dif * sd_1, str.tostring(sd_1), textcolor = label_text, color = label_color, style = label.style_label_lower_left)
- if horiz_lines
- line_p1 := line.new(bar_index - 1, top + dif * sd_1, bar_index + 1, top + dif * sd_1, color = line_color, style = proj_style)
- if use_sd_2
- proj_p2 := box.new(start, top + dif * sd_2, bar_index , top + dif * sd_1, border_color = proj_color, bgcolor = proj_color)
- if show_labels
- label.new(bar_index, top + dif * sd_2, str.tostring(sd_2), textcolor = label_text, color = label_color, style = label.style_label_lower_left)
- if horiz_lines
- line_p2 := line.new(bar_index - 1, top + dif * sd_2, bar_index + 1, top + dif * sd_2, color = line_color, style = proj_style)
- if use_sd_3
- proj_p3 := box.new(start, top + dif * sd_3, bar_index, top + dif * sd_2, border_color = proj_color, bgcolor = proj_color)
- if show_labels
- label.new(bar_index, top + dif * sd_3, str.tostring(sd_3), textcolor = label_text, color = label_color, style = label.style_label_lower_left)
- if horiz_lines
- line_p3 := line.new(bar_index - 1, top + dif * sd_3, bar_index + 1, top + dif * sd_3, color = line_color, style = proj_style)
- if use_sd_4
- proj_p4 := box.new(start, top + dif * sd_4, bar_index, top + dif * sd_3, border_color = proj_color, bgcolor = proj_color)
- if show_labels
- label.new(bar_index, top + dif * sd_4, str.tostring(sd_4), textcolor = label_text, color = label_color, style = label.style_label_lower_left)
- if horiz_lines
- line_p4 := line.new(bar_index - 1, top + dif * sd_4, bar_index + 1, top + dif * sd_4, color = line_color, style = proj_style)
- if use_sd_1
- proj_m1 := box.new(start, bot, bar_index, bot - dif * sd_1, border_color = proj_color, bgcolor = proj_color)
- if show_labels
- label.new(bar_index, bot - dif * sd_1, "-" + str.tostring(sd_1), textcolor = label_text, color = label_color, style = label.style_label_upper_left)
- if horiz_lines
- line_m1 := line.new(bar_index - 1, bot - dif * sd_1, bar_index + 1, bot - dif * sd_1, color = line_color, style = proj_style)
- if use_sd_2
- proj_m2 := box.new(start, bot - dif * sd_1, bar_index, bot - dif * sd_2, border_color = proj_color, bgcolor = proj_color)
- if show_labels
- label.new(bar_index, bot - dif * sd_2, "-" + str.tostring(sd_2), textcolor = label_text, color = label_color, style = label.style_label_upper_left)
- if horiz_lines
- line_m2 := line.new(bar_index - 1, bot - dif * sd_2, bar_index + 1, bot - dif * sd_2, color = line_color, style = proj_style)
- if use_sd_3
- proj_m3 := box.new(start, bot - dif * sd_2, bar_index, bot - dif * sd_3, border_color = proj_color, bgcolor = proj_color)
- if show_labels
- label.new(bar_index, bot - dif * sd_3, "-" + str.tostring(sd_3), textcolor = label_text, color = label_color, style = label.style_label_upper_left)
- if horiz_lines
- line_m3 := line.new(bar_index - 1, bot - dif * sd_3, bar_index + 1, bot - dif * sd_3, color = line_color, style = proj_style)
- if use_sd_4
- proj_m4 := box.new(start, bot - dif * sd_3, bar_index, bot - dif * sd_4, border_color = proj_color, bgcolor = proj_color)
- if show_labels
- label.new(bar_index, bot - dif * sd_4, "-" + str.tostring(sd_4), textcolor = label_text, color = label_color, style = label.style_label_upper_left)
- if horiz_lines
- line_m4 := line.new(bar_index - 1, bot - dif * sd_4, bar_index + 1, bot - dif * sd_4, color = line_color, style = proj_style)
- else if not t
- if horiz_lines and not na(line_p1)
- line_p1.set_x2(bar_index + 1)
- line_p2.set_x2(bar_index + 1)
- line_p3.set_x2(bar_index + 1)
- line_p4.set_x2(bar_index + 1)
- line_m1.set_x2(bar_index + 1)
- line_m2.set_x2(bar_index + 1)
- line_m3.set_x2(bar_index + 1)
- line_m4.set_x2(bar_index + 1)
- if not t and valid_range
- if high > proj_p1.get_top() and not passed_p1
- passed_p1 := true
- if show_exceed
- label.new(bar_index, proj_p1.get_top(), str.tostring(sd_1), style = label.style_label_down, color = exceed_color, textcolor = label_text)
- if high > proj_p2.get_top() and not passed_p2
- passed_p2 := true
- if show_exceed
- label.new(bar_index, proj_p2.get_top(), str.tostring(sd_2), style = label.style_label_down, color = exceed_color, textcolor = label_text)
- if high > proj_p3.get_top() and not passed_p3
- passed_p3 := true
- if show_exceed
- label.new(bar_index, proj_p3.get_top(), str.tostring(sd_3), style = label.style_label_down, color = exceed_color, textcolor = label_text)
- if high > proj_p4.get_top() and not passed_p4
- passed_p4 := true
- if show_exceed
- label.new(bar_index, proj_p4.get_top(), str.tostring(sd_4), style = label.style_label_down, color = exceed_color, textcolor = label_text)
- if low < proj_m1.get_bottom() and not passed_m1
- passed_m1 := true
- if show_exceed
- label.new(bar_index, proj_m1.get_bottom(), "-" + str.tostring(sd_1), style = label.style_label_up, color = exceed_color, textcolor = label_text)
- if low < proj_m2.get_bottom() and not passed_m2
- passed_m2 := true
- if show_exceed
- label.new(bar_index, proj_m2.get_bottom(), "-" + str.tostring(sd_2), style = label.style_label_up, color = exceed_color, textcolor = label_text)
- if low < proj_m3.get_bottom() and not passed_m3
- passed_m3 := true
- if show_exceed
- label.new(bar_index, proj_m3.get_bottom(), "-" + str.tostring(sd_3), style = label.style_label_up, color = exceed_color, textcolor = label_text)
- if low < proj_m4.get_bottom() and not passed_m4
- passed_m4 := true
- if show_exceed
- label.new(bar_index, proj_m4.get_bottom(), "-" + str.tostring(sd_4), style = label.style_label_up, color = exceed_color, textcolor = label_text)
- else if t and not t[1]
- if passed_p1 or passed_m1
- count_a1 += 1
- if passed_p2 or passed_m2
- count_a2 += 1
- if passed_p3 or passed_m3
- count_a3 += 1
- if passed_p4 or passed_m4
- count_a4 += 1
- passed_p1 := false
- passed_p2 := false
- passed_p3 := false
- passed_p4 := false
- passed_m1 := false
- passed_m2 := false
- passed_m3 := false
- passed_m4 := false
- // -------------------------------------------------- Core Logic --------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement