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

//@version=5
indicator(title="Ichimoku Cross", shorttitle="IchiCross",precision=1,scale=scale.right,overlay=false)

// Getting inputs
TenkanSenPeriod = input.int(9, minval=1, title="TenkanSen Period")
KijunSenPeriod= input.int(26, minval=1, title="KijunSen Period")

// Plot colors
ColorStrongBullish = #104B26
ColorBullish = #2A7F2A
ColorWeakBullish = #54E554
ColorCross = color.yellow
ColorStrongBearish = #730909
ColorBearish = #D01A06
ColorWeakBearish = #F6968B

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

// Calculation
TenkanSen = donchian(TenkanSenPeriod)
KijunSen = donchian(KijunSenPeriod)

Histogram = 1

color My_color = na

if TenkanSen > KijunSen
    if(close>=TenkanSen)
        My_color := ColorStrongBullish
    else
        if(close<=KijunSen)
            My_color := ColorWeakBullish
        else
            My_color := ColorBullish
else
    if TenkanSen < KijunSen
        if(close<=TenkanSen)
            My_color := ColorStrongBearish
        else
            if(close>=KijunSen)
                My_color := ColorWeakBearish
            else
                My_color := ColorBearish
    else
        My_color := ColorCross

plot(Histogram,"IchiCross",color=My_color,linewidth=5,style=plot.style_histogram,join=true)
