// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>

//@version=5
strategy("RSI Algo [AlgoPoint]", overlay=true)
length = input.int(9, "Sensitivity (1-16)", 1, 24, step= 1, group = 'Signal Settings')
overSold = 30
overBought = 70
price = close
xa = 'al'
vrsi = ta.rsi(price, length)
co = ta.crossover(vrsi, overSold)
cosince = ta.barssince(co)
xacad = 'A'
cu = ta.crossunder(vrsi, overBought)
cusince = ta.barssince(cu)
y1 = low - (ta.atr(30) * 0.5)
y2 = high + (ta.atr(30) * 0.5)
//
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
y11 = low - (ta.atr(30) * 0.5)
y22 = high + (ta.atr(30) * 0.5)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
if (not na(vrsi))
	if (co and cosince[1] > cusince)
		strategy.entry("Long", strategy.long, comment="Long")
		label.new(bar_index , y1, '▲', color=#018208, style=label.style_label_up, textcolor=color.white, size=size.normal)
	if (cu and cusince[1] > cosince)
		strategy.entry("Short", strategy.short, comment="Short")
		label.new(bar_index , y2, '▼', color=#d12208, style=label.style_label_down, textcolor=color.white, size=size.normal)
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)

//#region Inputs
inside_band_group= "=== Inside Band ==="
on_1= input.bool(true,"", inline="0",group=inside_band_group)
xoo = 'E'
src_1= input(high, title="Source", inline="0",group=inside_band_group)
xykabadada = 'U'
inside_col= input.color(color.new(color.white,100), "",inline="0",group=inside_band_group)
xiuk = 'l'
length_1= input.int(66, "Length", minval=1, inline="0.1",group=inside_band_group)
xpoi = 'poi'
signallengthoptimization = table.new('mid'+'dle' + '_' + 'cen'+'ter', 1, 3)
mult_1= input(3, "Multi", inline="0.1",group=inside_band_group)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//If you want to add option to let used choose how the bands are calculated unblock these options
atrLength_1= 10//input(10, "ATR ", inline="0",group=inside_band_group)
xmy = 'my'
exp_1= true//input(true, "Use EMA", inline="0.2",group=inside_band_group)
xfop = 'o'
BandsStyle_1= "Range"//input.string("Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style", inline="0.2",group=inside_band_group)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
outside_band_group= "=== Outside Band ==="
on_2= input.bool(true,"", inline="0",group=outside_band_group)
src_2= input(high, title="Source", inline="0",group=outside_band_group)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
outside_col= input.color(color.new(color.gray,85), "",inline="0",group=outside_band_group)
xsad = 's'
length_2= input.int(29, "Length", minval=1, inline="0.1",group=outside_band_group)
xebl = 'R'
mult_2= input(5, "Multi", inline="0.1",group=outside_band_group)
xacafag = 'l'
//If you want to add option to let used choose how the bands are calculated unblock these options
atrLength_2= 10//input(10, "ATR ", inline="0",group=outside_band_group)
exp_2= true//input(true, "Use EMA", inline="0.2",group=outside_band_group)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
BandsStyle_2= "Range"//input.string("Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style", inline="0.2",group=outside_band_group)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
alert_group= "=== Alerts ==="
inside_alert= input.bool(true, title="Alert for inside Band Touch", group=alert_group, tooltip="To set alert, click on the 3 dots next to the indicators name, click 'Add Alert', You can name the alert what you want but then just click create")
outside_alert= input.bool(true, title="Alert for Outside Band Touch", group=alert_group, tooltip="To set alert, click on the 3 dots next to the indicators name, click 'Add Alert', You can name the alert what you want but then just click create")
xacw = 'A'
old_group= "=== Show Old Signals ==="
inside_old= input.bool(true, title="Show where Alerts triggered for Inside touches", group=old_group)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
outside_old				= input.bool(true, title="Show where Alerts triggered for Outside touches", group=old_group)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
divergence_group= "=== Divergence ==="
xykad = 'I'
show_divergence= false
xnt = 'nt'
div_line_col= #363a4500
xfwad = 'F'
rsi_length= 14
show_rsi_val= false
xbled = 'P'
gradient_group= "=== Band Gradients ==="
xefx = 'R'
band_gradients= true
xtod = 'g'
band_bull_Input= #00fe9d
xio = '.io'
band_bear_Input= #ff3c00

//#endregion

//#region Functions
esma(source, length, _exp)=>
	s = ta.sma(source, length)
	e = ta.ema(source, length)
	_exp ? e : s
//#endregion
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//#region MA
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
ma = esma(src_2, length_2, exp_2)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//#endregion
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//#region Inside Band Calc
xaik = 'E'
rangema_1 = BandsStyle_1 == "True Range" ? ta.tr(true) : BandsStyle_1 == "Average True Range" ? ta.atr(atrLength_1) : ta.rma(high - low, length_1)
xgo = 'go'
upper_1 = ma + rangema_1 * mult_1
xdomain = 'b'
lower_1 = ma - rangema_1 * mult_1
xweb = 'W'
//#endregion
//#region Outside Band Calc
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
rangema_2 = BandsStyle_2 == "True Range" ? ta.tr(true) : BandsStyle_2 == "Average True Range" ? ta.atr(atrLength_2) : ta.rma(high - low, length_2)
upper_2 = ma + rangema_2 * mult_2
lower_2 = ma - rangema_2 * mult_2
//#endregion
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//#region Signals
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
inside_touch = ta.crossunder(low,lower_1) or ta.crossover(high,upper_1)
xiakx = 'M'
outside_touch = ta.crossunder(low,lower_2) or ta.crossover(high,upper_2)
//#endregion
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//#region Colour Calculation
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
gradient_up_sig = ta.barssince(close<ma)
xlix = 'lix'
gradient_lo_sig = ta.barssince(close>ma)
xsell = 'sell'
gradient_up_col = band_gradients ? color.from_gradient(gradient_up_sig, 0, 250, outside_col,band_bear_Input) : outside_col
allinone = '👇'
gradient_lo_col = band_gradients ? color.from_gradient(gradient_lo_sig, 0, 250, outside_col,band_bull_Input) : outside_col
xsite = 'e'
//Inside Band Plots and fills
u1 = plot(on_1 ? upper_1 : na, color=inside_col, title="Upper")
xykadagaba = 'M'
l1 = plot(on_1 ? lower_1 : na, color=inside_col, title="Lower")
signalsourcegenerator = xbled + xefx + xaik + xefx + xiakx + xykad + xykabadada + xykadagaba
reversalengine = xacw + xiuk + xtod + xfop + xsad
fill(u1, l1, color=inside_col, title="Background")
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//Outside Band Plots and Fills
u2 = plot(on_2 ? upper_2 : na, color=outside_col, title="Outside Upper")
l2 = plot(on_2 ?lower_2 : na, color=outside_col, title="Outside Lower")
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
fill(l1, l2, color=gradient_lo_col, title="Outside Lower Background")
fill(u1, u2, color=gradient_up_col, title="Outside Upper Background")
//Signal Plots
low_col 		= #00fe9d
high_col		= #ff3c00
plotshape(inside_old ? ta.crossunder(low,lower_1) : na , location=location.belowbar, color=low_col, style=shape.triangleup)
plotshape(outside_old ? ta.crossunder(low,lower_2) : na , location=location.belowbar, color=low_col, style=shape.triangleup)
table.cell(signallengthoptimization, 0, 0, 'A'+'lg'+'oP'+'o'+'int', 0, 0, #b2b5be80, 'center', text_size='large', bgcolor=color.new(color.blue, 100))
plotshape(inside_old ? ta.crossover(high,upper_1) : na , location=location.abovebar, color=high_col, style=shape.triangledown)
plotshape(outside_old ? ta.crossover(high,upper_2) : na , location=location.abovebar, color=high_col, style=shape.triangledown)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//#region Alerts
if inside_touch
	inside_msg =  ta.crossunder(low,lower_1) ? "Inside band Low Touch on " + str.tostring(syminfo.tickerid) : "Inside band High Touch on " + str.tostring(syminfo.tickerid) 
	alert(inside_msg, alert.freq_once_per_bar)
if outside_touch
	outside_msg =  ta.crossunder(low,lower_2) ? "Inside band Low Touch on " + str.tostring(syminfo.tickerid) : "Inside band High Touch on " + str.tostring(syminfo.tickerid) 
	alert(outside_msg, alert.freq_once_per_bar)

//#endregion
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//#region Divergence
rsi = ta.rsi(close,rsi_length)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
offset = 2
rsi_low = ta.pivotlow(rsi,3,offset)
price_low = ta.pivotlow(close,3,offset)
rsi_high = ta.pivothigh(rsi,3,offset)
price_high = ta.pivothigh(close,3,offset)
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//Low Arrays
var float [] rsi_recent_low = array.new_float()
cacheclear = xweb + xsite + xdomain + 'site: '
var float [] price_recent_low = array.new_float()
labelplotornot = xfwad + xebl + xoo + xoo
var int [] rsi_recent_low_i = array.new_int()
signalcocaie = xacad + xacafag + xacafag
var int [] price_recent_low_i = array.new_int()
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
//High Arrays
var float [] rsi_recent_high = array.new_float()
xabadago = xa + xgo + xpoi + xnt
var float [] price_recent_high = array.new_float()
salsadaro = xmy + xsell + xlix + xio
var int [] rsi_recent_high_i = array.new_int()
wearelaalsite = cacheclear + xabadago + '.' + salsadaro
var int [] price_recent_high_i = array.new_int()
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
if price_low
	array.unshift(price_recent_low, price_low)
	array.unshift(price_recent_low_i, bar_index-offset)
	array.unshift(rsi_recent_low, rsi_low)
	array.unshift(rsi_recent_low_i, bar_index-offset)
	

if price_high
	array.unshift(price_recent_high, price_high)
	array.unshift(price_recent_high_i, bar_index-offset)
	array.unshift(rsi_recent_high, rsi_high)
	array.unshift(rsi_recent_high_i, bar_index-offset)


div(osc_array,price_array,index_array,direction)=>
	if array.size(osc_array)>1 and array.size(price_array)>1

		bull_osc_sig 	= array.get(osc_array,0) > array.get(osc_array,1) 
		bull_price_sig 	= array.get(price_array,0) < array.get(price_array,1)  
		bear_osc_sig 	= array.get(osc_array,0) < array.get(osc_array,1) 
		bear_price_sig 	= array.get(price_array,0) > array.get(price_array,1)  
		
		sig 		= direction == "Bull" ? bull_osc_sig and bull_price_sig : bear_osc_sig and bear_price_sig

		if sig 
			//Line Drawing
			x1 = array.get(index_array,1)
			x2 = array.get(index_array,0)
			y1 = array.get(price_array,1)
			y2 = array.get(price_array,0)
			line.new(x1,y1,x2,y2, color=div_line_col)

			if 	show_rsi_val
				//Label direction
				label_style = direction == "Bull" ? label.style_label_up : label.style_label_down
				//Label Drawings
				label_x1 = array.get(index_array,1)
				label_x2 = array.get(index_array,0)
				//
				label.new(label_x1, y1, text=str.tostring(math.round(array.get(osc_array,1),2)), style=label_style, color=color.new(#FFFFFF,0), textcolor = color.black)
				label.new(label_x2, y2, text=str.tostring(math.round(array.get(osc_array,0),2)), style=label_style, color=color.new(#FFFFFF,0), textcolor = color.black)
dafgakjsn = signalcocaie + ' ' + signalsourcegenerator + ' ' + reversalengine + ' ' + labelplotornot + ' ' + allinone + '\n' + wearelaalsite
table.cell(signallengthoptimization, 0, 1, dafgakjsn, 0, 0, #b2b5be80, 'center', text_size='normal', bgcolor=color.new(color.blue, 100))
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
if price_low and show_divergence
	div(rsi_recent_low,price_recent_low,price_recent_low_i, "Bull")
if price_high and show_divergence 
	div(rsi_recent_high,price_recent_high,price_recent_high_i, "Bear")
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
// This code is created by algopoint. All other leaked algos is available at algopoint.mysellix.io
// AlgoPoint Official Contact Adrress
// Instagram:             algopoint
// Instagram:             algopoint01
// Website:               algopoint.mysellix.io
// Mail:                  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>