dashed

Ichimoku Cloud (signals)

462 0 32

Indicate Ichimoku signals directly on the chart.

-----

Signals from: http://www.ichimokutrader.com/signals.html

Shorthand notations:

- TS             Cross = Tenkan Sen (turning line) / Kijun Sen (standard line) Cross
- PS Cross = Price and Kijun Sen (standard line) Cross

----

Caveats:

- I couldn't figure out how to make strings configurable, so you'll need to change them in the script itself to fit to your preferences.
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2
study(title="Ichimoku Cloud (signals)", shorttitle="Ichimoku (signals)", overlay=true)

conversionPeriods = input(9, minval=1, title="Conversion Line Periods"),
basePeriods = input(26, minval=1, title="Base Line Periods")
laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Periods"),
displacement = input(26, minval=1, title="Displacement")

donchian(len) => avg(lowest(len), highest(len))

conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)

// i.e. Senkou Span A
leadLine1 = offset(avg(conversionLine, baseLine), displacement)
// i.e. Senkou Span B
leadLine2 = offset(donchian(laggingSpan2Periods), displacement)


// i.e. Tenkan Sen (blue)
plot(conversionLine, color=#0496ff, title="Turning/Conversion Line", linewidth=3) 
// i.e. Kijun Sen (red)
plot(baseLine, color=#991515, title="Standard/Base Line", linewidth=3)
// i.g. Chikou Span (green)
plot(close, offset = -displacement, color=#459915, title="Lagging Span", linewidth=3)

plot(conversionLine, color=#0496ff, title="Conversion Line")
plot(baseLine, color=#991515, title="Base Line")

real_leadLine1 = avg(conversionLine, baseLine)
real_leadLine2 = donchian(laggingSpan2Periods)

// i.e. Senkou Span A
p1 = plot(real_leadLine1, offset = displacement, color=green, title="Lead 1")
// i.e. Senkou Span B
p2 = plot(real_leadLine2, offset = displacement, color=red, title="Lead 2")

// i.e. Kumo cloud colouring
fill(p1, p2, color = real_leadLine1 > real_leadLine2 ? green : red)

// ichimoku cloud signals
// source: http://www.ichimokutrader.com/signals.html

// Tenkan Sen (turning line) / Kijun Sen (standard line) Cross

//tk_cross_bull = (conversionLine[1] < baseLine[1] and conversionLine >= baseLine)
tk_cross_bull = crossover(conversionLine, baseLine)
//tk_cross_bear = (conversionLine[1] > baseLine[1] and conversionLine <= baseLine)
tk_cross_bear = crossunder(conversionLine, baseLine)

// weak bullish (below kumo)
tk_cross_below_kumo = (conversionLine < leadLine2 and conversionLine < leadLine1) and (conversionLine[1] < leadLine2[1] and conversionLine[1] < leadLine1[1]) and (baseLine < leadLine2 and baseLine < leadLine1) and (baseLine[1] < leadLine2[1] and baseLine[1] < leadLine1[1]) 

plotshape((tk_cross_bull and tk_cross_below_kumo) ? leadLine1 : na, title="Weak\Bullish\TS Cross", color=green, style=shape.arrowup, location=location.belowbar, text="Weak\nBullish\nCross\nTS\n", textcolor=black)

// neutral bullish (inside kumo)
// NOTE: old
//tk_cross_inside_kumo = ((conversionLine[1] < leadLine2 and conversionLine < leadLine2) and (baseLine[1] < leadLine2 and baseLine < leadLine2) and (conversionLine[1] > leadLine1 and conversionLine > leadLine1) and (baseLine[1] > leadLine1 and baseLine > leadLine1)) or ((conversionLine[1] < leadLine1 and conversionLine < leadLine1) and (baseLine[1] < leadLine1 and baseLine < leadLine1) and (conversionLine[1] > leadLine2 and conversionLine > leadLine2) and (baseLine[1] > leadLine2 and baseLine > leadLine2))

// get true y-coord of the cross
cross_y = (conversionLine[1] * (baseLine - baseLine[1]) - baseLine[1] * (conversionLine - conversionLine[1])) / ((baseLine - baseLine[1]) - (conversionLine - conversionLine[1]))

tk_cross_inside_kumo = (leadLine1[1] < cross_y and cross_y < leadLine2[1] and leadLine1 < cross_y and cross_y < leadLine2) or (leadLine2[1] < cross_y and cross_y < leadLine1[1] and leadLine2 < cross_y and cross_y < leadLine1)

plotshape((tk_cross_bull and tk_cross_inside_kumo) ? leadLine1 : na, title="Neutral\Bullish\TS Cross", color=green, style=shape.arrowup, location=location.belowbar, text="Neutral\nBullish\nCross\nTS\n", textcolor=black)

// strong bullish (above kumo)
tk_cross_above_kumo = (conversionLine > leadLine2 and conversionLine > leadLine1) and (conversionLine[1] > leadLine2[1] and conversionLine[1] > leadLine1[1]) and (baseLine > leadLine2 and baseLine > leadLine1) and (baseLine[1] > leadLine2[1] and baseLine[1] > leadLine1[1])

plotshape((tk_cross_bull and tk_cross_above_kumo) ? leadLine1 : na, title="Strong\Bullish\TS Cross", color=green, style=shape.arrowup, location=location.belowbar, text="Strong\nBullish\nCross\nTS\n", textcolor=black)

// strong bearish (below kumo)
plotshape((tk_cross_bear and tk_cross_below_kumo) ? leadLine1 : na, title="Strong\Bearish\TS Cross", color=red, style=shape.arrowdown, location=location.abovebar, text="Strong\nBearish\nCross\nTS\n", textcolor=black)

// neutral bearish (inside kumo)
plotshape((tk_cross_bear and tk_cross_inside_kumo) ? leadLine1 : na, title="Neutral\Bearish\TS Cross", color=red, style=shape.arrowdown, location=location.abovebar, text="Neutral\nBearish\nCross\nTS\n", textcolor=black)

// weak bearish (above kumo)
plotshape((tk_cross_bear and tk_cross_above_kumo) ? leadLine1 : na, title="Weak\Bearish\TS Cross", color=red, style=shape.arrowdown, location=location.abovebar, text="Weak\nBearish\nCross\nTS\n", textcolor=black)


// Price and Kijun Sen (standard line) Cross

//pk_cross_bull = (close[1] < baseLine[1] and close >= baseLine)
//pk_cross_bear = (close[1] > baseLine[1] and close <= baseLine)
pk_cross_bull = crossover(close, baseLine)
pk_cross_bear = crossunder(close, baseLine)

// weak bullish (below kumo)
pk_cross_below_kumo = (close < leadLine2 and close < leadLine1) and (close[1] < leadLine2[1] and close[1] < leadLine1[1]) and (baseLine < leadLine2 and baseLine < leadLine1) and (baseLine[1] < leadLine2[1] and baseLine[1] < leadLine1[1])

plotshape((pk_cross_bull and pk_cross_below_kumo) ? leadLine1 : na, title="Weak\Bullish\PS Cross", color=green, style=shape.arrowup, location=location.belowbar, text="Weak\nBullish\nCross\n\nPS", textcolor=black)

// neutral bullish (inside kumo)
//pk_cross_inside_kumo = ((close[1] < leadLine2 and close < leadLine2) and (baseLine[1] < leadLine2 and baseLine < leadLine2) and (close[1] > leadLine1 and close > leadLine1) and (baseLine[1] > leadLine1 and baseLine > leadLine1)) or ((close[1] < leadLine1 and close < leadLine1) and (baseLine[1] < leadLine1 and baseLine < leadLine1) and (close[1] > leadLine2 and close > leadLine2) and (baseLine[1] > leadLine2 and baseLine > leadLine2))

cross_pk_y = (close[1] * (baseLine - baseLine[1]) - baseLine[1] * (close - close[1])) / ((baseLine - baseLine[1]) - (close - close[1]))

pk_cross_inside_kumo = (leadLine1[1] < cross_pk_y and cross_pk_y < leadLine2[1] and leadLine1 < cross_pk_y and cross_pk_y < leadLine2) or (leadLine2[1] < cross_pk_y and cross_pk_y < leadLine1[1] and leadLine2 < cross_pk_y and cross_pk_y < leadLine1)


plotshape((pk_cross_bull and pk_cross_inside_kumo) ? leadLine1 : na, title="Neutral\Bullish\PS Cross", color=green, style=shape.arrowup, location=location.belowbar, text="Neutral\nBullish\nCross\n\nPS", textcolor=black)

// strong bullish (above kumo)
pk_cross_above_kumo = (close > leadLine2 and close > leadLine1) and (close[1] > leadLine2[1] and close[1] > leadLine1[1]) and (baseLine > leadLine2 and baseLine > leadLine1) and (baseLine[1] > leadLine2[1] and baseLine[1] > leadLine1[1])

plotshape((pk_cross_bull and pk_cross_above_kumo) ? leadLine1 : na, title="Strong\Bullish\PS Cross", color=green, style=shape.arrowup, location=location.belowbar, text="Strong\nBullish\nCross\n\nPS", textcolor=black)

// strong bearish (below kumo)
plotshape((pk_cross_bear and pk_cross_below_kumo) ? leadLine1 : na, title="Strong\Bearish\PS Cross", color=red, style=shape.arrowdown, location=location.abovebar, text="Strong\nBearish\nCross\n\nPS", textcolor=black)

// neutral bearish (inside kumo)
plotshape((pk_cross_bear and pk_cross_inside_kumo) ? leadLine1 : na, title="Neutral\Bearish\PS Cross", color=red, style=shape.arrowdown, location=location.abovebar, text="Neutral\nBearish\nCross\n\nPS", textcolor=black)

// weak bearish (above kumo)
plotshape((pk_cross_bear and pk_cross_above_kumo) ? leadLine1 : na, title="Weak\Bearish\PS Cross", color=red, style=shape.arrowdown, location=location.abovebar, text="Weak\nBearish\nCross\n\nPS", textcolor=black)

// Kumo Breakout

kumo_bull = (crossover(close, leadLine1) and leadLine1 > leadLine2) or (crossover(close, leadLine2) and leadLine2 > leadLine1)
kumo_bear = (crossunder(close, leadLine2) and leadLine1 > leadLine2) or (crossunder(close, leadLine1) and leadLine2 > leadLine1)

plotshape(kumo_bull ? leadLine1 : na, title="Bullish\Kumo\Breakout", color=green, style=shape.arrowup, location=location.abovebar, text="Bullish\nKumo\nBreakout", textcolor=black)

plotshape(kumo_bear ? leadLine1 : na, title="Bearish\Kumo\Breakout", color=red, style=shape.arrowdown, location=location.belowbar, text="Bearish\nKumo\nBreakout", textcolor=black)

// Senkou Span Cross 
// The Senkou Span Cross signal occurs when the Senkou Span A (1st leading line) crosses the Senkou Span B (2nd leading line).

lead_line_cross_bull = crossover(leadLine1, leadLine2)
lead_line_cross_bear = crossunder(leadLine1, leadLine2)
price_below_kumo = (close < leadLine2 and close < leadLine1)
price_above_kumo = (close > leadLine2 and close > leadLine1)
price_inside_kumo = (leadLine2 < close and close < leadLine1) and (leadLine1 < close and close < leadLine2)

// weak bullish (price below kumo)
plotshape((lead_line_cross_bull and price_below_kumo) ? leadLine1 : na, title="Weak\Bullish\Span Cross", color=green, style=shape.arrowup, location=location.absolute, text="Weak\nBullish\nCross\nSpan", textcolor=black)

// neutral bullish (price inside kumo)
plotshape((lead_line_cross_bull and price_inside_kumo) ? leadLine1 : na, title="Neutral\Bullish\Span Cross", color=green, style=shape.arrowup, location=location.absolute, text="Neutral\nBullish\nCross\nSpan", textcolor=black)

// strong bullish (price above kumo)
plotshape((lead_line_cross_bull and price_above_kumo) ? leadLine1 : na, title="Strong\Bullish\Span Cross", color=green, style=shape.arrowup, location=location.absolute, text="Strong\nBullish\nCross\nSpan", textcolor=black)

// weak bearish (price above kumo)
plotshape((lead_line_cross_bear and price_above_kumo) ? leadLine1 : na, title="Weak\Bearish\Span Cross", color=red, style=shape.arrowdown, location=location.absolute, text="Weak\nBearish\nCross\nSpan", textcolor=black)

// neutral bearish (price inside kumo)
plotshape((lead_line_cross_bear and price_inside_kumo) ? leadLine1 : na, title="Neutral\Bearish\Span Cross", color=red, style=shape.arrowdown, location=location.absolute, text="Neutral\nBearish\nCross\nSpan", textcolor=black)

// strong bearish (price below kumo)
plotshape((lead_line_cross_bear and price_below_kumo) ? leadLine1 : na, title="Strong\Bearish\Span Cross", color=red, style=shape.arrowdown, location=location.absolute, text="Strong\nBearish\nCross\nSpan", textcolor=black)


// Chikou Span Cross
// The Chikou Span Cross signal occurs when the Chikou Span (Lagging line) rises above or falls below the price.

past_price = offset(close, displacement)
lag_line_bull_cross = crossunder(past_price, close)
//lag_line_bear_cross = cross(past_price, close)
lag_line_bear_cross = crossover(past_price, close)

// past_price = close[displacement]
// lag_line_bull_cross = (close[1] < close[displacement + 1] and close >= close[displacement]) or (close[1] <= close[displacement + 1] and close > close[displacement])
// lag_line_bear_cross = (close[1] > close[displacement + 1] and close <= close[displacement]) or (close[1] >= close[displacement + 1] and close < close[displacement])


past_price_below_kumo = (past_price < leadLine2 and past_price < leadLine1)
past_price_above_kumo = (past_price > leadLine2 and past_price > leadLine1)
past_price_inside_kumo = (leadLine2 < past_price and past_price < leadLine1) and (leadLine1 < past_price and past_price < leadLine2)


// weak bullish (price below kumo)
plotshape((lag_line_bull_cross and past_price_below_kumo) ? close : na, title="Weak\Bullish\Lag Cross", color=green, style=shape.arrowup, location=location.bottom, text="Weak\nBullish\nCross\nLag", textcolor=black, offset=-displacement)

// neutral bullish (price inside kumo)
plotshape((lag_line_bull_cross and past_price_inside_kumo) ? close : na, title="Neutral\Bullish\Lag Cross", color=green, style=shape.arrowup, location=location.bottom, text="Neutral\nBullish\nCross\nLag", textcolor=black, offset=-displacement)

// strong bullish (price above kumo)
plotshape((lag_line_bull_cross and past_price_above_kumo) ? close : na, title="Strong\Bullish\Lag Cross", color=green, style=shape.arrowup, location=location.bottom, text="Strong\nBullish\nCross\nLag", textcolor=black, offset=-displacement)

// weak bearish (price above kumo)
plotshape((lag_line_bear_cross and past_price_above_kumo) ? close : na, title="Weak\Bearish\Lag Cross", color=red, style=shape.arrowdown, location=location.bottom, text="Weak\nBearish\nCross\nLag", textcolor=black, offset=-displacement)

// neutral bearish (price inside kumo)
plotshape((lag_line_bear_cross and past_price_inside_kumo) ? close : na, title="Neutral\Bearish\Lag Cross", color=red, style=shape.arrowdown, location=location.bottom, text="Neutral\nBearish\nCross\nLag", textcolor=black, offset=-displacement)

// strong bearish (price below kumo)
plotshape((lag_line_bear_cross and past_price_below_kumo) ? close : na, title="Strong\Bearish\Lag Cross", color=red, style=shape.arrowdown, location=location.bottom, text="Strong\nBearish\nCross\nLag", textcolor=black, offset=-displacement)

// debug
//plotshape((should_plot_tk_nb_inside_kumo) ? leadLine1 : na, color=black, style=shape.arrowup, location=location.belowbar, size=size.huge)



Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out