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

//@version=5
indicator("Directional_Candle", overlay=true)

//TP y SL Alcista velas direccionales A1 
//plot(close*1.0075,"Take Profit Up", color.green)
//plot(close+(2*(close-(low*0.999))),"R2-UP", color.yellow)
//plot(close+((close-(low*0.999))),"R1-UP", color.orange)
//plot(low*0.999,"Stop Loss Up", color.red)

plot(low-0.02,"SL-LONG", color.red)
plot((low-0.02)*1.0035,"ENTRY-LONG", color.green)
plot((low-0.02)*1.00875,"TP-LONG", color.blue)
plot(close*1.005,"TP-LONG-MARKET", color.orange)



//TP y SL Bajista velas direccionales B3
//plot(close*0.9925,"Take Profit Down", color.green)
//plot(close-(2*((high*1.001)-close)),"R2-DOWN", color.yellow)
//plot(close-((high*1.001)-close),"R1-DOWN", color.orange)
//plot(high*1.001,"Stop Loss Down", color.red)

plot(high+0.02,"SL-SHORT", color.red)
plot((high+0.02)*0.9965,"ENTRY-SHORT", color.green)
plot((high+0.02)*0.99125,"TP-SHORT", color.blue)
plot(close*0.995,"TP-SHORT-MARKET", color.orange)


//A1
//barcolor ((close > open and close > high[1] and ((close-low)/(high-low) > 0.66)) ? color.blue : na)
plotshape((close > open and close > high[1] and ((close-low)/(high-low) > 0.66)), title="Candle A1", text='A1'+'\n', location=location.belowbar, style=shape.cross, size=size.tiny, color=color.green, textcolor=color.gray, transp=0)

//B3
//barcolor ((close < open  and close < low[1] and ((high-close)/(high-low) > 0.66)) ? color.orange : na)
plotshape((close < open  and close < low[1] and ((high-close)/(high-low) > 0.66)), title="Candle B3", text='B3'+'\n', location=location.abovebar, style=shape.cross, size=size.tiny, color=color.red, textcolor=color.gray, transp=0)

//Rechazo alcista
//barcolor ((close > open and ((high-open)/(high-low) < 0.33)) ? color.blue : na)
plotshape((close > open and ((high-open)/(high-low) < 0.33)), title="Rejection Up", text='RU'+'\n', location=location.belowbar, style=shape.cross, size=size.tiny, color=color.green, textcolor=color.gray, transp=1)

//Rechazo bajista
//barcolor ((close < open  and ((open-low)/(high-low) < 0.33)) ? color.orange : na)
plotshape((close < open  and ((open-low)/(high-low) < 0.33)), title="Rejection Down", text='RD'+'\n', location=location.abovebar, style=shape.cross, size=size.tiny, color=color.red, textcolor=color.gray, transp=0)

//Envolvente alcista
//barcolor ((open[1] > close [1] and open < close and high > high[1] and low < low[1]) ? color.blue : na)
plotshape((open[1] > close [1] and open < close and high > high[1] and low < low[1]), title="Engulfing Up", text='EU'+'\n', location=location.belowbar, style=shape.cross, size=size.tiny, color=color.green, textcolor=color.gray, transp=0)

//Envolvente bajista
//barcolor ((open[1] < close [1] and open > close and low < low[1] and high > high[1]) ? color.orange : na)
plotshape((open[1] < close [1] and open > close and low < low[1] and high > high[1]), title="Engulfing Down", text='ED'+'\n', location=location.abovebar, style=shape.cross, size=size.tiny, color=color.red, textcolor=color.gray, transp=0)

//Vela interior alcista
//barcolor ((open[1] > close [1] and open < close and high < high[1] and low > low[1]) ? color.blue : na)
plotshape((open[1] > close [1] and open < close and high < high[1] and low > low[1]), title="Inside Up", text='IU'+'\n', location=location.belowbar, style=shape.cross, size=size.tiny, color=color.green, textcolor=color.gray, transp=0)

//Vela interior bajista
//barcolor ((open[1] < close [1] and open > close and high < high[1] and low > low[1]) ? color.orange : na)
plotshape((open[1] < close [1] and open > close and high < high[1] and low > low[1]), title="Inside Down", text='ID'+'\n', location=location.abovebar, style=shape.cross, size=size.tiny, color=color.red, textcolor=color.gray, transp=0)

//Entrada en largo TP/Sl
//plotshape((close > open and close > high[1] and ((close-low)/(high-low) > 0.66)) or (close > open and ((high-open)/(high-low) < 0.33)) or (open[1] > close [1] and open < close and high > high[1] and low < low[1]) or (open[1] > close [1] and open < close and high < high[1] and low > low[1]), title="Long", text="", location=location.abovebar, style=shape.diamond, size=size.tiny, color=color.green, textcolor=color.gray, transp=0)

//Entrada en corto TP/SL
//plotshape((close < open  and close < low[1] and ((high-close)/(high-low) > 0.66)) or (close < open  and ((open-low)/(high-low) < 0.33)) or (open[1] < close [1] and open > close and low < low[1] and high > high[1]) or (open[1] < close [1] and open > close and high < high[1] and low > low[1]), title="Short", text="", location=location.belowbar, style=shape.diamond, size=size.tiny, color=color.red, textcolor=color.gray, transp=0)


//l = label.new(bar_index, high, '\n\n\n\n\n\n\n\n\n\n\n\n\nTP-UP: '+ str.tostring(close*1.0075) + '\n SL-UP:' + str.tostring(low*0.999) + '\nR-UP: ' + str.tostring(((high*1.0075)-close)/(close-(low*0.999))) +  '\n\nTP-DOWN: '+ str.tostring(close*0.9925) + '\n SL-DOWN:' + str.tostring(high*1.001) + '\nR-DOWN: ' + str.tostring((close-(low*0.9925))/((high*1.001)-close)),  color=close > open ? color.white : color.white, textcolor=color.black, style=label.style_none, yloc=yloc.belowbar)
//l = label.new(bar_index, high, '\n\n\n\n\n\n\n\n\n\n\n\n\nSL-LONG: '+ str.tostring(low-0.02) + '\n ENTRY-LONG:' + str.tostring((low-0.02)*1.0035) + '\n TP-LONG:' + str.tostring((low-0.02)*1.0105) + '\n SL-SHORT:' + str.tostring(high+0.002) + '\n ENTRY-SHORT: ' + str.tostring((high+0.02)*0.9895) + '\n TP-SHORT: ' + str.tostring((high+0.02)*0.993),  color=close > open ? color.white : color.white, textcolor=color.black, style=label.style_none, yloc=yloc.belowbar)
//label.delete(l[1])

//m = label.new(bar_index, high, '\n\nTPDOWN: '+ str.tostring(close*0.9925) + '\n SL:' + str.tostring(high*1.001) + '\nR: ' + str.tostring(((high*1.001)-close)/(close-(low*0.9925))),  color=close < open ? color.white : color.white, textcolor=color.red, style=label.style_none, yloc=yloc.belowbar)
//label.delete(m[1])