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/
- // © sabricat
- //@version=5
- indicator("TMB Levels", overlay=true, max_lines_count=500, max_labels_count=500)
- tf = input.string("60", "Timeframe")
- src = input.string('High & Low', options=['High & Low', 'Open & Close'], title='Source')
- hi_show = input.bool(true, "Top ", inline="high")
- hi_col = input.color(color.green, title="", inline="high")
- hi_width = input.int(1, "Width", inline="high")
- hi_style = input.string("Dashed", "", ["Solid", "Dashed", "Dotted"], inline="high")
- mi_show = input.bool(true, "Mid ", inline="mid")
- mi_col = input.color(color.blue, title="", inline="mid")
- mi_width = input.int(2, "Width", inline="mid")
- mi_style = input.string("Solid", "", ["Solid", "Dashed", "Dotted"], inline="mid")
- lo_show = input.bool(true, "Bottom ", inline="low")
- lo_col = input.color(color.red, title="", inline="low")
- lo_width = input.int(1, "Width", inline="low")
- lo_style = input.string("Dashed", "", ["Solid", "Dashed", "Dotted"], inline="low")
- co_show = input.bool(true, "Line chart", inline="line_chart")
- co_col = input.color(color.yellow, title="", inline="line_chart")
- co_width = input.int(2, "Width", inline="line_chart")
- co_style = input.string("Solid", "", ["Solid", "Dashed", "Dotted"], inline="line_chart")
- f(src) =>
- v_ = src == 'High & Low' ? ((high - low) / 2 + low) : (math.abs((close - open) / 2) + math.min(close, open))
- lh_ = src == 'High & Low' ? high : math.max(open, close)
- ll_ = src == 'High & Low' ? low : math.min(open, close)
- [v_, lh_, ll_]
- get_line_style(style_) =>
- switch style_
- "Solid" => line.style_solid
- "Dashed" => line.style_dashed
- "Dotted" => line.style_dotted
- [v, lh, ll] = request.security(syminfo.tickerid, tf, f(src))
- changed = ta.change(time(tf)) != 0
- var int last_mid_time = na
- var float last_mid_price = na
- var line li = na
- var line lih = na
- var line lil = na
- var line lic = na
- if not na(lih)
- if hi_show
- lih.set_y1(lh)
- lih.set_y2(lh)
- lih.set_x2(time)
- if not na(li)
- if mi_show
- li.set_y1(v)
- li.set_y2(v)
- li.set_x2(time)
- if not na(lil)
- if lo_show
- lil.set_y1(ll)
- lil.set_y2(ll)
- lil.set_x2(time)
- if not na(lic)
- if co_show
- lic.set_y2(v)
- lic.set_x2(time)
- if changed
- last_mid_time := time
- last_mid_price := v
- if hi_show
- lih := line.new(time, lh, time, lh, xloc=xloc.bar_time, width=hi_width, color=hi_col, style=get_line_style(hi_style))
- if mi_show
- li := line.new(time, v, time, v, xloc=xloc.bar_time, width=mi_width, color=mi_col, style=get_line_style(mi_style))
- if lo_show
- lil := line.new(time, ll, time, ll, xloc=xloc.bar_time, width=lo_width, color=lo_col, style=get_line_style(lo_style))
- if co_show
- lic := line.new(last_mid_time, last_mid_price, time, v, xloc=xloc.bar_time, width=co_width, color=co_col, style=get_line_style(co_style))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement