Daily Scalping Moving Averages
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © exlux99

//@version=5
indicator("Daily Scalping Moving Averages", overlay=true)


ema10 = input(10, title="EMA Fast", group="EMA Lengths")
ema20 = input(20, title="EMA Medium", group="EMA Lengths")
ema50 = input(50, title="EMA Slow", group="EMA Lengths")

// SMAS input
sma10 = input(10, title="SMA Fast", group="SMA Lengths")
sma20 = input(20, title="SMA Medium", group="SMA Lengths")
sma50 = input(50, title="SMA Slow", group="SMA Lengths")

vwap_w=request.security(syminfo.tickerid, "W",ta.vwap)

src = close
haclose = close

//-------------- MOVING AVERAGES CALCULATION

//Simple moving averages
calc_sma10 = ta.sma(src, sma10)

calc_sma20 = ta.sma(src, sma20)

calc_sma50 = ta.sma(src, sma50)


//Exponential moving averages
calc_ema10 = ta.ema(src, ema10)

calc_ema20 = ta.ema(src, ema20)

calc_ema50 = ta.ema(src, ema50)


length = input.int(title="Length ATR", defval=14, minval=1, group="Volatility")
smoothing = "RMA"

ma_function(source, length) =>
	switch smoothing
		"RMA" => ta.rma(source, length)
		"SMA" => ta.sma(source, length)
		"EMA" => ta.ema(source, length)
		=> ta.wma(source, length)

daily_atr=request.security(syminfo.tickerid, "D", ta.atr(length))
daily_close=request.security(syminfo.tickerid, "D", close[1])

var float gica = 0.0
gica:= daily_atr


////////////////////////////////////////////////////////////////////////////
posInput = input.string(title='Position', defval='Middle Right', options=['Bottom Left', 'Bottom Right', 'Top Left', 'Top Right', 'Middle Right'], group="Table Position")
var pos = posInput == 'Bottom Left' ? position.bottom_left : posInput == 'Bottom Right' ? position.bottom_right : posInput == 'Top Left' ? position.top_left : posInput == 'Top Right' ? position.top_right : posInput == 'Middle Right' ? position.middle_right: na


var table table_atr = table.new(pos, 15, 15, border_width=3)

if barstate.islast

    table.cell(table_atr, 0, 0, 'EMA 10 ', text_color=color.white, text_size=size.normal, bgcolor=color.blue)
    table.cell(table_atr, 0, 1, calc_ema10>=haclose? "Long" : "Short" , text_color=color.white, text_size=size.normal, bgcolor= calc_ema10>=haclose? color.green : color.red)
    
    table.cell(table_atr, 1, 0, 'EMA 20 ', text_color=color.white, text_size=size.normal, bgcolor=color.blue)
    table.cell(table_atr, 1, 1, calc_ema20>=haclose? "Long" : "Short", text_color=color.white, text_size=size.normal, bgcolor= calc_ema20>=haclose? color.green : color.red)    
    
    table.cell(table_atr, 2, 0, 'EMA 50 ', text_color=color.white, text_size=size.normal, bgcolor=color.blue)
    table.cell(table_atr, 2, 1, calc_ema50>=haclose? "Long" : "Short", text_color=color.white, text_size=size.normal, bgcolor= calc_ema50>=haclose? color.green : color.red)
    

    table.cell(table_atr, 0, 2, 'SMA 10 ', text_color=color.white, text_size=size.normal, bgcolor=color.blue)
    table.cell(table_atr, 0, 3, calc_sma10>=haclose? "Long" : "Short", text_color=color.white, text_size=size.normal, bgcolor= calc_sma10>=haclose? color.green : color.red)
    
    table.cell(table_atr, 1, 2, 'SMA 20 ', text_color=color.white, text_size=size.normal, bgcolor=color.blue)
    table.cell(table_atr, 1, 3, calc_sma20>=haclose? "Long" : "Short", text_color=color.white, text_size=size.normal, bgcolor= calc_sma20>=haclose? color.green : color.red)
    
    table.cell(table_atr, 2, 2, 'SMA 50 ', text_color=color.white, text_size=size.normal, bgcolor=color.blue)
    table.cell(table_atr, 2, 3, calc_sma50>=haclose? "Long" : "Short", text_color=color.white, text_size=size.normal, bgcolor= calc_sma50>=haclose? color.green : color.red)

    
    table.cell(table_atr, 0, 4, 'VWAP Daily', text_color=color.white, text_size=size.normal, bgcolor=color.blue)
    table.cell(table_atr, 0, 5, ta.vwap>haclose? "Long" : "Short", text_color=color.white, text_size=size.normal, bgcolor= ta.vwap>haclose? color.green : color.red)

    table.cell(table_atr, 1, 4, 'Daily TOP', text_color=color.white, text_size=size.normal, bgcolor=color.blue)
    table.cell(table_atr, 1, 5, str.tostring(daily_close+gica, '#.##'), text_color=color.white, text_size=size.normal, bgcolor=color.purple)

    table.cell(table_atr, 2, 4, 'Daily BOT', text_color=color.white, text_size=size.normal, bgcolor=color.blue)
    table.cell(table_atr, 2, 5, str.tostring(daily_close-gica, '#.##'), text_color=color.white, text_size=size.normal, bgcolor=color.maroon)


plot(daily_close+gica, title='Daily TOP ATR')
plot(daily_close-gica , title='Daily BOT ATR')

 
    
