Dogaressa Helper (Emas)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ToddyS2K

//@version=5
indicator("Dogaressa Helper (Emas)", "Dogaressa Helper (Emas)", overlay=true)

print(txt) => var _label = label.new(bar_index, na, txt, xloc.bar_index, yloc.price, color(na), label.style_none, color.gray, size.large, text.align_left), label.set_xy(_label, bar_index, ta.highest(10)[1]), label.set_text(_label, txt)

get_ema50 (isCrypto) => (isCrypto) ? ta.ema(close,60) : ta.ema(close,50)
get_ema200 (isCrypto) => (isCrypto) ? ta.ema(close,223) : ta.ema(close,200)

ema10Color = input(color.yellow,"Ema 10")
ema50Color = input(color.blue,"Ema 50/60")
ema200Color = input(color.green,"Ema 200/223")
isCrypto = input(true,"Trading crypto")

ema10 = ta.ema(close,10)
var float ema50 = na
var float ema200 = na

if isCrypto
    ema50 := ta.ema(close,60)
    ema200 := ta.ema(close,223)
    label50 = "60"
    label200 = "223"
else
    ema50 := ta.ema(close,50)
    ema200 := ta.ema(close,200)
    label50 = "50"
    label200 = "200"

ema10_M30 = request.security(syminfo.tickerid,"30",ema10)
ema10_H1 = request.security(syminfo.tickerid,"60",ema10)
ema10_H4 = request.security(syminfo.tickerid,"240",ema10)
ema10_D = request.security(syminfo.tickerid,"D",ema10)

ema50_M30 = request.security(syminfo.tickerid,"30",get_ema50(isCrypto))
ema50_H1 = request.security(syminfo.tickerid,"60",get_ema50(isCrypto))
ema50_H4 = request.security(syminfo.tickerid,"240",get_ema50(isCrypto))
ema50_D = request.security(syminfo.tickerid,"D",get_ema50(isCrypto))

ema200_M30 = request.security(syminfo.tickerid,"30",get_ema200(isCrypto))
ema200_H1 = request.security(syminfo.tickerid,"60",get_ema200(isCrypto))
ema200_H4 = request.security(syminfo.tickerid,"240",get_ema200(isCrypto))
ema200_D = request.security(syminfo.tickerid,"D",get_ema200(isCrypto))

var line ln10_M30 = na
var line ln10_H1 = na
var line ln10_H4 = na
var line ln10_D = na

var label lb10_M30 = na
var label lb10_H1 = na
var label lb10_H4 = na
var label lb10_D = na

var line ln50_M30 = na
var line ln50_H1 = na
var line ln50_H4 = na
var line ln50_D = na

var label lb50_M30 = na
var label lb50_H1 = na
var label lb50_H4 = na
var label lb50_D = na

var line ln200_M30 = na
var line ln200_H1 = na
var line ln200_H4 = na
var line ln200_D = na

var label lb200_M30 = na
var label lb200_H1 = na
var label lb200_H4 = na
var label lb200_D = na

line.delete(ln10_M30)
line.delete(ln10_H1)
line.delete(ln10_H4)
line.delete(ln10_D)
label.delete(lb10_M30)
label.delete(lb10_H1)
label.delete(lb10_H4)
label.delete(lb10_D)

line.delete(ln50_M30)
line.delete(ln50_H1)
line.delete(ln50_H4)
line.delete(ln50_D)
label.delete(lb50_M30)
label.delete(lb50_H1)
label.delete(lb50_H4)
label.delete(lb50_D)

line.delete(ln200_M30)
line.delete(ln200_H1)
line.delete(ln200_H4)
line.delete(ln200_D)
label.delete(lb200_M30)
label.delete(lb200_H1)
label.delete(lb200_H4)
label.delete(lb200_D)

//For intraday timeframes, three bars back and three bars forward
x1 = time - timeframe.multiplier * 3 * 60 * 1000
x2 = time + timeframe.multiplier * 4 * 60 * 1000
x1  := time
x2lab = time + timeframe.multiplier * 2 * 60 * 1000

if timeframe.multiplier < 30 and timeframe.isminutes
    ln10_M30 := line.new(x1, ema10_M30, x2, ema10_M30, xloc=xloc.bar_time, width=2, color=ema10Color)
    lb10_M30 := label.new(x2lab, ema10_M30, "M30", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema10Color, textalign=text.align_left)
    ln50_M30 := line.new(x1, ema50_M30, x2, ema50_M30, xloc=xloc.bar_time, width=2, color=ema50Color)
    lb50_M30 := label.new(x2lab, ema50_M30, "M30", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema50Color, textalign=text.align_left)
    ln200_M30 := line.new(x1, ema200_M30, x2, ema200_M30, xloc=xloc.bar_time, width=2, color=ema200Color)
    lb200_M30 := label.new(x2lab, ema200_M30, "M30", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema200Color, textalign=text.align_left)

if timeframe.multiplier < 60 and timeframe.isminutes
    ln10_H1 := line.new(x1, ema10_H1, x2, ema10_H1, xloc=xloc.bar_time, width=2, color=ema10Color)
    lb10_H1 := label.new(x2lab, ema10_H1, "H1", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema10Color, textalign=text.align_left)
    ln50_H1 := line.new(x1, ema50_H1, x2, ema50_H1, xloc=xloc.bar_time, width=2, color=ema50Color)
    lb50_H1 := label.new(x2lab, ema50_H1, "H1", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema50Color, textalign=text.align_left)
    ln200_H1 := line.new(x1, ema200_H1, x2, ema200_H1, xloc=xloc.bar_time, width=2, color=ema200Color)
    lb200_H1 := label.new(x2lab, ema200_H1, "H1", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema200Color, textalign=text.align_left)
   
if timeframe.multiplier < 240 and timeframe.isminutes
    ln10_H4 := line.new(x1, ema10_H4, x2, ema10_H4, xloc=xloc.bar_time, width=2, color=ema10Color)
    lb10_H4 := label.new(x2lab, ema10_H4, "H4", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema10Color, textalign=text.align_left)
    ln50_H4 := line.new(x1, ema50_H4, x2, ema50_H4, xloc=xloc.bar_time, width=2, color=ema50Color)
    lb50_H4 := label.new(x2lab, ema50_H4, "H4", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema50Color, textalign=text.align_left)
    ln200_H4 := line.new(x1, ema200_H4, x2, ema200_H4, xloc=xloc.bar_time, width=2, color=ema200Color)
    lb200_H4 := label.new(x2lab, ema200_H4, "H4", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema200Color, textalign=text.align_left)
   
if timeframe.multiplier <= 240 and timeframe.isminutes
    ln10_D := line.new(x1, ema10_D, x2, ema10_D, xloc=xloc.bar_time, width=2, color=ema10Color)
    lb10_D := label.new(x2lab, ema10_D, "D", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema10Color, textalign=text.align_left)
    ln50_D := line.new(x1, ema50_D, x2, ema50_D, xloc=xloc.bar_time, width=2, color=ema50Color)
    lb50_D := label.new(x2lab, ema50_D, "D", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema50Color, textalign=text.align_left)
    ln200_D := line.new(x1, ema200_D, x2, ema200_D, xloc=xloc.bar_time, width=2, color=ema200Color)
    lb200_D := label.new(x2lab, ema200_D, "D", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema200Color, textalign=text.align_left)


