Alino Forex System
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ceyhun

//@version=4
study("Alino Forex System",overlay=true)

no=input(3,title="Swing")
Barcolor=input(true,title="Barcolor")
Bgcolor=input(false,title="Bgcolor")

res=highest(high,no)
sup=lowest(low,no)
avd=iff(close>res[1],1,iff(close<sup[1],-1,0))
avn=valuewhen(avd!=0,avd,0)
tsl=iff(avn==1,sup,res)

Buy=crossover(close,tsl)
Sell=crossunder(close,tsl)

plotshape(Buy,"BUY", shape.labelup, location.belowbar, color.green, text="BUY",textcolor=color.black)
plotshape(Sell,"SELL", shape.labeldown, location.abovebar, color.red, text="SELL",textcolor=color.black)

colr = close>=tsl ? color.green : close<=tsl ? color.red : na
plot(tsl, color=colr, linewidth=3, title="TSL")
barcolor(Barcolor ? colr : na)
bgcolor(Bgcolor ? colr :na)

alertcondition(Buy, title="Buy Signal", message="Buy")
alertcondition(Sell, title="Sell Signal", message="Sell")


alen = input( 14, "ATR Length (default 14)" )
smooth = input( 3, "Smoothing" )

a1 = input( 0.5, "Multiplier 1" )
a2 = input( 1, "Multiplier 2" )
a3 = input( 3, "Multiplier 3" )
a4 = input( 5, "Multiplier 4" )
a5 = input( 10, "Multiplier 5" )

datr = atr( alen )
sclose = sma( close, smooth )

priceup1 = sclose + ( datr * a1 )
pricedn1 = sclose - ( datr * a1 )
priceup2 = sclose + ( datr * a2 )
pricedn2 = sclose - ( datr * a2 )
priceup3 = sclose + ( datr * a3 )
pricedn3 = sclose - ( datr * a3 )
priceup4 = sclose + ( datr * a4 )
pricedn4 = sclose - ( datr * a4 )
priceup5 = sclose + ( datr * a5 )
pricedn5 = sclose - ( datr * a5 )

//plot(priceup1, color=color.green )
//plot(pricedn1, color=color.red )
//plot(priceup2, color=color.green )
//plot(pricedn2, color=color.red )
//plot(priceup3, color=color.green )
plot(pricedn3, color=color.red )
plot(priceup4, color=color.green )
//plot(pricedn4, color=color.red )
plot(priceup5, color=color.green )
//plot(pricedn5, color=color.red )

//var labelu1 = label.new(bar_index, high, text='+'+tostring(a1)+'x', style= label.style_label_left)
//var labeld1 = label.new(bar_index, high, text='-'+tostring(a1)+'x', style= label.style_label_left)

//var labelu2 = label.new(bar_index, high, text='+'+tostring(a2)+'x', style= label.style_label_left)
//var labeld2 = label.new(bar_index, high, text='-'+tostring(a2)+'x', style= label.style_label_left)

var labelu3 = label.new(bar_index, high, text='+'+tostring(a3)+'x', style= label.style_label_left)
var labeld3 = label.new(bar_index, high, text='-'+tostring(a3)+'x', style= label.style_label_left)

var labelu4 = label.new(bar_index, high, text='+'+tostring(a4)+'x', style= label.style_label_left)
//var labeld4 = label.new(bar_index, high, text='-'+tostring(a4)+'x', style= label.style_label_left)

var labelu5 = label.new(bar_index, high, text='+'+tostring(a5)+'x', style= label.style_label_left)
//var labeld5 = label.new(bar_index, high, text='-'+tostring(a5)+'x', style= label.style_label_left)

//label.set_x(labelu1, 0)
//label.set_y(labelu1, priceup1)
//label.set_xloc(labelu1, time, xloc.bar_time)
// label.set_yloc(labelu1, yloc.abovebar)
//label.set_color(labelu1, color.green)
//label.set_textcolor(labelu1, color.white)

//label.set_x(labeld1, 0)
//label.set_y(labeld1, pricedn1)
//label.set_xloc(labeld1, time, xloc.bar_time)
// label.set_yloc(labelu1, yloc.belowbar)
//label.set_color(labeld1, color.red)
//label.set_textcolor(labeld1, color.white)

//label.set_x(labelu2, 0)
//label.set_y(labelu2, priceup2)
//label.set_xloc(labelu2, time, xloc.bar_time)
//label.set_color(labelu2, color.green)
//label.set_textcolor(labelu2, color.white)

//label.set_x(labeld2, 0)
//label.set_y(labeld2, pricedn2)
//label.set_xloc(labeld2, time, xloc.bar_time)
//label.set_color(labeld2, color.red)
//label.set_textcolor(labeld2, color.white)



//label.set_x(labelu3, 0)
//label.set_y(labelu3, priceup3)
//label.set_xloc(labelu3, time, xloc.bar_time)
//label.set_color(labelu3, color.green)
//label.set_textcolor(labelu3, color.white)

label.set_x(labeld3, 0)
label.set_y(labeld3, pricedn3)
label.set_xloc(labeld3, time, xloc.bar_time)
label.set_color(labeld3, color.red)
label.set_textcolor(labeld3, color.white)


label.set_x(labelu4, 0)
label.set_y(labelu4, priceup4)
label.set_xloc(labelu4, time, xloc.bar_time)
label.set_color(labelu4, color.green)
label.set_textcolor(labelu4, color.white)

//label.set_x(labeld4, 0)
//label.set_y(labeld4, pricedn4)
//label.set_xloc(labeld4, time, xloc.bar_time)
//label.set_color(labeld4, color.red)
//label.set_textcolor(labeld4, color.white)


label.set_x(labelu5, 0)
label.set_y(labelu5, priceup5)
label.set_xloc(labelu5, time, xloc.bar_time)
label.set_color(labelu5, color.green)
label.set_textcolor(labelu5, color.white)

//label.set_x(labeld5, 0)
//label.set_y(labeld5, pricedn5)
//label.set_xloc(labeld5, time, xloc.bar_time)
//label.set_color(labeld5, color.red)
//label.set_textcolor(labeld5, color.white)


