Indicator · Pine Script v5 · On the chart

Ichimoku Kumo

by hayashi19· code credited to HayashiHitsuji

This indicator draws an Ichimoku Kinko Hyo set on the price chart, with conversion and base lines, leading spans A and B, a lagging line and a cloud filled lime or red depending on which span is higher.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code114
Settings9inputs
LicenceNone statedfile: MPL-2.0
Last update4 years ago10 Jan 2022

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

114 lines of Pine Script v5 from indicator/INDICATOR Ichimoku Kinko Hyo Indicator (林19).pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

INDICATOR Ichimoku Kinko Hyo Indicator (林19).pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HayashiHitsuji

//@version=5
indicator('INDICATOR: Ichimoku Kinko Hyo Indicator (林19)', shorttitle = 'Ichimoku Kumo (林19)', overlay = true)

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// INDICATOR INPUT =============================================================
table_view      = input.bool(false, 'Show info table ?')

con_per         = input.int(9, 'Conversion Line Length')
base_per        = input.int(26, 'Base Line Length')
lagspan_per     = input.int(52, 'Leading Span Length')

kumo_displace   = input.bool(false, 'Displace the kumo ?')
displacement    = input.int(26, 'Displacement')

simple_view     = input.bool(false, 'Simple view ?')
signal_view     = input.bool(false, 'Show signal ?')
signal_type     = input.session("Simple", "Signal Type", options = ["Traditional", "Simple", "Kumo Cross"])
// ========================================================================== //

// INDICATOR CALCULATION =======================================================
// ichimoku
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))

con_line        = donchian(con_per)
base_line       = donchian(base_per)

lead_line_1     = math.avg(con_line, base_line)
lead_line_2     = donchian(lagspan_per)
lead_1_displace = kumo_displace ? lead_line_1[displacement - 1] : lead_line_1
lead_2_displace = kumo_displace ? lead_line_2[displacement - 1] : lead_line_2

lag_span        = ta.sma(close, 14)
// ========================================================================== //

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// INDICATOR COLOR =============================================================
kumo_color      = lead_line_1 >= lead_line_2 ? color.lime : color.red
// ========================================================================== //

// PLOT INDICATOR ==============================================================
// ichimoku
plot(simple_view ? na : con_line, color = color.new(color.aqua, 0), title = 'Conversion Line')
plot(simple_view ? na : base_line, color = color.new(color.fuchsia, 0), title = 'Base Line')

plot(simple_view ? na : lag_span, color = color.new(color.white, 0), title = 'Lagging Span', offset = -displacement + 1)

p1 = plot(lead_line_1, color = color.new(color.lime, 0), title = 'Leading Span A', offset = kumo_displace ? displacement - 1 : 0)
p2 = plot(lead_line_2, color = color.new(color.red, 0), title = 'Leading Span B', offset = kumo_displace ? displacement - 1 : 0)

fill(p1, p2, color = color.new(kumo_color, 80))
// ========================================================================== //

// PLOT CANDLE =================================================================
// Color condition
candle_dolor = close >= lead_1_displace and close >= lead_2_displace ? color.green : close <= lead_1_displace and close <= lead_2_displace ? color.red : color.white

// Plot
plotcandle(open, high, low, close, color = candle_dolor, wickcolor = candle_dolor, bordercolor = candle_dolor)
// ========================================================================== //

// PLOT SIGNAL =================================================================
long_simp   = (ta.crossover(lead_1_displace, lead_2_displace) and close >= lead_1_displace and close >= lead_2_displace) or
                 (ta.crossover(close, lead_1_displace) and lead_1_displace >= lead_2_displace) or 
                     (ta.crossover(close, lead_2_displace) and lead_1_displace <= lead_2_displace) 

short_simp  = (ta.crossunder(lead_1_displace, lead_2_displace) and close <= lead_1_displace and close <= lead_2_displace) or
                 (ta.crossunder(close, lead_1_displace) and lead_1_displace <= lead_2_displace) or
                     (ta.crossover(close, lead_1_displace) and lead_1_displace >= lead_2_displace)
                 
long_trad   = ((close >= lead_1_displace and close >= lead_2_displace) and ta.crossover(con_line, base_line)) or
                 (ta.crossover(lead_1_displace, lead_2_displace) and con_line >= base_line and close >= lead_1_displace)

short_trad  = ((close <= lead_1_displace and close <= lead_2_displace) and ta.crossunder(con_line, base_line)) or
                 (ta.crossunder(lead_1_displace, lead_2_displace) and con_line <= base_line and close <= lead_1_displace)
                 
long_kumo   = ta.crossover(lead_1_displace, lead_2_displace)

short_kumo  = ta.crossunder(lead_1_displace, lead_2_displace)

long        = signal_type == 'Simple' ? long_simp : 
                 signal_type == 'Traditional' ? long_trad : long_kumo

short       = signal_type == 'Simple' ? short_simp : 
                 signal_type == 'Traditional' ? short_trad : short_kumo

plotshape(signal_view ? long : na, style = shape.labelup, location = location.belowbar, color = color.new(color.green, 0), text = 'Long', textcolor = color.new(color.white, 0))
plotshape(signal_view ? short : na, style = shape.labeldown, location = location.abovebar, color = color.new(color.red, 0), text = 'Short', textcolor = color.new(color.white, 0))
// ========================================================================== //

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// TABLE =======================================================================
// table condition
kumo_cond       = lead_line_1 >= lead_line_2 ? 'Bullish' : 'Bearish'
short_momentum  = close >= con_line ? 'Bullish' : 'Bearish'
mid_momentum    = close >= base_line ? 'Bullish' : 'Bearish'
line_cond       = con_line >= base_line ? 'Bullish' : 'Bearish'
price_act       = close >= lead_1_displace and close >= lead_2_displace ? 'Bullish' : close <= lead_1_displace and close <= lead_2_displace ? 'Bearish' : 'Range'

// table
info_table      = table.new(position = position.middle_right, columns = 1, rows = 5, bgcolor = color.new(color.black, 60), border_width = 1)

if table_view
    table.cell(table_id = info_table, column = 0, row = 0, text = 'Long term ' + kumo_cond, text_color = color.white, text_halign = text.align_left)
    table.cell(table_id = info_table, column = 0, row = 1, text = 'Mid momentum ' + short_momentum, text_color = color.white, text_halign = text.align_left)
    table.cell(table_id = info_table, column = 0, row = 2, text = 'Short momentum ' + mid_momentum, text_color = color.white, text_halign = text.align_left)
    table.cell(table_id = info_table, column = 0, row = 3, text = 'Momentum ' + line_cond, text_color = color.white, text_halign = text.align_left)
    table.cell(table_id = info_table, column = 0, row = 4, text = 'Price trend ' + price_act, text_color = color.white, text_halign = text.align_left)
// ========================================================================== //

Overview

Candles are coloured green, red or white by their position relative to the cloud. Optional features include cloud displacement, a simple view, an info table and signals of three types: traditional, simple or cloud cross. Line lengths are adjustable.

Details

Published by

hayashi19 on GitHub

Code credit

HayashiHitsuji, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Show info table ?boolfalsetable_view
Conversion Line Lengthint9con_per
Base Line Lengthint26base_per
Leading Span Lengthint52lagspan_per
Displace the kumo ?boolfalsekumo_displace
Displacementint26displacement
Simple view ?boolfalsesimple_view
Show signal ?boolfalsesignal_view
Signal TypesessionSimplesignal_type
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

575 stars

This indicator detects equal highs and lows by comparing prices within user-defined left and right bars using a tolerance percentage. It plots horizontal lines on the price chart for equal highs in one color and lows in another. A screener allows input of mult

Indicator v5 Support & resistanceTrend
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows with Screener

Function - Linear Regression

by ricardosantos79
261 stars

This indicator fits a linear regression through stored pivot highs and lows and draws the resulting channel on the price chart. A function returns predicted values, maximum and minimum deviations, and the average absolute deviation. Confirmed two-bar pivots up

Indicator v5 TrendSupport & resistance
Updated 4 years ago · None stated GitHub repository of Function - Linear Regression

AI Trend

by dearvn
257 stars

AI Trend is an indicator that plots pivot points, trend lines, and support and resistance levels directly on the price chart. It marks high and low pivots based on user-defined length, draws trend lines that check for violations at specified points, and identi

Indicator v5 TrendSupport & resistance
Updated 7 weeks ago · None stated GitHub repository of AI Trend

Dynamic Linear Regression

by TradersPost
228 stars

Dynamic Linear Regression calculates and plots linear regression trendlines and standard deviation channels directly on the price chart over a user-selected time period. Traders can configure static channels locked at the end time, dynamic channels that contin

Indicator v6 TrendSupport & resistance
Updated 3 months ago · None stated GitHub repository of Dynamic Linear Regression

Ichimoku Cloud

by harryguiacorn
220 stars

This indicator plots Ichimoku Cloud elements on the price chart, including Tenkan-sen, Kijun-sen, Senkou Span A and B lines with optional Chikou Span. It signals trend changes via Tenkan-sen and Kijun-sen crosses and places arrows at Kijun-sen direction shifts

Indicator v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ichimoku Cloud
219 stars

This indicator identifies local swing highs and swing lows to construct a Zig Zag pattern on the main price chart. It evaluates pivot points based on a customizable number of surrounding left and right bars. Using persistent variables, the script tracks previo

Indicator v4 Support & resistanceTrend Repaints
Updated 5 years ago · None stated GitHub repository of Teaching: Finding Highs and Lows 6

More Trend scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers