Skip to main content

Ichimoku Tenkan 9 / Kijun 26 — Pine Script v5 strategy

TRENDIchimokuPine Script v5

This script rebuilds the Ichimoku lines from highs and lows. It buys when Tenkan-sen crosses above Kijun-sen while the close is above the cloud, and sells when the close drops below Kijun-sen.

Full code (free to copy)

//@version=5
strategy("Ichimoku Cloud & TK Cross", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)

tenkanLen = input.int(9, "Tenkan", minval=5, maxval=20)
kijunLen = input.int(26, "Kijun", minval=15, maxval=50)

tenkan = (ta.highest(high, tenkanLen) + ta.lowest(low, tenkanLen)) / 2.0
kijun = (ta.highest(high, kijunLen) + ta.lowest(low, kijunLen)) / 2.0
spanA = (tenkan + kijun) / 2.0
spanB = (ta.highest(high, 52) + ta.lowest(low, 52)) / 2.0
cloudTop = math.max(spanA[26], spanB[26])

if close > cloudTop and ta.crossover(tenkan, kijun)
    strategy.entry("Long", strategy.long)
if close < kijun
    strategy.close("Long")

plot(tenkan, "Tenkan", color=color.aqua)
plot(kijun, "Kijun", color=color.red)

Judge this code on BTCUSDT 1D →Free, in your browser, on the same candles as the table below.

Online judge verdict on BTCUSDT (measured 29 November 2026)

TimeframeSealed periodTradesReturnBuy & holdVerdict
1d2024-12-17 → 2026-10-167-9.84 %-23.25 %Not enough trades to judge yet
4h2026-03-12 → 2026-10-1714-5.36 %15.83 %No evidence of an edge, for now
1h2026-08-05 → 2026-10-171910.34 %27.14 %No evidence of an edge, for now

Past data, 10 bps per fill, last 20% of the bars sealed. Windows: full history on 1d, last 3 years on 4h, last year on 1h. Research, not advice: no result is promised.

This reading has not been compared with a real TradingView run.

Measured on 29 November 2026 with the online judge’s Pine v5 engine (sa-pine-vm 0.2.0), on Binance BTCUSDT candles up to 16/10/2026 on 1D and up to 17/10/2026 on 4h and 1h. Differences with TradingView’s Strategy Tester remain possible. Binance data, CC BY-NC-SA 4.0.

Open this code in the free judge (1 click) →

Replay each verdict yourself, in your browser: 1d · 4h · 1h. The script is filled in; nothing runs until you click “Judge”.

How the script works

Tenkan = midpoint of the high and low over 9 bars, Kijun = same over 26, Senkou B = same over 52 (hard-coded). Senkou A = average of Tenkan and Kijun.

The cloud top cloudTop = math.max(spanA[26], spanB[26]) uses values from 26 bars ago, i.e. the cloud as it is drawn under the current bar. Entry requires close > cloudTop and ta.crossover(tenkan, kijun); the exit is close < kijun.

Parameters in the code

ParameterValueRole
tenkanLen9Input "Tenkan" created with input.int, from 5 to 20.
kijunLen26Input "Kijun" created with input.int, from 15 to 50.
initial_capital10000Starting capital declared in strategy().
default_qty_typepercent_of_equity, 100Each entry commits 100% of available equity.
commission_value0.1 (%)0.10% commission per order declared in the script; the judge applies it (10 bps per fill).
process_orders_on_closenot setOrders fill at the open of the next bar, the Pine default.

Known limits of this rule

Before you trust it: test it on data it never saw

A backtest in TradingView's Strategy Tester shows one past path with the settings you picked. Strategy Arena Lab (free, Windows and Linux) replays this Pine on your PC, compares its trades one by one with TradingView's for supported Pine, counts the variants you try, then judges the rule on a period kept sealed during the search: survives, no evidence of an edge or inconclusive.

Get the free Lab →

FAQ

What does the online judge say about this script?

On BTCUSDT, with 10 bps fees per fill, measured on 29 November 2026: 1D: "Not enough trades to judge yet" (7 trades, -9.84% on the sealed period); 4h: "No evidence of an edge, for now" (14 trades, -5.36% on the sealed period); 1h: "No evidence of an edge, for now" (19 trades, 10.34% on the sealed period). No timeframe reaches "Survives". These verdicts concern past data and say nothing certain about the future.

Does the 26-bar cloud offset leak future data?

Not in this code: it reads spanA[26] and spanB[26], so past values. A leak would appear if the cloud projected 26 bars ahead were used to decide on the current bar.

Can I change the script's settings?

Yes, the settings are inputs you can edit in TradingView. Each setting you try is one more trial: a setting chosen after seeing the sealed period is no longer a test on unseen data. The judge and the Lab count trials for this reason.

Other free Pine Script v5 strategies

RSI Mean ReversionEMA Crossover 9/21EMA Ribbon 8/21/55Bollinger Band BounceMACD MomentumSuperTrendStochastic RSIATR BreakoutVWAP BounceRSI + EMA ComboFaber 10-Month TimingGolden Cross SMA 50/200Bollinger Squeeze BreakoutKeltner Channel Breakout 20/1.5Donchian Turtle 20/10ADX 25 & DMI 14 TrendParabolic SAR 0.02/0.2Hull Moving Average 55ALMA 20 Gaussian TrendCCI 20 (+100) BreakoutMoney Flow Index MFI 14 (20/80)ATR 14 Chandelier StopLinear Regression 20ROC 14 + EMA 200 FilterWilliams %R 14 PullbackNo-Leak Weekly EMA FilterPivot High/Low BreakoutAI-style ATR Breakout + EMA 200
TradingView Starter
Choose the account path. Prove the strategy separately.
Your first chart and price alert do not require the Lab. Strategy Arena proof remains required before trusting or exporting a strategy.
Partner attribution is for first-time users and web purchases only. Strategy Arena may earn a commission on eligible purchases; starting with a free account needs no payment.
I have never had an account · Start free I already have an account Check a strategy
More TradingView paths
Evidence-gated Pine review

Educational code on past data. No investment advice; no result is promised.