Verisimilitude

Coloured Ichimoku Cloud 7,22,44,22

Updated 9th March 2015
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
//Created By User George Stewart
//Last Update 01/03/2015
//new Updates include Cloud Color Change based on Trend.based on Trend
//Added ability to turn on/off Tenkan-Sen (7 Period), Kinjun-Sen (22 Period), Chinkou Span (Lagging Line), and "Cloud"
//Correct Plot Names for Alerts
study(title="Coloured Ichimoku Cloud 7,22,44,22", shorttitle="Coloured Ichimoku Cloud", overlay=true)
turningPeriods = input(7, minval=1, title="Tenkan-Sen")
standardPeriods = input(22, minval=1, title="Kinjun-Sen")
leadingSpan2Periods = input(44, minval=1, title="Senkou Span B")
displacement = input(22, minval=1, title="-ChinkouSpan/+SenkouSpan A")
sts = input(true, title="Show Tenkan-Sen (7 Period)?")
sks = input(true, title="Show Kinjun-Sen (22 Period)?")
sll = input(true, title="Show Chinkou Span (Lagging Line)?")
sc = input(true, title="Show Cloud?")
cr1 = input(false, title="Show Crosses up/down Tenkan-Sen (7 Period) and Kinjun-Sen (22 Period?")

//Definitions for Tenkan-Sen (7 Period), Kinjun-Sen (22 Period), Chinkou Span (Lagging Line)
donchian(len) => avg(lowest(len), highest(len))
turning = donchian(turningPeriods)
standard = donchian(standardPeriods)
leadingSpan1 = avg(turning, standard)
leadingSpan2 = donchian(leadingSpan2Periods)

//Crosses up/down Tenkan-Sen (7 Period) and Kinjun-Sen (22 Period)
crossUpTenkanKinjun = turning[1] < standard[1] and turning > standard ? 1 : 0
crossDnTenkanKinjun = turning[1] > standard[1] and turning < standard ? 1 : 0
cupA = crossUpTenkanKinjun == 1 ? crossUpTenkanKinjun : 0
cdnB = crossDnTenkanKinjun == 1 ? crossDnTenkanKinjun : 0

//First Definition for Ability to Color Cloud based on Trend.
leadingSpan1Above = leadingSpan1 >= leadingSpan2 ? 1 : na
leadingSpan2Below = leadingSpan1 <= leadingSpan2 ? 1 : na
//Next 4 lines are code used as plots in order to Color Cloud based on Trend
span1plotU = leadingSpan1Above ? leadingSpan1 : na
span2plotU = leadingSpan1Above ? leadingSpan2 : na

span1plotD = leadingSpan2Below ? leadingSpan1 : na
span2plotD = leadingSpan2Below ? leadingSpan2 : na

col = leadingSpan1 >= leadingSpan2 ? aqua : orange

//plots for 3 lines other than cloud.
plot(sts and turning ? turning : na, title = 'Tenkan-Sen (7 Period)', linewidth=2, color=red)
plot(sks and standard ? standard : na, title = 'Kinjun-Sen (22 Period)', linewidth=2, color=navy)
plot(sll and close ? close : na, title='Chinkou Span (Lagging Line)', linewidth=2, offset = -displacement, color=yellow)
//Cloud Lines Plot Statements - ***Regular Lines to Fill in Break in Gap
plot(sc and leadingSpan1 ? leadingSpan1 : na, title = 'Senkou Span A (22 Period) Cloud', style=line, linewidth=1, offset = displacement, color=col)
plot(sc and leadingSpan2 ? leadingSpan2 : na, title = 'Senkou Span B (44 Period) Cloud', style=line, linewidth=1, offset = displacement, color=col)
//Cloud Lines Plot Statements - ***linebr to create rules for change in Shading
p1 = plot(sc and span1plotU ? span1plotU  : na, title = 'Senkou Span A (22 Period) Above Span B Cloud', style=linebr, linewidth=1, offset = displacement, color=col)
p2 = plot(sc and span2plotU ? span2plotU  : na, title = 'Senkou Span B (44 Period) Below Span A Cloud', style=linebr, linewidth=1, offset = displacement, color=col)
p3 = plot(sc and span1plotD ? span1plotD  : na, title = 'Senkou Span A (22 Period) Below Span B Cloud', style=linebr, linewidth=1, offset = displacement, color=col)
p4 = plot(sc and span2plotD ? span2plotD  : na, title = 'Senkou Span B (44 Period) Above Span A Cloud', style=linebr, linewidth=1, offset = displacement, color=col)
//Fills that color cloud based on Trend.
fill(p1, p2, color=aqua, transp=70, title='Kumo (Cloud)')
fill(p3, p4, color=orange, transp=70, title='Kumo (Cloud)')