MTF Ichimoku Analysis[tanayroy]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tanayroy

//@version=5
indicator("MTF Ichimoku Analysis[tanayroy]", shorttitle="MTF ICHIMOKU",overlay=true)
TRANSP=60
SUBTRANSP=80
var string GP1 = "Ichimoku Settings"
tenkanSenPeriod = input.int(9, minval=1, title="Tenkan Sen Length",group = GP1)
kijunSenPeriod = input.int(26, minval=1, title="Kijun Sen Length",group = GP1)
senkouBLen = input.int(52, minval=1, title="Senkou B Length",group = GP1)
displacement = input.int(26, minval=1, title="Displacement",group = GP1)
chikuspanConsolidationBar=input.int(5, minval=1, title="Chikou Consolidation Bar",group = GP1)
kumoShadowPeriod=input.int(252, minval=1, title="Kumo Shadow Analyzing Period",group = GP1)

var string GP2 = "Resolution"

resolution1= input.timeframe('5', "Resolution 1",group=GP2,inline = "21")
resolution2= input.timeframe('30', "Resolution 2",group=GP2,inline = "21")
resolution3= input.timeframe('60', "Resolution 3",group=GP2,inline = "22")
resolution4= input.timeframe('D', "Resolution 4",group=GP2,inline = "22")
resolution5= input.timeframe('W', "Resolution 5",group=GP2,inline = "23")
resolution6= input.timeframe('M', "Resolution 6",group=GP2,inline = "23")

var string GP3 = "Display"

tableYpos= input.string("top", "Panel position", inline = "31", options = ["top", "middle", "bottom"], group = GP3)
tableXpos = input.string("right", "", inline = "31", options = ["left", "center", "right"], group = GP3)
c_bull    = input.color(color.new(color.green, 30), "Bull", inline = "32", group = GP3)
c_bear    = input.color(color.new(color.red, 30), "Bear", inline = "32", group = GP3)
c_neutral = input.color(color.new(color.blue, 30), "Neutral", inline = "32", group = GP3)
useShortNotation = input.bool(false,"Use Shorthand Notations", group = GP3)

donchian(len) => math.avg(ta.lowest(len), ta.highest(len))


GetPipSize() =>
    if syminfo.type == "forex"
        syminfo.mintick * 10
    else
        1
        
pip()=>
    syminfo.type == "forex"?"(Pips)":na
    
f_MTFIchi() =>
    tenkanSen = donchian(tenkanSenPeriod)
    kijunSen = donchian(kijunSenPeriod )
    senkouA = (tenkanSen+kijunSen)/2
    senkouB = donchian(senkouBLen )
    kumoUpLine = senkouA[displacement]>=senkouB[displacement]?senkouA[displacement]:senkouB[displacement]
    kumoDownLine = senkouA[displacement]>=senkouB[displacement]?senkouB[displacement]:senkouA[displacement]
    highestSenkouA = ta.highest(senkouA[displacement],kumoShadowPeriod)
    lowestSenkouA = ta.lowest(senkouA[displacement],kumoShadowPeriod)
    highestSenkouB = ta.highest(senkouB[displacement],kumoShadowPeriod)
    lowestSenkouB = ta.lowest(senkouB[displacement],kumoShadowPeriod)
    highestCloud = highestSenkouA>=highestSenkouB?highestSenkouA:highestSenkouB
    lowestCloud = lowestSenkouA<=lowestSenkouB?lowestSenkouA:lowestSenkouB
    kijunSlp = (ta.change(kijunSen)/kijunSen)
    senkouASlp = (ta.change(senkouA)/senkouA) 
    senkouBSlp = (ta.change(senkouB)/senkouB) 
    tenkanSlp = (ta.change(tenkanSen)/tenkanSen) 
    kumoUpLinechiku = senkouA[displacement+displacement]>=senkouB[displacement+
     displacement]?senkouA[displacement+displacement]:senkouB[displacement+displacement]
    kumoDownLinechiku = senkouA[displacement+displacement]>=senkouB[displacement+
     displacement]?senkouB[displacement+displacement]:senkouA[displacement+displacement]
    chikuHigh = 0.0
    chikuLow = low[displacement-1]
    for i = displacement-1 to displacement-chikuspanConsolidationBar
        chikuHigh:=math.max(high[i],chikuHigh)
    
    for i = displacement-1 to displacement-chikuspanConsolidationBar
        chikuLow:=math.min(low[i],chikuLow)
    float score = 0.0    
    tenkanCrossover = ta.barssince(ta.crossover(close,tenkanSen) or ta.crossunder(close,tenkanSen))
    kijunSenCrossover = ta.barssince(ta.crossover(close,kijunSen) or ta.crossunder(close,kijunSen))
    tsCrossover = ta.barssince(ta.crossover(tenkanSen,kijunSen) or ta.crossunder(tenkanSen,kijunSen))
    kumoCrossover = ta.barssince(ta.crossover(close,kumoUpLine) or ta.crossunder(close,kumoDownLine))
    senkouCrossover = ta.barssince(ta.crossover(senkouA,senkouB) or ta.crossunder(senkouA,senkouB))
    distanceBetweenTenkanAndPrice = math.abs(close-tenkanSen)/GetPipSize()
    distanceBetweenKijunAndPrice = math.abs(close-kijunSen)/GetPipSize()
    
    //Price Vs Kumo (Score +-2)
    priceKumo = 0
    if close > kumoUpLine
        priceKumo := 1
        score := score + 2.0
    else if close<kumoDownLine
        priceKumo := 2
        score := score - 2.0
    
    //Price Vs TenkanSen (Score +-0.5)
    priceTenkanSen = 0
    if close >= tenkanSen
        priceTenkanSen := 1
        if priceKumo==1
            score := score + 0.5
        else
            score := score - 0.5
            
    else if close < tenkanSen
        priceTenkanSen := 2
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5
    
    //Price Vs KijunSen (Score +-0.5)
    priceKijunSen = 0
    if close >= kijunSen
        priceKijunSen := 1
        if priceKumo ==1
            score := score + 0.5
        else
            score := score - 0.5
    else if close < kijunSen
        priceKijunSen := 2
        score := score - 0.5
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5
    
    
    //Price Vs. Chikou    
    priceChiku = 0
    if close >= close[26]
        priceChiku := 1
        if priceKumo==1
            score := score + 0.5
        else
            score := score - 0.5
    else if close < close[26]
        priceChiku := 2
        score := score - 0.5
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5
    
    //Tenkan Sen Vs Kijun Sen
    tkCross =  0
    if tenkanSen >= kijunSen
        tkCross := 1
        if priceKumo==1
            score := score + 2.0
        else
            score := score - 2.0
    else if tenkanSen < kijunSen
        tkCross := 2
        if priceKumo == 2
            score := score - 2.0
        else
            score := score + 2.0
    
    //Slope of Tenkan Sen    
    tDirection = 0
    if tenkanSlp > 0
        tDirection := 1
        if priceKumo==1
            score := score + 0.5
        else
            score := score - 0.5
    else if tenkanSlp < 0
        tDirection := 2
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5
    
    //Slope of Kijun Sen
    kDirection = 0
    if kijunSlp > 0
        kDirection := 1
        if priceKumo==1
            score := score + 0.5
        else
            score := score - 0.5
    else if kijunSlp < 0
        kDirection := 2
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5
            
    //Kumo Vs. Tenkansen    
    kumoTenkanSen = 0
    if tenkanSen <= kumoUpLine and tenkanSen>=kumoDownLine
        kumoTenkanSen := 0
        if priceKumo==1
            score := score - 0.5
        else if priceKumo == 2
            score := score + 0.5
    else if tenkanSen > kumoUpLine
        kumoTenkanSen := 1
        if priceKumo==1
            score := score + 0.5
        else
            score := score - 0.5
    else
        kumoTenkanSen := 2
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5

    //Kumo Vs. Kijun Sen
    kumoKijunSen = 0
    if kijunSen <= kumoUpLine and kijunSen>=kumoDownLine
        kumoKijunSen := 0
        if priceKumo==1
            score := score - 0.5
        else if priceKumo == 2
            score := score + 0.5
    else if kijunSen > kumoUpLine
        kumoKijunSen := 1
        if priceKumo==1
            score := score + 0.5
        else
            score := score - 0.5
    else
        kumoKijunSen := 2
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5
    
    //Kumo Vs Chikou    
    kumochiku = 0  
    if close <= kumoUpLinechiku and close >= kumoDownLinechiku
        kumochiku := 0
        if priceKumo==1
            score := score - 0.5
        else if priceKumo==2
            score := score + 0.5
    else if close>kumoUpLinechiku
        kumochiku := 1
        if priceKumo==1
            score := score + 0.5
        else
            score := score - 0.5
    else
        kumochiku := 2
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5
    
    
    //Kumo Shadow Behind price
    kumoShadow = 99
    if close > kumoUpLine and close < highestCloud
        kumoShadow := 11  
        score := score - 0.5
    else if close<kumoDownLine and close>lowestCloud
        kumoShadow := 11 
        score := score + 0.5
        
    if kumoShadow == 99 and  priceKumo ==1
        score := score + 0.5
    else if kumoShadow == 99 and  priceKumo == 2
        score := score - 0.5
    
    senkouAB = 0
    if senkouA >= senkouB
        senkouAB := 1
        if priceKumo==1
            score := score + 0.5
        else
            score := score - 0.5
    else if senkouA < senkouB
        senkouAB := 2
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5
    
    ADirection = 0
    if senkouASlp > 0
        ADirection := 1
        if priceKumo==1
            score := score + 0.5
        else
            score := score - 0.5
    else if senkouASlp < 0
        ADirection := 2 
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5
    
    BDirection = 0
    if senkouBSlp > 0
        BDirection := 1
        if priceKumo==1
            score := score + 0.5
        else
            score := score - 0.5
    else if senkouBSlp < 0
        BDirection := 2 
        if priceKumo == 2
            score := score - 0.5
        else
            score := score + 0.5
    
    chikuHorizontal = 99
    if close > close[26] and close <= chikuHigh
        chikuHorizontal := 11
        if priceKumo == 1
            score := score - 0.5
  
            
    else if close < close[26] and close>=chikuLow
        chikuHorizontal := 11
        if priceKumo == 2
            score := score + 0.5
 
    
    chikuVertical = 99.0
    if close > close[26] and not (close <= chikuHigh)
        pct_ch = ((close-chikuHigh)/close)*100
        chikuVertical := -pct_ch
        // if priceKumo == 1
        //     score := score + 0.5
        
    else if close < close[26] and not (close>=chikuLow)
        pct_ch=((chikuLow-close)/close)*100
        chikuVertical := +pct_ch
        // if priceKumo == 2
        //     score := score - 0.5
    
     
    [priceKumo, priceTenkanSen, priceKijunSen, priceChiku, tkCross, tDirection, 
     kDirection, kumoTenkanSen, kumoKijunSen, kumochiku, kumoShadow, senkouAB, 
     ADirection, BDirection, chikuHorizontal, chikuVertical, tenkanCrossover, 
     kijunSenCrossover, tsCrossover, kumoCrossover, senkouCrossover, score,
     distanceBetweenTenkanAndPrice, distanceBetweenKijunAndPrice]

var table ichimokuTable = table.new(tableYpos + "_" + tableXpos, columns=7, rows=31,bgcolor=color.yellow,border_width=1,border_color=color.white)    
[priceKumo1, priceTenkanSen1, priceKijunSen1, priceChiku1, tkCross1, tDirection1,
  kDirection1, kumoTenkanSen1, kumoKijunSen1, kumochiku1, kumoShadow1, senkouAB1,
  ADirection1, BDirection1, chikuHorizontal1, chikuVertical1, tenkanCrossover1,
  kijunSenCrossover1, tsCrossover1, kumoCrossover1, senkouCrossover1, score1, 
  distanceBetweenTenkanAndPrice1, 
  distanceBetweenKijunAndPrice1]=request.security(syminfo.tickerid, resolution1, f_MTFIchi()) 

[priceKumo2, priceTenkanSen2, priceKijunSen2, priceChiku2, tkCross2, tDirection2,
  kDirection2, kumoTenkanSen2, kumoKijunSen2, kumochiku2, kumoShadow2, senkouAB2,
  ADirection2, BDirection2, chikuHorizontal2, chikuVertical2, tenkanCrossover2,
  kijunSenCrossover2, tsCrossover2, kumoCrossover2, senkouCrossover2, score2, 
  distanceBetweenTenkanAndPrice2, 
  distanceBetweenKijunAndPrice2]=request.security(syminfo.tickerid, resolution2, f_MTFIchi())  
  
[priceKumo3, priceTenkanSen3, priceKijunSen3, priceChiku3, tkCross3, tDirection3,
  kDirection3, kumoTenkanSen3, kumoKijunSen3, kumochiku3, kumoShadow3, senkouAB3,
  ADirection3, BDirection3, chikuHorizontal3, chikuVertical3, tenkanCrossover3,
  kijunSenCrossover3, tsCrossover3, kumoCrossover3, senkouCrossover3, score3, 
  distanceBetweenTenkanAndPrice3, 
  distanceBetweenKijunAndPrice3]=request.security(syminfo.tickerid, resolution3, f_MTFIchi()) 
  
[priceKumo4, priceTenkanSen4, priceKijunSen4, priceChiku4, tkCross4, tDirection4,
  kDirection4, kumoTenkanSen4, kumoKijunSen4, kumochiku4, kumoShadow4, senkouAB4,
  ADirection4, BDirection4, chikuHorizontal4, chikuVertical4, tenkanCrossover4,
  kijunSenCrossover4, tsCrossover4, kumoCrossover4, senkouCrossover4, score4, 
  distanceBetweenTenkanAndPrice4, 
  distanceBetweenKijunAndPrice4]=request.security(syminfo.tickerid, resolution4, f_MTFIchi()) 
  
[priceKumo5, priceTenkanSen5, priceKijunSen5, priceChiku5, tkCross5, tDirection5,
  kDirection5, kumoTenkanSen5, kumoKijunSen5, kumochiku5, kumoShadow5, senkouAB5,
  ADirection5, BDirection5, chikuHorizontal5, chikuVertical5, tenkanCrossover5,
  kijunSenCrossover5, tsCrossover5, kumoCrossover5, senkouCrossover5, score5, 
  distanceBetweenTenkanAndPrice5, 
  distanceBetweenKijunAndPrice5]=request.security(syminfo.tickerid, resolution5, f_MTFIchi())  

[priceKumo6, priceTenkanSen6, priceKijunSen6, priceChiku6, tkCross6, tDirection6,
  kDirection6, kumoTenkanSen6, kumoKijunSen6, kumochiku6, kumoShadow6, senkouAB6,
  ADirection6, BDirection6, chikuHorizontal6, chikuVertical6, tenkanCrossover6,
  kijunSenCrossover6, tsCrossover6, kumoCrossover6, senkouCrossover6, score6, 
  distanceBetweenTenkanAndPrice6, 
  distanceBetweenKijunAndPrice6]=request.security(syminfo.tickerid, resolution6, f_MTFIchi())  


f_change_to_symbol(num)=>
    string symbol=na
    if num==0
        symbol:='↔'
    else if num == 1
        symbol := '↑'
    else if num == 2
        symbol := '↓'
    else if num == 11
        symbol := 'Ⓨ'
    else if num == 99 or num == 99.0
        symbol := 'Ⓝ'
    else
        symbol := str.tostring(num,format.percent)
        
f_color(num)=>
    color symbolColor=na
    if num==0
        symbolColor:=color.blue
    else if num == 1
        symbolColor := color.green
    else if num == 2
        symbolColor := color.red
    else if num == 11
        symbolColor := color.blue
    else if num == 99 or num == 99.0
        symbolColor := color.blue
    else
        if num<=0.0
            symbolColor := color.green
        else
            symbolColor := color.red
            
f_set_the_table(tableName,colNum,priceKumo, priceTenkanSen, priceKijunSen, priceChiku, tkCross, tDirection, 
     kDirection, kumoTenkanSen, kumoKijunSen, kumochiku, kumoShadow, senkouAB, 
     ADirection, BDirection, chikuHorizontal, chikuVertical, tenkanCrossover, 
     kijunSenCrossover, tsCrossover, kumoCrossover, senkouCrossover, score,
     distanceBetweenTenkanAndPrice, distanceBetweenKijunAndPrice)=>
    table.cell(tableName,colNum,2,f_change_to_symbol(priceKumo) ,text_halign=text.align_right,text_color=f_color(priceKumo))
    table.cell(tableName,colNum,3,f_change_to_symbol(priceTenkanSen) ,text_halign=text.align_right,text_color=f_color(priceTenkanSen))
    table.cell(tableName,colNum,4,f_change_to_symbol(priceKijunSen) ,text_halign=text.align_right,text_color=f_color(priceKijunSen))
    table.cell(tableName,colNum,5,f_change_to_symbol(priceChiku),text_halign=text.align_right,text_color=f_color(priceChiku))
    table.cell(tableName,colNum,6,f_change_to_symbol(tkCross),text_halign=text.align_right,text_color=f_color(tkCross))
    table.cell(tableName,colNum,8,f_change_to_symbol(tDirection),text_halign=text.align_right,text_color=f_color(tDirection))
    table.cell(tableName,colNum,9,f_change_to_symbol(kDirection),text_halign=text.align_right,text_color=f_color(kDirection))
    table.cell(tableName,colNum,10,f_change_to_symbol(ADirection),text_halign=text.align_right,text_color=f_color(ADirection))
    table.cell(tableName,colNum,11,f_change_to_symbol(BDirection),text_halign=text.align_right,text_color=f_color(BDirection))
    table.cell(tableName,colNum,13,f_change_to_symbol(kumoTenkanSen),text_halign=text.align_right,text_color=f_color(kumoTenkanSen))
    table.cell(tableName,colNum,14,f_change_to_symbol(kumoKijunSen),text_halign=text.align_right,text_color=f_color(kumoKijunSen))
    table.cell(tableName,colNum,15,f_change_to_symbol(kumochiku),text_halign=text.align_right,text_color=f_color(kumochiku))
    table.cell(tableName,colNum,16,f_change_to_symbol(kumoShadow),text_halign=text.align_right,text_color=f_color(kumoShadow))
    table.cell(tableName,colNum,17,f_change_to_symbol(senkouAB),text_halign=text.align_right,text_color=f_color(senkouAB))
    table.cell(tableName,colNum,19,f_change_to_symbol(chikuHorizontal),text_halign=text.align_right,text_color=f_color(chikuHorizontal))
    table.cell(tableName,colNum,20,f_change_to_symbol(chikuVertical),text_halign=text.align_right,text_color=f_color(chikuVertical))
    table.cell(tableName,colNum,22,str.tostring(tenkanCrossover),text_halign=text.align_right,text_color=color.blue)
    table.cell(tableName,colNum,23,str.tostring(kijunSenCrossover),text_halign=text.align_right,text_color=color.blue)
    table.cell(tableName,colNum,24,str.tostring(kumoCrossover),text_halign=text.align_right,text_color=color.blue)
    table.cell(tableName,colNum,25,str.tostring(tsCrossover),text_halign=text.align_right,text_color=color.blue)
    table.cell(tableName,colNum,26,str.tostring(senkouCrossover),text_halign=text.align_right,text_color=color.blue)
    table.cell(tableName,colNum,27,str.tostring(score),text_halign=text.align_right,text_color=score>=0?color.green:color.red)
    table.cell(tableName,colNum,29,str.tostring(distanceBetweenTenkanAndPrice),text_halign=text.align_right,text_color=color.blue)
    table.cell(tableName,colNum,30,str.tostring(distanceBetweenKijunAndPrice),text_halign=text.align_right,text_color=color.blue)
    
if barstate.islast
    headerColor = color.new(color.orange, TRANSP)
    subHeaderColor = color.new(color.orange, SUBTRANSP)
    table.cell(ichimokuTable,0,0,text=useShortNotation?'':'MTF Ichimoku', bgcolor = headerColor)
    table.cell(ichimokuTable,1,0,resolution1, bgcolor = headerColor)
    table.cell(ichimokuTable,2,0,resolution2, bgcolor = headerColor)
    table.cell(ichimokuTable,3,0,resolution3, bgcolor = headerColor)
    table.cell(ichimokuTable,4,0,resolution4, bgcolor = headerColor)
    table.cell(ichimokuTable,5,0,resolution5, bgcolor = headerColor)
    table.cell(ichimokuTable,6,0,resolution6, bgcolor = headerColor)
    if not useShortNotation
        table.cell(ichimokuTable,0,1,text='Current Price(P) and Ichimoku', bgcolor = subHeaderColor, tooltip = 
         'Here we are analyzing the current price and Ichimoku indicators. 
          The position of price with respect to Ichimoku indicators states the market condition clearly.')
        table.merge_cells(ichimokuTable, 0, 1, 6, 1)
    table.cell(ichimokuTable,0,2,text=useShortNotation?'P-C':'Kumo(C)',text_halign=text.align_right, 
     tooltip = 'Price(P) and Kumo(C): P > C = Bullish (↑). P < C = Bearish(↓). P <> C = consolidation or no trend(↔). Score: ±2 ')
    table.cell(ichimokuTable,0,3,text=useShortNotation?'P-T':'Tenkan Sen(T)',text_halign=text.align_right,
     tooltip = 'Price(P) and Tenkan Sen(T): P >= T = Bullish (↑). P < T = Bearish(↓). Score: ±0.5')
    table.cell(ichimokuTable,0,4,text=useShortNotation?'P-K':'Kijun Sen(K)',text_halign=text.align_right, 
     tooltip = 'Price(P) and Kijun Sen(K): P >= K = Bullish (↑). P < T = Bearish(↓). Score: ±0.5')
    table.cell(ichimokuTable,0,5,text=useShortNotation?'P-L':'Chikou(L)',text_halign=text.align_right, 
     tooltip = 'Price(26 bars ago) and Chiku(L):  L >= P(26) = Bullish (↑). L < P(26) = Bearish(↓). Score: ±0.5')
    table.cell(ichimokuTable,0,6,text=useShortNotation?'T-K':'Tenkan Sen(T) Vs. Kijun Sen(K)', bgcolor = useShortNotation?color.yellow:subHeaderColor, 
     tooltip = 'Tenkan Sen(T) and Kijun Sen(K): T >= K = Bullish (↑). T < K = Bearish(↓). Score: ±2')
    if not useShortNotation
        table.cell(ichimokuTable,0,7,text='Direction(D) of Ichimoku Indicators',bgcolor = subHeaderColor, 
         tooltip ='The direction of Ichimoku indicators helps us to understand the trend and its direction.')
        table.merge_cells(ichimokuTable, 0, 7, 6, 7)
    table.cell(ichimokuTable,0,8,text=useShortNotation?'D-T':'Tenkan Sen(T)',text_halign=text.align_right, 
     tooltip = "Tenkan Sen's(T) direction: Upward slope = Bullish (↑). Downward slope = Bearish(↓). Flat=consolidation or no trend(↔). Score: ±0.5")
    table.cell(ichimokuTable,0,9,text=useShortNotation?'D-K':'Kijun Sen(K)',text_halign=text.align_right, 
     tooltip = "Kijun Sen's(K) direction: Upward slope = Bullish (↑). Downward slope = Bearish(↓). Flat=consolidation or no trend(↔). Score: ±0.5")
    table.cell(ichimokuTable,0,10,text=useShortNotation?'D-A':'Senkou A(A)',text_halign=text.align_right, 
     tooltip = "Senkou A(A)  direction: Upward slope = Bullish (↑). Downward slope = Bearish(↓). Flat=consolidation or no trend(↔). Score: ±0.5")
    table.cell(ichimokuTable,0,11,text=useShortNotation?'D-B':'Senkou B(B)',text_halign=text.align_right, 
     tooltip = "Senkou B(A)  direction: Upward slope = Bullish (↑). Downward slope = Bearish(↓). Flat=consolidation or no trend(↔). Score: ±0.5")
    if not useShortNotation
        table.cell(ichimokuTable,0,12,text='Kumo(C) Analysis',bgcolor = subHeaderColor, 
         tooltip = 'Kumo or Cloud is very important in the Ichimoku system. Analyzing its relation with other 
         indicators is important to detect the overall market condition.')
        table.merge_cells(ichimokuTable, 0,12 , 6, 12)
    table.cell(ichimokuTable,0,13,text=useShortNotation?'C-T':'Tenkan Sen(T)',text_halign=text.align_right, 
     tooltip = "Kumo(C) and Tenkan Sen(T): T >= C = Bullish (↑). T < C = Bearish(↓). T <> C = consolidation or no trend(↔). Score: ±0.5" )
    table.cell(ichimokuTable,0,14,text=useShortNotation?'C-K':'Kijun Sen(K)',text_halign=text.align_right, 
     tooltip = 'Kumo(C) and Kijun Sen(K): K >= C = Bullish (↑). K < C = Bearish(↓). K <> C = consolidation or no trend(↔). Score: ±0.5')
    table.cell(ichimokuTable,0,15,text=useShortNotation?'C-L':'Chikou(L)',text_halign=text.align_right, 
     tooltip = 'Kumo(C) and Chiku(L): L >= C = Bullish (↑). L < C = Bearish(↓). L <> C = consolidation or no trend(↔). Score: ±0.5')
    table.cell(ichimokuTable,0,16,text=useShortNotation?'CS':'Shadow(S)',text_halign=text.align_right, 
     tooltip = 'Kumo(C) Shadow: If Kumo shadow is present behind the price, trend strength will be weakened. Score: ±0.5')
    table.cell(ichimokuTable,0,17,text=useShortNotation?'CF':'Future(F)',text_halign=text.align_right, 
     tooltip = 'Kumo(C) Future (Senkou A(A) and Senkou B(B)):  A >= B = Bullish (↑). A < B = Bearish(↓). Score: ±0.5')
    if not useShortNotation
        table.cell(ichimokuTable,0,18,text='Chikou(L) Analysis',bgcolor = subHeaderColor, 
         tooltip = 'Vertical and Horizontal Chiku analysis will tell us about the possible consolidation of the price.' )
        table.merge_cells(ichimokuTable, 0, 18, 6, 18)
    table.cell(ichimokuTable,0,19,text=useShortNotation?'LH':'Horizontal(H)',text_halign=text.align_right, 
     tooltip = 'Chiku Vertical: if the price consolidates for the next 5 bars(You can change this option) 
     will it run into the price. Please remember we are placing the current price 26 bars ago and we are 
     interested to see the current price in open space for a clear trend. Score: ±0.5')
    table.cell(ichimokuTable,0,20,text=useShortNotation?'LV':'Vertical(V)',text_halign=text.align_right, 
     tooltip = 'Chikou Horizontal: If Chiku is in open space (Not running into the price), 
     we want to review Chiku vertically i.e how much percentage of fall or rise of 
     the current price can cause Chiku to run into the price. ')
    if not useShortNotation
        table.cell(ichimokuTable,0,21,text='Ichimoku Signal Analysis',bgcolor = subHeaderColor, 
         tooltip = 'Ichimoku signals: We know, that the crossover of Ichimoku indicators provides 
          important signals. In this section, you can see all the crossover  i.e when they happened (Bars ago)')
        table.merge_cells(ichimokuTable, 0, 21, 6, 21)
    table.cell(ichimokuTable,0,22,text=useShortNotation?'PXT':'Price(P) Vs. Tenkan Sen(T)',text_halign=text.align_right,
     tooltip = 'Price(P) and Tenkan Sen(T) crossover')
    table.cell(ichimokuTable,0,23,text=useShortNotation?'PXK':'Price(P) Vs. Kijun Sen(K)',text_halign=text.align_right,
     tooltip = 'Price(P) and Kijun Sen(K) crossover')
    table.cell(ichimokuTable,0,24,text=useShortNotation?'PXC':'Price(P) Vs. Kumo(C)',text_halign=text.align_right,
     tooltip = 'Price(P) and Kumo(C) crossover')
    table.cell(ichimokuTable,0,25,text=useShortNotation?'TXK':'Tenkan Sen(T) Vs. Kijun Sen(K)',text_halign=text.align_right,
     tooltip = 'Tenkan Sen(T) and Kijun Sen(K) crossover')
    table.cell(ichimokuTable,0,26,text=useShortNotation?'AXB':'Senkou A(A) Vs. Senkou B(B)',text_halign=text.align_right,
     tooltip = 'Senkou A(A) and Senkou B(B) Crossover')
    table.cell(ichimokuTable,0,27,text=useShortNotation?'S':'Score',text_halign=text.align_right,bgcolor = useShortNotation?color.yellow:subHeaderColor,
     tooltip = 'Trend Score: maximum trend score is ±10.5')
    if not useShortNotation
        table.cell(ichimokuTable,0,28,text='Current Price Distance',bgcolor = subHeaderColor, 
         tooltip = 'Distance between price and Tenkan Sen and Kijun Sen: We know, the price come 
         back to Tenkan/Kijun if it goes far away from Tenkan/Kijun. So it is important to note the distance between Tenkan and Price.')
        table.merge_cells(ichimokuTable, 0, 28, 6, 28)
    table.cell(ichimokuTable,0,29,text=useShortNotation?'P-T':'Price(P) and Tenkan Sen(T)'+pip(),text_halign=text.align_right,
     tooltip = 'Distance between Price(P) and Tenkan Sen(T)')
    table.cell(ichimokuTable,0,30,text=useShortNotation?'P-K':'Price(P) and Kijun Sen(K)'+pip(),text_halign=text.align_right,
     tooltip = 'Distance between Price(P) and Kijun Sen(K)')
    
    f_set_the_table(ichimokuTable,1,priceKumo1, priceTenkanSen1, priceKijunSen1, priceChiku1, tkCross1, tDirection1,
     kDirection1, kumoTenkanSen1, kumoKijunSen1, kumochiku1, kumoShadow1, senkouAB1,
     ADirection1, BDirection1, chikuHorizontal1, chikuVertical1, tenkanCrossover1,
     kijunSenCrossover1, tsCrossover1, kumoCrossover1, senkouCrossover1, score1, 
     distanceBetweenTenkanAndPrice1, 
     distanceBetweenKijunAndPrice1)
     
    f_set_the_table(ichimokuTable,2,priceKumo2, priceTenkanSen2, priceKijunSen2, priceChiku2, tkCross2, tDirection2,
     kDirection2, kumoTenkanSen2, kumoKijunSen2, kumochiku2, kumoShadow2, senkouAB2,
     ADirection2, BDirection2, chikuHorizontal2, chikuVertical2, tenkanCrossover2,
     kijunSenCrossover2, tsCrossover2, kumoCrossover2, senkouCrossover2, score2, 
     distanceBetweenTenkanAndPrice2, 
     distanceBetweenKijunAndPrice2)
    
    
    f_set_the_table(ichimokuTable,3,priceKumo3, priceTenkanSen3, priceKijunSen3, priceChiku3, tkCross3, tDirection3,
     kDirection3, kumoTenkanSen3, kumoKijunSen3, kumochiku3, kumoShadow3, senkouAB3,
     ADirection3, BDirection3, chikuHorizontal3, chikuVertical3, tenkanCrossover3,
     kijunSenCrossover3, tsCrossover3, kumoCrossover3, senkouCrossover3, score3, 
     distanceBetweenTenkanAndPrice3, 
     distanceBetweenKijunAndPrice3)
    
    f_set_the_table(ichimokuTable,4,priceKumo4, priceTenkanSen4, priceKijunSen4, priceChiku4, tkCross4, tDirection4,
     kDirection4, kumoTenkanSen4, kumoKijunSen4, kumochiku4, kumoShadow4, senkouAB4,
     ADirection4, BDirection4, chikuHorizontal4, chikuVertical4, tenkanCrossover4,
     kijunSenCrossover4, tsCrossover4, kumoCrossover4, senkouCrossover4, score4, 
     distanceBetweenTenkanAndPrice4, 
     distanceBetweenKijunAndPrice4)
    
    f_set_the_table(ichimokuTable,5,priceKumo5, priceTenkanSen5, priceKijunSen5, priceChiku5, tkCross5, tDirection5,
     kDirection5, kumoTenkanSen5, kumoKijunSen5, kumochiku5, kumoShadow5, senkouAB5,
     ADirection5, BDirection5, chikuHorizontal5, chikuVertical5, tenkanCrossover5,
     kijunSenCrossover5, tsCrossover5, kumoCrossover5, senkouCrossover5, score5, 
     distanceBetweenTenkanAndPrice5, 
     distanceBetweenKijunAndPrice5)
    
    f_set_the_table(ichimokuTable,6,priceKumo6, priceTenkanSen6, priceKijunSen6, priceChiku6, tkCross6, tDirection6,
     kDirection6, kumoTenkanSen6, kumoKijunSen6, kumochiku6, kumoShadow6, senkouAB6,
     ADirection6, BDirection6, chikuHorizontal6, chikuVertical6, tenkanCrossover6,
     kijunSenCrossover6, tsCrossover6, kumoCrossover6, senkouCrossover6, score6, 
     distanceBetweenTenkanAndPrice6, 
     distanceBetweenKijunAndPrice6)
    
