//@version=5 indicator('SG Levels', shorttitle='SGL', overlay=true) text_1 = input.string('', title='SG Text', confirm=true) ColNum = input.int(1, title='Column Number', maxval=2, minval=1) - 1 LineColor = input(color.aqua, title='Line Color') lsty = input.string('Solid', title='Line Style', options=['Solid', 'Dashed', 'Dotted']) SGI_H_LineColor = input(color.lime, title='SGI High Line Color') SGI_L_LineColor = input(color.red, title='SGI Low Line Color') SGI_lsty = input.string('Dotted', title='Line Style', options=['Solid', 'Dashed', 'Dotted']) EnableLabels = input(true, title='Enable Line Labels') LabelTextColor = LineColor LabelOffset = input.int(100, title='Label Offset', maxval=500, minval=1) label_fs = input.string('Medium', title='Trade Label Size', options=['Auto', 'Small', 'Medium', 'Large']) label_font_size = label_fs == 'Auto' ? size.auto : label_fs == 'Small' ? size.small : label_fs == 'Large' ? size.large : size.normal line_style(lsty) => lsty == 'Dashed' ? line.style_dashed : lsty == 'Dotted' ? line.style_dotted : lsty == 'Solid' ? line.style_solid : na draw_hline(start, end, price, line_color, lsty) => var line _line = na _line := line.new(bar_index - start, price, bar_index - end, price, xloc=xloc.bar_index, style=line_style(lsty), color=line_color, extend=extend.both, width=2) _line draw_Text(_text, _x, _y, font_size, text_color) => var label la_panel = na label.delete(la_panel) la_panel := label.new(x=bar_index + _x, y=_y, text=_text, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_none, textcolor=text_color, size=font_size) la_panel outA_text = str.replace_all(text_1, 'Date: ', 'Date:_') outB_text = str.replace_all(outA_text, 'y S', 'y_S') outC_text = str.replace_all(outB_text, 'a L', 'a_L') out0_text = str.replace_all(outC_text, 'SPX PX', 'SPX_PX') out1_text = str.replace_all(out0_text, 'ES PX', 'ES_PX') out2_text = str.replace_all(out1_text, 'l I', 'l_I') out3_text = str.replace_all(out2_text, 'e G', 'e_G') out4_text = str.replace_all(out3_text, 'l W', 'l_W') out5_text = str.replace_all(out4_text, 'o G', 'o_G') out6_text = str.replace_all(out5_text, 'l T', 'l_T') out7_text = str.replace_all(out6_text, 't W', 't_W') out8_text = str.replace_all(out7_text, 'I I', 'I_I') out9_text = str.replace_all(out8_text, ' / ', '/') out10_text = str.replace_all(out9_text, 'NDX PX', 'NDX_PX') out11_text = str.replace_all(out10_text, 'NQ PX', 'NQ_PX') out12_text = str.replace_all(out11_text, 'RUT PX', 'RUT_PX') out13_text = str.replace_all(out12_text, 'RTY PX', 'RTY_PX') out14_text = str.replace_all(out13_text, 'SPY PX', 'SPY_PX') out_array = str.split(out14_text, ' ') c_s = "\t" out_array_s = array.size(out_array) - 1 getPrice(i) => var float out = na if out_array_s >= i parsed = array.get(str.split(array.get(out_array, i), c_s), ColNum) out := parsed == "-" ? na : str.tonumber(parsed) out L1A = getPrice(3) L2A = getPrice(4) L3A = getPrice(5) L4A = getPrice(6) L5A = getPrice(7) L6A = getPrice(8) L7A = getPrice(9) L8A = getPrice(10) L9A = getPrice(11) L10A = getPrice(12) L11A = getPrice(13) L12A = getPrice(14) L13A = getPrice(15) float LSGI_H = na float LSGI_L = na if str.contains(text_1, "SGI Imp.:") iLSGI = array.get(str.split(array.get(out_array, out_array_s), c_s), 2) LSGI_0 = str.tonumber(array.get(str.split(iLSGI, '/'), 0)) LSGI_1 = str.tonumber(array.get(str.split(iLSGI, '/'), 1)) LSGI_H := math.max(LSGI_0, LSGI_1) LSGI_L := math.min(LSGI_0, LSGI_1) else LSGI_H := na LSGI_L := na draw_hline(100, 0, L1A, LineColor, lsty) draw_hline(100, 0, L2A, LineColor, lsty) draw_hline(100, 0, L3A, LineColor, lsty) draw_hline(100, 0, L4A, LineColor, lsty) draw_hline(100, 0, L5A, LineColor, lsty) draw_hline(100, 0, L6A, LineColor, lsty) draw_hline(100, 0, L7A, LineColor, lsty) draw_hline(100, 0, L8A, LineColor, lsty) draw_hline(100, 0, L9A, LineColor, lsty) draw_hline(100, 0, L10A, LineColor, lsty) draw_hline(100, 0, L11A, LineColor, lsty) draw_hline(100, 0, L12A, LineColor, lsty) draw_hline(100, 0, L13A, LineColor, lsty) if str.contains(text_1, "SGI Imp.:") draw_hline(100, 0, LSGI_H, SGI_H_LineColor, SGI_lsty) draw_hline(100, 0, LSGI_L, SGI_L_LineColor, SGI_lsty) getLabel(i) => out_array_s >= i ? array.get(str.split(array.get(out_array, i), c_s), 2) : na L1C = getLabel(3) L2C = getLabel(4) L3C = getLabel(5) L4C = getLabel(6) L5C = getLabel(7) L6C = getLabel(8) L7C = getLabel(9) L8C = getLabel(10) L9C = getLabel(11) L10C = getLabel(12) L11C = getLabel(13) L12C = getLabel(14) L13C = getLabel(15) string SGI_H_Lbl = na string SGI_L_Lbl = na if str.contains(text_1, "SGI Imp.:") SGI_H_Lbl := array.get(str.split(array.get(out_array, out_array_s), c_s), 0) + 'High' SGI_L_Lbl := array.get(str.split(array.get(out_array, out_array_s), c_s), 0) + 'Low' SGI_L_Lbl if EnableLabels draw_Text(L1C, LabelOffset, L1A, label_font_size, LabelTextColor) draw_Text(L2C, LabelOffset, L2A, label_font_size, LabelTextColor) draw_Text(L3C, LabelOffset, L3A, label_font_size, LabelTextColor) draw_Text(L4C, LabelOffset, L4A, label_font_size, LabelTextColor) draw_Text(L5C, LabelOffset, L5A, label_font_size, LabelTextColor) draw_Text(L6C, LabelOffset, L6A, label_font_size, LabelTextColor) draw_Text(L7C, LabelOffset, L7A, label_font_size, LabelTextColor) draw_Text(L8C, LabelOffset, L8A, label_font_size, LabelTextColor) draw_Text(L9C, LabelOffset, L9A, label_font_size, LabelTextColor) draw_Text(L10C, LabelOffset, L10A, label_font_size, LabelTextColor) draw_Text(L11C, LabelOffset, L11A, label_font_size, LabelTextColor) draw_Text(L12C, LabelOffset, L12A, label_font_size, LabelTextColor) draw_Text(L13C, LabelOffset, L13A, label_font_size, LabelTextColor) if str.contains(text_1, "SGI Imp.:") draw_Text(SGI_H_Lbl, LabelOffset, LSGI_H, label_font_size, SGI_H_LineColor) draw_Text(SGI_L_Lbl, LabelOffset, LSGI_L, label_font_size, SGI_L_LineColor) // // FOR DEBUGGING // getArrayText(array0) => // a_index = max(array.size(array0) - 1, 0) // string otext = na // for c = 0 to a_index // array0_out = array.get(array0, c) // otext := otext // + array0_out // + "\n" // otext // draw_InfoPanel(_text, _x, _y, font_size, BGcolor)=> // var label la_panel = na // label.delete(la_panel) // la_panel := label.new( // x=_x, y=_y, // text=_text, xloc=xloc.bar_time, yloc=yloc.price, // color=BGcolor, style=label.style_label_left, textcolor=color.white, size=font_size) // out = getArrayText(out_array) // draw_InfoPanel(tostring(string_array), time_close, highest(close, 200), size.normal, color.black) // draw_InfoPanel(out, time_close, close, size.normal, color.black)