CANDLE STICK HEATMAP
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © traderharikrishna

//@version=5
indicator("CANDLE STICK HEATMAP",overlay=true)
bullco=input.color(color.green,'', group='Log',inline='1')
bearco=input.color(color.red,'', group='Log',inline='1')
txtco=input.color(color.white,'', group='Log',inline='1')
hide=input.bool(true,'Indicator Stats')
log_show_msg = input.int(60, title='Candles to show', group='Log')//rows
col=  input.int(12, title='Split', group='Log')//rows
log_offset = input.int(0, title='# Candles offset', group='Log', step=1)
//geo=input.string("Asia/Kolkata",'TimeZone',options=['Asia/Kolkata','America/New_York'],tooltip='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones')
geo=input.string("GMT+5:30", "Timezone", options=["GMT+0", "GMT+1", "GMT+2", "GMT+3","GMT+4","GMT+5","GMT+5:30","GMT+6","GMT+7","GMT+8","GMT+9","GMT+10","GMT+11","GMT+12","GMT-1", "GMT-2", "GMT-3","GMT-4","GMT-5","GMT-6","GMT-7","GMT-8","GMT-9","GMT-10","GMT-11","GMT-12"])
format= "yyyy-MM-dd"
format2='HH:mm'
tm=str.tostring(str.format_time( time(timeframe.period, '', ''),format,geo))
tm:=tm+'\n'+str.tostring(str.format_time( time(timeframe.period, '', ''),format2,geo))
malen=input.int(200,'EMA Length')
ma=ta.ema(close,malen)
plot(ma,color=color.blue,linewidth=4,title = 'EMA200')
var bar_arr = array.new_int(0)
var time_arr = array.new_string(0)
var msg_arr = array.new_string(0)
var type_arr = array.new_string(0)

log_msg(message, type, times) =>
    array.push(bar_arr, bar_index)
    array.push(time_arr,times)
    array.push(msg_arr, message)
    array.push(type_arr, type)
	
msg()=>
    rsi=ta.rsi(close,14)
    [p,m,adx]=ta.dmi(14,14)
    [macd,signal,hist]=ta.macd(close,12,26,9)
    vma=ta.ema(volume,20)
    
    updn=close>ma?'upTrend':'DnTrend'
    msg='\n----\n'+str.tostring(updn)+'\n'
    msg:=msg+'RSI:'+str.tostring(math.round(rsi))+'\n'
    msg:=msg+'ADX:'+str.tostring(math.round(adx))+'\n'
    msg:=msg+'MACD:'+str.tostring(hist>0?'UP':'DN')+'\n'
    msg:=msg+'Vol:'+str.tostring(volume>vma?'Good':'Low')
    msg

if open<close
    log_msg(hide?msg():na,'bullish',tm)
if open>close
    log_msg(hide?msg():na,'bearish',tm)
///////////////////////////////////
//  2. Create and fill log table //


var log_tbl = table.new(position.bottom_right,  log_show_msg +1, col+1, border_width=1)

if barstate.islast 
    for i = 1 to log_show_msg by 1
        arr_i = array.size(msg_arr) - log_show_msg + i - 1 - log_offset
        if arr_i < 0
            break
        type = array.get(type_arr, arr_i)
        msg_color = type =='bullish'? bullco 
                     :type =='bearish'?bearco
                     :type == 'message' ? #a19f9f 
                     :type == 'warning' ? #F5AC4E 
                     :type == 'error' ? #2996fe 
                     :type == 'buy' ? #03a903 
                     :type == 'sell' ? #ff0000 
                     :color.gray
        
        for e=0 to col
            if i>col*e and i<=col*e+col
                ///table.cell(log_tbl,i-col*e, e,str.tostring(i)+','+str.tostring(0) +'\n'+ array.get(time_arr, arr_i), bgcolor=msg_color, text_size=size.small,text_color=color.white)
                table.cell(log_tbl,i-col*e, e, array.get(time_arr, arr_i)+array.get(msg_arr, arr_i)+'\n', bgcolor=msg_color, text_size=size.small,text_color=txtco)