Strategy · Pine Script v5 · On the chart

Ichimoku Cloud — Large Cap

by Jaden300

Ichimoku Cloud — Large Cap is a long-only trend-following strategy designed for large-cap stocks.

View on GitHub

GitHub stars4on the repository
Pine versionv5runs as is
Lines of code142
Settings6inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago31 May 2026

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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

142 lines of Pine Script v5 from strategy/strategy_ichimoku/pine_ichimoku_largecap.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

pine_ichimoku_largecap.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0
// Ichimoku Cloud Strategy — optimized for large-cap tech (long-only)
// Run strategy_ichimoku/tests/test_largecap.py to update default params below.

//@version=5
strategy("Ichimoku Cloud — Large Cap", shorttitle="IchimokuLC",
         overlay=true,
         initial_capital=1500,
         default_qty_type=strategy.percent_of_equity,
         default_qty_value=33,
         commission_type=strategy.commission.percent,
         commission_value=1.5,
         pyramiding=0,
         process_orders_on_close=false)

// ── Inputs ────────────────────────────────────────────────────────────────────
tenkanPeriod  = input.int(9,  "Tenkan Period",   minval=1, group="Ichimoku")
kijunPeriod   = input.int(26, "Kijun Period",    minval=1, group="Ichimoku")
senkouBPeriod = input.int(52, "Senkou B Period", minval=1, group="Ichimoku")

useCloud  = input.bool(true, "Cloud Color Filter",  group="Filters",
             tooltip="Only enter when future cloud is bullish (SpanA > SpanB)")
useChikou = input.bool(true, "Chikou Confirmation", group="Filters",
             tooltip="Only enter when close > close[kijun] bars ago")

slPct = input.float(0.0, "Stop Loss %  (0 = off)", minval=0.0, maxval=30.0, step=0.5, group="Risk")

// ── Ichimoku Calculations ─────────────────────────────────────────────────────
tenkan  = (ta.highest(high, tenkanPeriod)  + ta.lowest(low, tenkanPeriod))  / 2
kijun   = (ta.highest(high, kijunPeriod)   + ta.lowest(low, kijunPeriod))   / 2
senkouA = (tenkan + kijun) / 2
senkouB = (ta.highest(high, senkouBPeriod) + ta.lowest(low, senkouBPeriod)) / 2
chikou  = close

displacement = kijunPeriod
cloudTop    = math.max(senkouA[displacement], senkouB[displacement])
cloudBottom = math.min(senkouA[displacement], senkouB[displacement])

// ── Signal Logic ──────────────────────────────────────────────────────────────
tkCrossUp   = ta.crossover(tenkan,  kijun)
tkCrossDown = ta.crossunder(tenkan, kijun)

cloudOk  = not useCloud  or (senkouA > senkouB)
chikouOk = not useChikou or (chikou > close[displacement])

priceAboveCloud = close > cloudTop
priceBelowCloud = close < cloudBottom

longEntrySignal = tkCrossUp and cloudOk and chikouOk
longExitSignal  = tkCrossDown or priceBelowCloud

// ── Strategy Execution ────────────────────────────────────────────────────────
var float stopLevel = na

if longEntrySignal and strategy.position_size == 0
    strategy.entry("Long", strategy.long)
    stopLevel := slPct > 0 ? close * (1.0 - slPct / 100.0) : na

if longExitSignal and strategy.position_size > 0
    strategy.close("Long", comment="Exit")
    stopLevel := na

if strategy.position_size > 0 and slPct > 0 and not na(stopLevel)
    strategy.exit("SL", from_entry="Long", stop=stopLevel)

if strategy.position_size == 0
    stopLevel := na

// ── Plots ─────────────────────────────────────────────────────────────────────
tkColor = tenkan >= kijun ? color.new(#2962FF, 0) : color.new(#FF6D00, 0)
plot(tenkan, "Tenkan",  color=tkColor, linewidth=2)
plot(kijun,  "Kijun",   color=color.new(#FF6D00, 0), linewidth=2)
plot(chikou, "Chikou",  color=color.new(#9C27B0, 0), offset=-displacement, linewidth=1)

p1 = plot(senkouA, "Senkou A", color=color.new(#00E676, 0), offset=displacement, linewidth=1)
p2 = plot(senkouB, "Senkou B", color=color.new(#FF1744, 0), offset=displacement, linewidth=1)
cloudColor = senkouA >= senkouB ? color.new(#00E676, 85) : color.new(#FF1744, 85)
fill(p1, p2, color=cloudColor, title="Cloud")

plot(strategy.position_size > 0 and slPct > 0 ? stopLevel : na,
     "Stop Loss", color=color.red, style=plot.style_linebr, linewidth=2)

plotshape(longEntrySignal,
          title="Buy",  location=location.belowbar,
          color=color.new(#00E676, 0), style=shape.triangleup, size=size.small, text="BUY")
plotshape(longExitSignal and strategy.position_size > 0,
          title="Sell", location=location.abovebar,
          color=color.new(#FF1744, 0), style=shape.triangledown, size=size.small, text="SELL")

bgcolor(priceAboveCloud ? color.new(#00E676, 96) : na, title="Above Cloud BG")
bgcolor(priceBelowCloud ? color.new(#FF1744, 96) : na, title="Below Cloud BG")

// ── Confidence & Info Table ───────────────────────────────────────────────────
tkBull     = tenkan > kijun                 ? 1 : 0
cldBull    = senkouA > senkouB              ? 1 : 0
chkBull    = chikou > close[displacement]   ? 1 : 0
abvCloud   = close > cloudTop               ? 1 : 0
confidence = (tkBull + cldBull + chkBull + abvCloud) * 25

inPos    = strategy.position_size > 0
confStr  = inPos ? str.tostring(confidence) + "/100" : "--"
confColor = confidence >= 75 ? color.new(#00E676, 0) : confidence >= 50 ? color.new(#FFEB3B, 0) : color.new(#FF1744, 0)

var table tbl = table.new(position.top_right, 2, 7,
                           bgcolor=color.new(#131722, 85),
                           border_color=color.new(#363a45, 100),
                           border_width=1,
                           frame_color=color.new(#363a45, 100),
                           frame_width=1)

if barstate.islast
    table.cell(tbl, 0, 0, "Ichimoku LC",
               text_color=color.white, text_size=size.small,
               bgcolor=color.new(#2962FF, 70))
    table.cell(tbl, 1, 0, "",
               bgcolor=color.new(#2962FF, 70))
    table.cell(tbl, 0, 1, "Tenkan",
               text_color=color.gray, text_size=size.tiny)
    table.cell(tbl, 1, 1, str.tostring(tenkanPeriod),
               text_color=color.white, text_size=size.tiny)
    table.cell(tbl, 0, 2, "Kijun",
               text_color=color.gray, text_size=size.tiny)
    table.cell(tbl, 1, 2, str.tostring(kijunPeriod),
               text_color=color.white, text_size=size.tiny)
    table.cell(tbl, 0, 3, "Senkou B",
               text_color=color.gray, text_size=size.tiny)
    table.cell(tbl, 1, 3, str.tostring(senkouBPeriod),
               text_color=color.white, text_size=size.tiny)
    table.cell(tbl, 0, 4, "SL",
               text_color=color.gray, text_size=size.tiny)
    table.cell(tbl, 1, 4, slPct > 0 ? str.tostring(slPct, "#.##") + "%" : "off",
               text_color=color.white, text_size=size.tiny)
    table.cell(tbl, 0, 5, "Position",
               text_color=color.gray, text_size=size.tiny)
    table.cell(tbl, 1, 5, inPos ? "LONG" : "--",
               text_color=inPos ? color.new(#00E676, 0) : color.gray,
               text_size=size.tiny)
    table.cell(tbl, 0, 6, "Confidence",
               text_color=color.gray, text_size=size.tiny)
    table.cell(tbl, 1, 6, confStr,
               text_color=inPos ? confColor : color.gray,
               text_size=size.tiny)

Overview

Ichimoku Cloud — Large Cap calculates standard Ichimoku components, including Tenkan-sen, Kijun-sen, Senkou Span A, Senkou Span B, and Chikou Span. Trades enter on a bullish Tenkan/Kijun crossover with optional filters for future cloud color and Chikou position relative to price. Exits occur when a bearish Tenkan/Kijun crossover takes place or price falls below the cloud. An optional percentage-based stop loss can be enabled in settings. Plotted directly on the price chart.

Details

Published by

Jaden300 on GitHub

Draws

On the price chart

Markets

Stocks

Timeframes

H4 and above

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingstock-markettradingview-ideas

Settings

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

SettingTypeDefaultVariable
Tenkan Periodint9tenkanPeriod
Kijun Periodint26kijunPeriod
Senkou B Periodint52senkouBPeriod
Cloud Color FilterbooltrueuseCloud
Chikou ConfirmationbooltrueuseChikou
Stop Loss % (0 = off)float0.0slPct
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

This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr

Strategy v6 BreakoutTrend
Updated 2 days ago · AGPL-3.0 GitHub repository of Forven S01509 - Simple Donchian 20/10 Breakout

Omar Edited WF

by Alorse
330 stars

Omar Edited WF is a trading strategy overlay built around Williams Fractals and multiple Exponential Moving Averages. It detects high and low fractal pivot points over configurable lookback periods alongside three adjustable EMA trendlines. Long entries are ma

Strategy v5 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of Omar Edited WF
257 stars

This strategy calculates dynamic support and resistance levels using pivot highs and lows alongside a custom smoothed trend filter and a 3-period EMA. It identifies entry opportunities when price breaks out relative to the trend filter and short-term EMA cross

Strategy v5 TrendSupport & resistance Repaints
Updated 7 weeks ago · None stated GitHub repository of 30s - ES 1m Strategy Candle Bar
106 stars

This overlay strategy plots a two-timeframe Ichimoku setup on the price chart, with Tenkan, Kijun, Chikou, and Kumo from a base higher timeframe and an optional highest-timeframe cloud. It allows two entries in the same direction and uses ATR-based trailing st

Strategy v4 TrendVolatility & bands
Updated 2 years ago · GPL-3.0 GitHub repository of 2Tier Ichimoku Pyramiding [Takazudo]
104 stars

This strategy combines three Exponential Moving Averages with Williams Fractals to execute trend-following or mean-reverting trades. It analyzes price structure using short, medium, and long-term EMAs along with fractal highs and lows. Entries trigger when fra

Strategy v5 TrendMoving averages
Updated 3 years ago · MIT GitHub repository of 3MA and Fractals Strategy

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