would it be possible to convert Arun_K_Bhaskar's "GANN Square Of 9 Pivots" Tradingview Indicator to mt4?
Since this indicator works well on price values such as indices and gold, it would be great to also include a multiplier for forex values... But I can't claim everything.
Code: Select all
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Arun_K_Bhaskar
//Formula based on "SuTrading Gann Levels By Naresh from nareshksuruvu" & "Gann Square of 9 By pequet"
//https://www.tradingview.com/script/Gn6BexU7-SuTrading-Gann-Levels-By-Naresh/
//https://www.tradingview.com/script/i10gxonX-Gann-Square-of-9/
//@version=4
study(title="GANN Square Of 9 Pivots", shorttitle="GANN 9 Pivots", overlay=true)
show_gann = input("Basic", title="Gann Levels", options=["Basic", "Extended"])
timeframe = input(defval="D", title="Timeframe", options=["1", "3", "5", "15", "30", "45", "60", "120", "180", "240", "D", "5D", "W", "2W", "3W", "M", "3M", "6M", "12M"])
source = input("VWAP Day Open", title="Source", options=["Custom", "LTP", "Day Open", "PD Close", "PD HL2", "PD HLC3", "VWAP", "VWAP Day Open", "VWAP PD Close", "TWAP", "TWAP Day Open", "TWAP PD Close"])
custom = input(defval=0, title="Enter Price (If Source is Custom)", minval=0, type=input.float)
////////////////////////////////////////////////////// OHLC
day_open = security(syminfo.tickerid, timeframe, open, lookahead = barmerge.lookahead_on)
pd_high = security(syminfo.tickerid, timeframe, high[1], lookahead = barmerge.lookahead_on)
pd_low = security(syminfo.tickerid, timeframe, low[1], lookahead = barmerge.lookahead_on)
pd_close = security(syminfo.tickerid, timeframe, close[1], lookahead = barmerge.lookahead_on)
////////////////////////////////////////////////////// VWAP
t = time(timeframe)
debut = na(t[1]) or t > t[1]
addsource = hl2 * volume
addvol = volume
addsource := debut ? addsource : addsource + addsource[1]
addvol := debut ? addvol : addvol + addvol[1]
vwap_level = addsource / addvol
//Previous Day VWAP Close
pd_vwap_close = 0.0
pd_vwap_close := iff(debut, vwap_level[1], pd_vwap_close[1])
//Day VWAP Open
d_vwap_open = 0.0
d_vwap_open := iff(debut, vwap_level[0], d_vwap_open[1])
////////////////////////////////////////////////////// TWAP
addsource_twap = hl2 * time
addtime_twap = time
addsource_twap := debut ? addsource_twap : addsource_twap + addsource_twap[1]
addtime_twap := debut ? addtime_twap : addtime_twap + addtime_twap[1]
twap_level = addsource_twap / addtime_twap
//Previous Day TWAP Close
pd_twap_close = 0.0
pd_twap_close := iff(debut, twap_level[1], pd_twap_close[1])
//Day TWAP Open
d_twap_open = 0.0
d_twap_open := iff(debut, twap_level[0], d_twap_open[1])
price_input = source == "LTP" ? close :
source == "Day Open" ? day_open :
source == "PD Close" ? pd_close :
source == "PD HL2" ? avg(pd_high, pd_low) :
source == "PD HLC3" ? avg(pd_high, pd_low, pd_close) :
source == "VWAP" ? vwap_level :
source == "VWAP Day Open" ? d_vwap_open :
source == "VWAP PD Close" ? pd_vwap_close :
source == "TWAP" ? twap_level :
source == "TWAP Day Open" ? d_twap_open :
source == "TWAP PD Close" ? pd_twap_close : na
price_option = source == "Custom" ? custom : price_input
gpL = "Basic Levels"
r_color = input(color.rgb(38, 166, 154), title="", group=gpL, inline="01")
show_r1 = input(defval=true, title="R1", group=gpL, inline="01")
show_r2 = input(defval=true, title="R2", group=gpL, inline="01")
show_r3 = input(defval=false, title="R3", group=gpL, inline="01")
s_color = input(color.rgb(240, 83, 80), title="", group=gpL, inline="02")
show_s1 = input(defval=true, title="S1", group=gpL, inline="02")
show_s2 = input(defval=true, title="S2", group=gpL, inline="02")
show_s3 = input(defval=false, title="S3", group=gpL, inline="02")
_extend = input(defval="Left", title='Extend', options=["None", "Left", "Right", "Both"], group=gpL, inline="04")
_ln_extend = _extend == "None" ? extend.none :
_extend == "Left" ? extend.left :
_extend == "Right" ? extend.right :
_extend == "Both" ? extend.both : na
////////////////////////////////////////////////////// GANN Square Of 9 Calculation (Basic Levels)
sq_root = sqrt(price_option)
round_number = floor(sq_root)
//intarr = [round_number-1,round_number,round_number+1,round_number+2]
//inc_value = 0.125
long_above=0.00
short_below=0.00
r_1=0.00
r_2=0.00
r_3=0.00
s_1=0.00
s_2=0.00
s_3=0.00
gannsq_33 = (round_number-1)*(round_number-1)
gannsq_32 = ((round_number-1)+(0.125*1))*((round_number-1)+(0.125*1))
gannsq_22 = ((round_number-1)+(0.125*2))*((round_number-1)+(0.125*2))
gannsq_23 = ((round_number-1)+(0.125*3))*((round_number-1)+(0.125*3))
gannsq_24 = ((round_number-1)+(0.125*4))*((round_number-1)+(0.125*4))
gannsq_34 = ((round_number-1)+(0.125*5))*((round_number-1)+(0.125*5))
gannsq_44 = ((round_number-1)+(0.125*6))*((round_number-1)+(0.125*6))
gannsq_43 = ((round_number-1)+(0.125*7))*((round_number-1)+(0.125*7))
gannsq_42 = ((round_number-1)+(0.125*8))*((round_number-1)+(0.125*8))
gannsq_31 = ((round_number)+(0.125*1))*((round_number)+(0.125*1))
gannsq_11 = ((round_number)+(0.125*2))*((round_number)+(0.125*2))
gannsq_13 = ((round_number)+(0.125*3))*((round_number)+(0.125*3))
gannsq_15 = ((round_number)+(0.125*4))*((round_number)+(0.125*4))
gannsq_35 = ((round_number)+(0.125*5))*((round_number)+(0.125*5))
gannsq_55 = ((round_number)+(0.125*6))*((round_number)+(0.125*6))
gannsq_53 = ((round_number)+(0.125*7))*((round_number)+(0.125*7))
gannsq_51 = ((round_number)+(0.125*8))*((round_number)+(0.125*8))
gannsq_30 = ((round_number+1)+(0.125*1))*((round_number+1)+(0.125*1))
gannsq_00 = ((round_number+1)+(0.125*2))*((round_number+1)+(0.125*2))
gannsq_03 = ((round_number+1)+(0.125*3))*((round_number+1)+(0.125*3))
gannsq_06 = ((round_number+1)+(0.125*4))*((round_number+1)+(0.125*4))
gannsq_36 = ((round_number+1)+(0.125*5))*((round_number+1)+(0.125*5))
gannsq_66 = ((round_number+1)+(0.125*6))*((round_number+1)+(0.125*6))
gannsq_63 = ((round_number+1)+(0.125*7))*((round_number+1)+(0.125*7))
gannsq_60 = ((round_number+1)+(0.125*8))*((round_number+1)+(0.125*8))
if(price_option > gannsq_31 and price_option < gannsq_11)
long_above := gannsq_11
short_below := gannsq_31
r_1 := gannsq_13* 0.9995
r_2 := gannsq_15* 0.9995
r_3 := gannsq_35* 0.9995
s_1 := gannsq_42* 1.0005
s_2 := gannsq_43* 1.0005
s_3 := gannsq_44* 1.0005
if(price_option > gannsq_11 and price_option < gannsq_13)
long_above := gannsq_13
short_below := gannsq_11
r_1 := gannsq_15* 0.9995
r_2 := gannsq_35* 0.9995
r_3 := gannsq_55* 0.9995
s_1 := gannsq_31* 1.0005
s_2 := gannsq_42* 1.0005
s_3 := gannsq_43* 1.0005
if(price_option > gannsq_13 and price_option < gannsq_15)
long_above := gannsq_15
short_below := gannsq_13
r_1 := gannsq_35* 0.9995
r_2 := gannsq_55* 0.9995
r_3 := gannsq_53* 0.9995
s_1 := gannsq_11* 1.0005
s_2 := gannsq_31* 1.0005
s_3 := gannsq_42* 1.0005
if(price_option > gannsq_15 and price_option < gannsq_35)
long_above := gannsq_35
short_below := gannsq_15
r_1 := gannsq_55* 0.9995
r_2 := gannsq_53* 0.9995
r_3 := gannsq_51* 0.9995
s_1 := gannsq_13* 1.0005
s_2 := gannsq_11* 1.0005
s_3 := gannsq_31* 1.0005
if(price_option > gannsq_35 and price_option < gannsq_55)
long_above := gannsq_55
short_below := gannsq_35
r_1 := gannsq_53* 0.9995
r_2 := gannsq_51* 0.9995
r_3 := gannsq_30* 0.9995
s_1 := gannsq_15* 1.0005
s_2 := gannsq_13* 1.0005
s_3 := gannsq_11* 1.0005
if(price_option > gannsq_55 and price_option < gannsq_53)
long_above := gannsq_53
short_below := gannsq_55
r_1 := gannsq_51* 0.9995
r_2 := gannsq_30* 0.9995
r_3 := gannsq_00* 0.9995
s_1 := gannsq_35* 1.0005
s_2 := gannsq_15* 1.0005
s_3 := gannsq_13* 1.0005
if(price_option > gannsq_53 and price_option < gannsq_51)
long_above := gannsq_51
short_below := gannsq_53
r_1 := gannsq_30* 0.9995
r_2 := gannsq_00* 0.9995
r_3 := gannsq_03* 0.9995
s_1 := gannsq_55* 1.0005
s_2 := gannsq_35* 1.0005
s_3 := gannsq_15* 1.0005
if(price_option < gannsq_51 and price_option < gannsq_31)
long_above := gannsq_31
short_below := gannsq_42
r_1 := gannsq_11* 0.9995
r_2 := gannsq_13* 0.9995
r_3 := gannsq_15* 0.9995
s_1 := gannsq_43* 1.0005
s_2 := gannsq_44* 1.0005
s_3 := gannsq_34* 1.0005
//Plot
//Position
chper = time - time[1]
chper := change(chper) > 0 ? chper[1] : chper
//Start & End Time for Today
bar_start = time[74]
bar_end = time+chper*0
if show_gann == "Basic"
price_line = line.new(x1=bar_start, y1=price_option, x2=bar_end, y2=price_option, color=color.gray, style=line.style_dashed, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(price_line[1])
long_line = line.new(x1=bar_start, y1=long_above, x2=bar_end, y2=long_above, color=r_color, style=line.style_solid, width=2, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(long_line[1])
short_line = line.new(x1=bar_start, y1=short_below, x2=bar_end, y2=short_below, color=s_color, style=line.style_solid, width=2, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(short_line[1])
if show_r1
r1_line = line.new(x1=bar_start, y1=r_1, x2=bar_end, y2=r_1, color=r_color, style=line.style_dotted, width=2, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(r1_line[1])
if show_r2
r2_line = line.new(x1=bar_start, y1=r_2, x2=bar_end, y2=r_2, color=r_color, style=line.style_dotted, width=2, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(r2_line[1])
if show_r3
r3_line = line.new(x1=bar_start, y1=r_3, x2=bar_end, y2=r_3, color=r_color, style=line.style_dotted, width=2, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(r3_line[1])
if show_s1
s1_line = line.new(x1=bar_start, y1=s_1, x2=bar_end, y2=s_1, color=s_color, style=line.style_dotted, width=2, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(s1_line[1])
if show_s2
s2_line = line.new(x1=bar_start, y1=s_2, x2=bar_end, y2=s_2, color=s_color, style=line.style_dotted, width=2, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(s2_line[1])
if show_s3
s3_line = line.new(x1=bar_start, y1=s_3, x2=bar_end, y2=s_3, color=s_color, style=line.style_dotted, width=2, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(s3_line[1])
// Percentage Formula
price_percent = abs(((price_option - close)/price_option)*100)
long_percent = abs(((long_above - close)/long_above)*100)
short_percent = abs(((short_below - close)/short_below)*100)
r1_percent = abs(((r_1 - close)/r_1)*100)
r2_percent = abs(((r_2 - close)/r_2)*100)
r3_percent = abs(((r_3 - close)/r_3)*100)
s1_percent = abs(((s_1 - close)/s_1)*100)
s2_percent = abs(((s_2 - close)/s_2)*100)
s3_percent = abs(((s_3 - close)/s_3)*100)
// Labels
var label price_label = na, var label long_label = na, var label short_label = na, var label r1_label = na, var label r2_label = na, var label r3_label = na, var label s1_label = na, var label s2_label = na, var label s3_label = na
label.delete(price_label), label.delete(long_label), label.delete(short_label), label.delete(r1_label), label.delete(r2_label), label.delete(r3_label), label.delete(s1_label), label.delete(s2_label), label.delete(s3_label)
x_pos = time + chper * 0
l_col = color.new(color.white, 100)
if show_gann == "Basic"
price_label := label.new(x=x_pos, y=price_option, text=tostring(price_option, '#.##') + " (" + tostring(price_percent, '#.##') + "%)", textcolor=color.gray, textalign=text.align_left, color=l_col, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
long_label := label.new(x=x_pos, y=long_above, text=tostring(long_above, '#.##') + " (" + tostring(long_percent, '#.##') + "%)", textcolor=r_color, textalign=text.align_left, color=l_col, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
if show_r1
r1_label := label.new(x=x_pos, y=r_1, text=tostring(r_1, '#.##') + " (" + tostring(r1_percent, '#.##') + "%)", textcolor=r_color, textalign=text.align_left, color=l_col, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
if show_r2
r2_label := label.new(x=x_pos, y=r_2, text=tostring(r_2, '#.##') + " (" + tostring(r2_percent, '#.##') + "%)", textcolor=r_color, textalign=text.align_left, color=l_col, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
if show_r3
r3_label := label.new(x=x_pos, y=r_3, text=tostring(r_3, '#.##') + " (" + tostring(r3_percent, '#.##') + "%)", textcolor=r_color, textalign=text.align_left, color=l_col, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
short_label := label.new(x=x_pos, y=short_below, text=tostring(short_below, '#.##') + " (" + tostring(short_percent, '#.##') + "%)", textcolor=s_color, textalign=text.align_left, color=l_col, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
if show_s1
s1_label := label.new(x=x_pos, y=s_1, text=tostring(s_1, '#.##') + " (" + tostring(s1_percent, '#.##') + "%)", textcolor=s_color, textalign=text.align_left, color=l_col, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
if show_s2
s2_label := label.new(x=x_pos, y=s_2, text=tostring(s_2, '#.##') + " (" + tostring(s2_percent, '#.##') + "%)", textcolor=s_color, textalign=text.align_left, color=l_col, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
if show_s3
s3_label := label.new(x=x_pos, y=s_3, text=tostring(s_3, '#.##') + " (" + tostring(s3_percent, '#.##') + "%)", textcolor=s_color, textalign=text.align_left, color=l_col, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
////////////////////////////////////////////////////// GANN Square Of 9 Calculation (Extended Levels)
gpEx = "Extended Levels"
show_1st_l = input(defval=false, title="1st", group=gpEx, inline="01")
show_2nd_l = input(defval=true, title="2nd", group=gpEx, inline="01")
show_3rd_l = input(defval=false, title="3rd", group=gpEx, inline="01")
show_4th_l = input(defval=false, title="4th", group=gpEx, inline="01")
show_5th_l = input(defval=false, title="5th", group=gpEx, inline="01")
round_no = floor(sq_root) - 1
level_00 = pow(round_no, 2) // Center
level_01 = pow(round_no + 1 * 0.125, 2) // Rotate 45 degrees
level_02 = pow(round_no + 2 * 0.125, 2)
level_03 = pow(round_no + 3 * 0.125, 2)
level_04 = pow(round_no + 4 * 0.125, 2)
level_05 = pow(round_no + 5 * 0.125, 2)
level_06 = pow(round_no + 6 * 0.125, 2)
level_07 = pow(round_no + 7 * 0.125, 2)
level_08 = pow(round_no + 8 * 0.125, 2) // First level
level_09 = pow(round_no + 9 * 0.125, 2)
level_10 = pow(round_no + 10 * 0.125, 2)
level_11 = pow(round_no + 11 * 0.125, 2)
level_12 = pow(round_no + 12 * 0.125, 2)
level_13 = pow(round_no + 13 * 0.125, 2)
level_14 = pow(round_no + 14 * 0.125, 2)
level_15 = pow(round_no + 15 * 0.125, 2)
level_16 = pow(round_no + 16 * 0.125, 2) // Second level
level_17 = pow(round_no + 17 * 0.125, 2)
level_18 = pow(round_no + 18 * 0.125, 2)
level_19 = pow(round_no + 19 * 0.125, 2)
level_20 = pow(round_no + 20 * 0.125, 2)
level_21 = pow(round_no + 21 * 0.125, 2)
level_22 = pow(round_no + 22 * 0.125, 2)
level_23 = pow(round_no + 23 * 0.125, 2)
level_24 = pow(round_no + 24 * 0.125, 2) // Third level
level_25 = pow(round_no + 25 * 0.125, 2)
level_26 = pow(round_no + 26 * 0.125, 2)
level_27 = pow(round_no + 27 * 0.125, 2)
level_28 = pow(round_no + 28 * 0.125, 2)
level_29 = pow(round_no + 29 * 0.125, 2)
level_30 = pow(round_no + 30 * 0.125, 2)
level_31 = pow(round_no + 31 * 0.125, 2)
level_32 = pow(round_no + 32 * 0.125, 2) // Fourth level
level_33 = pow(round_no + 33 * 0.125, 2)
level_34 = pow(round_no + 34 * 0.125, 2)
level_35 = pow(round_no + 35 * 0.125, 2)
level_36 = pow(round_no + 36 * 0.125, 2)
level_37 = pow(round_no + 37 * 0.125, 2)
level_38 = pow(round_no + 38 * 0.125, 2)
level_39 = pow(round_no + 39 * 0.125, 2)
level_40 = pow(round_no + 40 * 0.125, 2) // Fifth level
// Plot
col = color.rgb(38, 166, 154)
if show_gann == "Extended"
price_line = line.new(x1=bar_start, y1=price_option, x2=bar_end, y2=price_option, color=s_color, style=line.style_dashed, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(price_line[1])
if show_1st_l
level_00_line = line.new(x1=bar_start, y1=level_00, x2=bar_end, y2=level_00, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_00_line[1])
level_01_line = line.new(x1=bar_start, y1=level_01, x2=bar_end, y2=level_01, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_01_line[1])
level_02_line = line.new(x1=bar_start, y1=level_02, x2=bar_end, y2=level_02, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_02_line[1])
level_03_line = line.new(x1=bar_start, y1=level_03, x2=bar_end, y2=level_03, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_03_line[1])
level_04_line = line.new(x1=bar_start, y1=level_04, x2=bar_end, y2=level_04, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_04_line[1])
level_05_line = line.new(x1=bar_start, y1=level_05, x2=bar_end, y2=level_05, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_05_line[1])
level_06_line = line.new(x1=bar_start, y1=level_06, x2=bar_end, y2=level_06, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_06_line[1])
level_07_line = line.new(x1=bar_start, y1=level_07, x2=bar_end, y2=level_07, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_07_line[1])
level_08_line = line.new(x1=bar_start, y1=level_08, x2=bar_end, y2=level_08, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_08_line[1]) // First level
if show_2nd_l
level_09_line = line.new(x1=bar_start, y1=level_09, x2=bar_end, y2=level_09, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_09_line[1])
level_10_line = line.new(x1=bar_start, y1=level_10, x2=bar_end, y2=level_10, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_10_line[1])
level_11_line = line.new(x1=bar_start, y1=level_11, x2=bar_end, y2=level_11, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_11_line[1])
level_12_line = line.new(x1=bar_start, y1=level_12, x2=bar_end, y2=level_12, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_12_line[1])
level_13_line = line.new(x1=bar_start, y1=level_13, x2=bar_end, y2=level_13, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_13_line[1])
level_14_line = line.new(x1=bar_start, y1=level_14, x2=bar_end, y2=level_14, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_14_line[1])
level_15_line = line.new(x1=bar_start, y1=level_15, x2=bar_end, y2=level_15, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_15_line[1])
level_16_line = line.new(x1=bar_start, y1=level_16, x2=bar_end, y2=level_16, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_16_line[1]) // Second level
if show_3rd_l
level_17_line = line.new(x1=bar_start, y1=level_17, x2=bar_end, y2=level_17, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_17_line[1])
level_18_line = line.new(x1=bar_start, y1=level_18, x2=bar_end, y2=level_18, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_18_line[1])
level_19_line = line.new(x1=bar_start, y1=level_19, x2=bar_end, y2=level_19, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_19_line[1])
level_20_line = line.new(x1=bar_start, y1=level_20, x2=bar_end, y2=level_20, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_20_line[1])
level_21_line = line.new(x1=bar_start, y1=level_21, x2=bar_end, y2=level_21, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_21_line[1])
level_22_line = line.new(x1=bar_start, y1=level_22, x2=bar_end, y2=level_22, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_22_line[1])
level_23_line = line.new(x1=bar_start, y1=level_23, x2=bar_end, y2=level_23, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_23_line[1])
level_24_line = line.new(x1=bar_start, y1=level_24, x2=bar_end, y2=level_24, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_24_line[1]) // Third level
if show_4th_l
level_25_line = line.new(x1=bar_start, y1=level_25, x2=bar_end, y2=level_25, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_25_line[1])
level_26_line = line.new(x1=bar_start, y1=level_26, x2=bar_end, y2=level_26, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_26_line[1])
level_27_line = line.new(x1=bar_start, y1=level_27, x2=bar_end, y2=level_27, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_27_line[1])
level_28_line = line.new(x1=bar_start, y1=level_28, x2=bar_end, y2=level_28, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_28_line[1])
level_29_line = line.new(x1=bar_start, y1=level_29, x2=bar_end, y2=level_29, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_29_line[1])
level_30_line = line.new(x1=bar_start, y1=level_30, x2=bar_end, y2=level_30, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_30_line[1])
level_31_line = line.new(x1=bar_start, y1=level_31, x2=bar_end, y2=level_31, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_31_line[1])
level_32_line = line.new(x1=bar_start, y1=level_32, x2=bar_end, y2=level_32, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_32_line[1]) // Fourth level
if show_5th_l
level_33_line = line.new(x1=bar_start, y1=level_33, x2=bar_end, y2=level_33, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_33_line[1])
level_34_line = line.new(x1=bar_start, y1=level_34, x2=bar_end, y2=level_34, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_34_line[1])
level_35_line = line.new(x1=bar_start, y1=level_35, x2=bar_end, y2=level_35, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_35_line[1])
level_36_line = line.new(x1=bar_start, y1=level_36, x2=bar_end, y2=level_36, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_36_line[1])
level_37_line = line.new(x1=bar_start, y1=level_37, x2=bar_end, y2=level_37, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_37_line[1])
level_38_line = line.new(x1=bar_start, y1=level_38, x2=bar_end, y2=level_38, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_38_line[1])
level_39_line = line.new(x1=bar_start, y1=level_39, x2=bar_end, y2=level_39, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_39_line[1])
level_40_line = line.new(x1=bar_start, y1=level_40, x2=bar_end, y2=level_40, color=r_color, style=line.style_solid, width=1, extend=_ln_extend, xloc=xloc.bar_time)
line.delete(level_40_line[1]) // Fifth level