Kros-Candles
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kemaltkn

//@version=5
indicator(title="Kros-Candles", overlay = true,shorttitle="Kros Candles")

ShowMarket = input.bool(group='Market-Table', title='Show Market Table ?', defval=false, inline='showtable')





BarRange() =>
	high - low
BodyRange() =>
	math.abs(close - open)
	
rangeOfBar = BarRange()
rangeOfBody = BodyRange()

isUp = close > open
isDown = close <= open 

KrosCandle = 0.93  <= rangeOfBody / rangeOfBar 

PumpColor = input.color(group='Bars', title='Pump Bar Color', defval= color.lime , inline='pump')
DumpColor = input.color(group='Bars', title='Dump Bar Color', defval=color.red, inline='dump')



CandleColor = KrosCandle and isUp ? PumpColor : KrosCandle and isDown ? DumpColor : na , 
barcolor(CandleColor)
    
plotshape(KrosCandle,style=shape.triangledown,size=size.small, location=location.abovebar, color=color.silver,title="FullBodyCandle")


//-----------------------------------------
//Table


Btc_dom1 = request.security('CRYPTOCAP:BTC.D' ,"D" ,expression = open) 
Btc_dom2 = request.security('CRYPTOCAP:BTC.D' ,"D" ,expression = close) 
Change = (Btc_dom2 - Btc_dom2[1]) / Btc_dom2[1]  * 100


TotalOp = request.security('CRYPTOCAP:TOTAL' ,"D" ,expression = open) 
TotalClose = request.security('CRYPTOCAP:TOTAL' ,"D" ,expression = close) 
Change1 = (TotalClose - TotalClose[1]) / TotalClose[1]  * 100

Total2Op = request.security('CRYPTOCAP:TOTAL2' ,"D" ,expression = open) 
Total2Close = request.security('CRYPTOCAP:TOTAL2' ,"D" ,expression = close) 
Change2 = (Total2Close - Total2Close[1]) / Total2Close[1]  * 100


Dom_Text = Btc_dom1 > Btc_dom2 ? color.red : Btc_dom1 < Btc_dom2 ? color.green : na
Total_Text = TotalOp > TotalClose ? color.red : TotalOp < TotalClose ? color.green  :na
Total2_Text = Total2Op > Total2Close ? color.red : Total2Op < Total2Close ? color.green  :na



if barstate.islast and ShowMarket

    var infoTable = table.new(position = position.top_right, columns = 2, rows = 3, bgcolor = color.rgb(93, 96, 107, 70), border_width = 1)

    table.cell(table_id = infoTable, column = 0, row = 2, text = "BTC.D : ",text_color=color.rgb(31, 188, 211, 0),text_halign=text.align_left)
    table.cell(table_id = infoTable, column = 1, row = 2, text = "" + str.tostring(Change,"#.##"),text_color=Dom_Text,text_halign=text.align_center )
    
    table.cell(table_id = infoTable, column = 0, row = 0, text = "TOTAL : ",text_color=color.rgb(31, 188, 211, 0),text_halign=text.align_left)
    table.cell(table_id = infoTable, column = 1, row = 0, text = str.tostring(Change1,"#.##"),text_color=Total_Text,text_halign=text.align_center)
    
    table.cell(table_id = infoTable, column = 0, row = 1, text = "TOTAL2 : ",text_color=color.rgb(31, 188, 211, 0),text_halign=text.align_left)
    table.cell(table_id = infoTable, column = 1, row = 1, text = str.tostring(Change2,"#.##"),text_color=Total_Text,text_halign=text.align_center)
    
    
//-----------------------------------------
//Emas
threeEmaLength = 50
fourEmaLength = 200


showEmas = input.bool(group='EMAs', title='Show EMAs?', defval=false, inline='showemas')
threeEmaColor = input.color(group='EMAs', title='50', defval=color.rgb(31, 188, 211, 0), inline='emacolors')
fourEmaColor = input.color(group='EMAs', title='200', defval=color.rgb(255, 255, 255, 0), inline='emacolors')



threeEma = ta.ema(close, threeEmaLength)
plot(showEmas ? threeEma : na, color=threeEmaColor, title='50 Ema')

fourEma = ta.ema(close, fourEmaLength)
plot(showEmas ? fourEma : na, color=fourEmaColor, title='200 Ema')


//-----------------------------------------  
    
   