DEBUG SIGNAL
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sinnerfilozofiya

//@version=5
indicator(title="DEBUG SIGNAL",shorttitle="LONG SIGNALS",overlay=true)


fast=input(21,"fast ema")
slow=input(50,"slow ema")
rsi=ta.rsi(close,14)
ema21=ta.ema(close,fast)
ema50=ta.ema(close,slow)

emacrossover=ta.crossover(ema21,ema50)
emacrossunder=ta.crossunder(ema21,ema50)
buy=ta.crossover(ema21,ema50)
sell=ta.crossunder(ema21,ema50)

//this part is for getting ema data from higher time frames
emaholder1=ta.ema(close,21)
emaholder2=ta.ema(close,50)

fast_ema_15=request.security(syminfo.tickerid,"15",emaholder1)
slow_ema_15=request.security(syminfo.tickerid,"15",emaholder2)

//old golden numbers were  (22.4-25,54)


val_pullback=ta.crossunder(rsi,30.3)
val_g1=ta.crossunder(rsi,25.6)
val_g2=ta.crossunder(rsi,22)
val_g3=ta.crossunder(rsi,18.9)
val_short=ta.crossover(rsi,77.6)

//now we go for buy options when 15m 21ema is above 50ema

if(fast_ema_15>slow_ema_15)
//    if(rsi<=30)
  //      if(rsi>10)
    if(val_pullback)            
        lbl=label.new(bar_index,low,"pb")
        label.set_color(lbl,color.yellow)
        label.set_yloc(lbl,yloc.belowbar)
        label.set_style(lbl,label.style_label_up)

    if(rsi>=68)
        if(rsi<=90)
            lbl=label.new(bar_index,low,"c")
            label.set_color(lbl,color.purple)
            label.set_yloc(lbl,yloc.abovebar)
            label.set_style(lbl,label.style_label_down)

//val_g1=ta.crossunder(rsi,25.6)
//val_g2=ta.crossunder(rsi,22)
//val_g3=ta.crossunder(rsi,18.9)
//val_short=ta.crossover(rsi,77.6)

if(fast_ema_15<slow_ema_15)
    if(val_g1 and rsi[1]>rsi[0] and rsi[1]>=30)
        if(rsi<=25.6)
            if(rsi>=22)
                    
                lbl=label.new(bar_index,low,"e1")
                label.set_color(lbl,color.yellow)
                label.set_yloc(lbl,yloc.belowbar)
                label.set_style(lbl,label.style_label_up)
    if(val_g2 and rsi[1]>=30)
        if(rsi<22)
            if(rsi>=20)
                lbl=label.new(bar_index,low,"e2")
                label.set_color(lbl,color.yellow)
                label.set_yloc(lbl,yloc.belowbar)
                label.set_style(lbl,label.style_label_up)

    if(val_g3)
        if(rsi<20)
            if(rsi>=1)
                    
                lbl=label.new(bar_index,low,"b")
                label.set_color(lbl,color.yellow)
                label.set_yloc(lbl,yloc.belowbar)
                label.set_style(lbl,label.style_label_up)
    if(rsi>=66)
        if(rsi<=90)
            lbl=label.new(bar_index,low,"c")
            label.set_color(lbl,color.purple)
            label.set_yloc(lbl,yloc.abovebar)
            label.set_style(lbl,label.style_label_down)

    

if(val_short)
    lbl=label.new(bar_index,low,"short")
    label.set_color(lbl,color.red)
    label.set_yloc(lbl,yloc.abovebar)
    label.set_style(lbl,label.style_label_down)





//if(rsi>69.9)            //(sell)
//    if(rsi<75)
//        lbl=label.new(bar_index,low,"sell")
//        label.set_color(lbl,color.red)
//        label.set_yloc(lbl,yloc.abovebar)
//        label.set_style(lbl,label.style_label_down)
//if(rsi>48)            //(sell)
  //  if(rsi<51)
    //    lbl=label.new(bar_index,low,"sell")
      //  label.set_color(lbl,color.red)
    //    label.set_yloc(lbl,yloc.abovebar)
      //  label.set_style(lbl,label.style_label_down)
//if(rsi>=22)
//    if(rsi<=25.5)
//        lbl=label.new(bar_index,low,"buy")
//        label.set_color(lbl,color.green)
//        label.set_yloc(lbl,yloc.belowbar)
//        label.set_style(lbl,label.style_label_up)
//

//line=4.631
//sl=4.607
//plot(sl, color=color.red, linewidth=2, style=plot.style_linebr,  trackprice=true)

//plot(ema50,color=color.black)
//plot(ema21,color=color.blue)
plot(slow_ema_15,color=color.green)
plot(fast_ema_15,color=color.red)



//buy2 = label.new(bar_index, low, text="Hello, world!", style=label.style_arrowup)



//bgcolor(emacrossover ? color.green : na)
//bgcolor(emacrossunder ? color.red : na)