LoTek - Horizontal Multi Time-Frame EMAs
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LoTek
// Original idea from @Cryptastico
// Understanding and implementation of settings lifted from The_Caretaker
// Use this script to make money


//@version=5

indicator(shorttitle="LoTek - H. MTF EMAs", title="LoTek - Horizontal Multi Time-Frame EMAs - Draft", overlay=true)

var color c_txt	= color.new (color.white, 0 )

var color c_e1		= color.new (color.green, 0 )
var color c_e2		= color.new (color.blue, 0 )
var color c_e3		= color.new (color.red, 0 )
var color c_e4		= color.new (color.aqua, 0 )
var color c_e5		= color.new (color.fuchsia, 0 )
var color c_e6		= color.new (color.orange, 0 )
var color c_e7		= color.new (color.silver, 0 )
var color c_e8		= color.new (color.olive, 0 )
 
var float minBarTime = 999999999999
currentTime = time(timeframe.period)
timeOfCurrentBar = ta.change(currentTime, 1)
minBarTime := not na(minBarTime) ? math.min(timeOfCurrentBar, minBarTime) : timeOfCurrentBar

// Begin settings   
show_lbl 	= 	input.bool			( true,					    ' Show Labels ',													        				inline = '1',				group = ' Labels')
//show_sqz 	= 	input.bool			( true,					    ' Show Labels ',													        				inline = '1',				group = ' Labels')

show_ema1 	= 	input.bool			( true,					    ' MA 1 ',															    			inline = 'MA 1',				group = ' Moving Averages')
i_col_e1	=	input.color 		( c_e1,					    ' : ',																			inline = 'MA 1',				group = ' Moving Averages')
i_len_e1 	=	input.int 			( 10,						' RSI Length ',			minval=1,								    				inline = 'MA 1',				group = ' Moving Averages')
i_res_e1	= 	input.timeframe	    ( 'D', 						' Resolution ', 		options=['D', '480', '360', '240', '120'],  				inline = 'MA 1',				group = ' Moving Averages')

show_ema2 	= 	input.bool			( false,					' MA 2 ',															    		    inline = 'MA 2',				group = ' Moving Averages')
i_col_e2	=	input.color 		( c_e2,					    ' : ',																			inline = 'MA 2',				group = ' Moving Averages')
i_len_e2 	=	input.int 			( 13,						' RSI Length ',			minval=1,								    				inline = 'MA 2',				group = ' Moving Averages')
i_res_e2	= 	input.timeframe	    ( 'D', 						' Resolution ', 		options=['D', '480', '360', '240', '120'],  				inline = 'MA 2',				group = ' Moving Averages')

show_ema3 	= 	input.bool			( true,					    ' MA 3 ',															    		    inline = 'MA 3',				group = ' Moving Averages')
i_col_e3	=	input.color 		( c_e3,					    ' : ',																			inline = 'MA 3',				group = ' Moving Averages')
i_len_e3 	=	input.int 			( 21,						' RSI Length ',			minval=1,								    				inline = 'MA 3',				group = ' Moving Averages')
i_res_e3	= 	input.timeframe	    ( 'D', 						' Resolution ', 		options=['D', '480', '360', '240', '120'],  				inline = 'MA 3',				group = ' Moving Averages')

show_ema4 	= 	input.bool			( true,					    ' MA 4 ',															    		    inline = 'MA 4',				group = ' Moving Averages')
i_col_e4	=	input.color 		( c_e4,					    ' : ',																			inline = 'MA 4',				group = ' Moving Averages')
i_len_e4 	=	input.int 			( 50,						' RSI Length ',			minval=1,								    				inline = 'MA 4',				group = ' Moving Averages')
i_res_e4	= 	input.timeframe	    ( 'D', 						' Resolution ', 		options=['D', '480', '360', '240', '120'],  				inline = 'MA 4',				group = ' Moving Averages')

show_ema5 	= 	input.bool			( false,					    ' MA 5 ',															    			inline = 'MA 5',				group = ' Moving Averages')
i_col_e5	=	input.color 		( c_e5,					    ' : ',																			inline = 'MA 5',				group = ' Moving Averages')
i_len_e5 	=	input.int 			( 89,						' RSI Length ',			minval=1,								    				inline = 'MA 5',				group = ' Moving Averages')
i_res_e5	= 	input.timeframe	    ( 'D', 						' Resolution ', 		options=['D', '480', '360', '240', '120'],  				inline = 'MA 5',				group = ' Moving Averages')

show_ema6 	= 	input.bool			( true,					' MA 6 ',															    		    inline = 'MA 6',				group = ' Moving Averages')
i_col_e6	=	input.color 		( c_e6,					    ' : ',																			inline = 'MA 6',				group = ' Moving Averages')
i_len_e6 	=	input.int 			( 100,						' RSI Length ',			minval=1,								    				inline = 'MA 6',				group = ' Moving Averages')
i_res_e6	= 	input.timeframe	    ( 'D', 						' Resolution ', 		options=['D', '480', '360', '240', '120'],  				inline = 'MA 6',				group = ' Moving Averages')

show_ema7 	= 	input.bool			( true,					' MA 7 ',															    		    inline = 'MA 7',				group = ' Moving Averages')
i_col_e7	=	input.color 		( c_e7,					    ' : ',																			inline = 'MA 7',				group = ' Moving Averages')
i_len_e7 	=	input.int 			( 200,						' RSI Length ',			minval=1,								    				inline = 'MA 7',				group = ' Moving Averages')
i_res_e7	= 	input.timeframe	    ( 'D', 						' Resolution ', 		options=['D', '480', '360', '240', '120'],  				inline = 'MA 7',				group = ' Moving Averages')

show_ema8 	= 	input.bool			( false,					    ' MA 8 ',															    		    inline = 'MA 8',				group = ' Moving Averages')
i_col_e8	=	input.color 		( c_e8,					    ' : ',																			inline = 'MA 8',				group = ' Moving Averages')
i_len_e8 	=	input.int 			( 800,						' RSI Length ',			minval=1,								    				inline = 'MA 8',				group = ' Moving Averages')
i_res_e8	= 	input.timeframe	    ( 'D', 						' Resolution ', 		options=['D', '480', '360', '240', '120'],  				inline = 'MA 8',				group = ' Moving Averages')


// Plot the horizontal lines
//EMA1 10
ema1 = show_ema1 ? request.security(syminfo.tickerid, i_res_e1, ta.ema(close, i_len_e1), lookahead=barmerge.lookahead_on) : na
plot(ema1[0], trackprice=true, offset=-9999, color=i_col_e1, linewidth=4, title='EMA 1')

//EMA2 13
ema2 = show_ema2 ? request.security(syminfo.tickerid, i_res_e2, ta.ema(close, i_len_e2), lookahead=barmerge.lookahead_on) : na
plot(ema2[0], trackprice=true, offset=-9999, color=i_col_e2, linewidth=4, title='EMA 2')

//EMA3 21
ema3 = show_ema3 ? request.security(syminfo.tickerid, i_res_e3, ta.ema(close, i_len_e3), lookahead=barmerge.lookahead_on) : na
plot(ema3[0], trackprice=true, offset=-9999, color=i_col_e3, linewidth=4, title='EMA 3')

//EMA4 55
ema4 = show_ema4 ? request.security(syminfo.tickerid, i_res_e4, ta.ema(close, i_len_e4), lookahead=barmerge.lookahead_on) : na
plot(ema4[0], trackprice=true, offset=-9999, color=i_col_e4, linewidth=4, title='EMA 4')

//EMA5 89
ema5 = show_ema5 ? request.security(syminfo.tickerid, i_res_e5, ta.ema(close, i_len_e5), lookahead=barmerge.lookahead_on) : na
plot(ema5[0], trackprice=true, offset=-9999, color=i_col_e5, linewidth=4, title='EMA 5')

//EMA6 100
ema6 = show_ema6 ? request.security(syminfo.tickerid, i_res_e6, ta.ema(close, i_len_e6), lookahead=barmerge.lookahead_on) : na
plot(ema6[0], trackprice=true, offset=-9999, color=i_col_e6, linewidth=4, title='EMA 6')

//EMA7 200
ema7 = show_ema7 ? request.security(syminfo.tickerid, i_res_e7, ta.ema(close, i_len_e7), lookahead=barmerge.lookahead_on) : na
plot(ema7[0], trackprice=true, offset=-9999, color=i_col_e7, linewidth=4, title='EMA 7')

//EMA8 800
ema8 = show_ema8 ? request.security(syminfo.tickerid, i_res_e8, ta.ema(close, i_len_e8), lookahead=barmerge.lookahead_on) : na
plot(ema8[0], trackprice=true, offset=-9999, color=i_col_e8, linewidth=4, title='EMA 8')


// Apply labels if needed
if show_lbl
    //EMA1
	var label l_e1 = label.new(bar_index, close, str.tostring(i_res_e1) + ' ' + str.tostring(i_len_e1), xloc=xloc.bar_time, style=label.style_none, size=size.huge)
	label.set_textcolor(l_e1, i_col_e1)
	label.set_textalign(l_e1, text.align_center)
    label.set_x(l_e1, int(currentTime - 1000000000))
    label.set_y(l_e1, ema1[0])

    //EMA2
	var label l_e2 = label.new(bar_index, close, str.tostring(i_res_e2) + ' ' + str.tostring(i_len_e2), xloc=xloc.bar_time, style=label.style_none, size=size.huge)
	label.set_textcolor(l_e2, i_col_e2)
	label.set_textalign(l_e2, text.align_center)
    label.set_x(l_e2, int(currentTime - 10000000))
    label.set_y(l_e2, ema2[0])
    
    //EMA3
	var label l_e3 = label.new(bar_index, close, str.tostring(i_res_e3) + ' ' + str.tostring(i_len_e3), xloc=xloc.bar_time, style=label.style_none, size=size.huge)
	label.set_textcolor(l_e3, i_col_e3)
	label.set_textalign(l_e3, text.align_center)
    label.set_x(l_e3, int(currentTime - 1000000000))
    label.set_y(l_e3, ema3[0])

    //EMA4
	var label l_e4 = label.new(bar_index, close, str.tostring(i_res_e4) + ' ' + str.tostring(i_len_e4), xloc=xloc.bar_time, style=label.style_none, size=size.huge)
	label.set_textcolor(l_e4, i_col_e4)
	label.set_textalign(l_e4, text.align_center)
    label.set_x(l_e4, int(currentTime - 1000000000))
    label.set_y(l_e4, ema4[0])
    
    //EMA5
	var label l_e5 = label.new(bar_index, close, str.tostring(i_res_e6) + ' ' + str.tostring(i_len_e5), xloc=xloc.bar_time, style=label.style_none, size=size.huge)
	label.set_textcolor(l_e5, i_col_e5)
	label.set_textalign(l_e5, text.align_center)
    label.set_x(l_e5, int(currentTime - 1000000000))
    label.set_y(l_e5, ema5[0])

    //EMA2
	var label l_e6 = label.new(bar_index, close, str.tostring(i_res_e6) + ' ' + str.tostring(i_len_e6), xloc=xloc.bar_time, style=label.style_none, size=size.huge)
	label.set_textcolor(l_e6, i_col_e6)
	label.set_textalign(l_e6, text.align_center)
    label.set_x(l_e6, int(currentTime - 10000000))
    label.set_y(l_e6, ema6[0])
    
    //EMA7
	var label l_e7 = label.new(bar_index, close, str.tostring(i_res_e7) + ' ' + str.tostring(i_len_e7), xloc=xloc.bar_time, style=label.style_none, size=size.huge)
	label.set_textcolor(l_e7, i_col_e7)
	label.set_textalign(l_e7, text.align_center)
    label.set_x(l_e7, int(currentTime - 1000000000))
    label.set_y(l_e7, ema7[0])

    //EMA8
	var label l_e8 = label.new(bar_index, close, str.tostring(i_res_e8) + ' ' + str.tostring(i_len_e8), xloc=xloc.bar_time, style=label.style_none, size=size.huge)
	label.set_textcolor(l_e8, i_col_e8)
	label.set_textalign(l_e8, text.align_center)
    label.set_x(l_e8, int(currentTime - 1000000000))
    label.set_y(l_e8, ema8[0])

//if show_sqz
    //coming soon, draw symbols on chart to indicate a prime squeeze