Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Ichimoku Cloud Strategy Idea

A Pine Script v4 strategy with no technical-analysis calculation. It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade commits 99% of equity and pays 0.1% commission. 7 settings; defaults include Conversion Line Period 9, Base Line Period 26 and Lagging Span 2 Period 52.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Ichimoku Cloud Strategy Idea repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
How did Ichimoku Cloud Strategy Idea do on BTCUSDT 1D with default settings?
−9.31%
From 26 Jan 2024 to 21 Oct 2026, over 32 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Ichimoku Cloud Strategy Idea be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does Ichimoku Cloud Strategy Idea use a stop loss?
Yes
strategy.exit sets a stop on line 43, 44.
Does Ichimoku Cloud Strategy Idea run in Zeal Terminal?
Yes
It compiles in 14 ms and runs 1,000 bars in 50 ms, in the browser.

BTCUSDT · 1D · default settings

  • Lead 1
  • Lead 2
  • Plot
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (7)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,051$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
Net profit
−9.31%
−$93.05
Buy and hold
+102.5%
same period
Closed trades
32
8 won · 24 lost
Profitable
25.0%
of closed trades
Profit factor
0.89
gross profit ÷ gross loss
Max drawdown
49.87%
−$498.67

One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A long position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 34, 35, 37, 38. The upgraded version below moves each call inside an if block.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames avg → math.avg, lowest → ta.lowest, highest → ta.highest, max → math.max, min → math.min.
  • 4 strategy calls use the when = argument (line 34, 35, 37, 38). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 32 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 22: avg → math.avg
  • Line 22: lowest → ta.lowest
  • Line 22: highest → ta.highest
  • Line 25: avg → math.avg
  • Line 28: max → math.max
3 more edits
  • Line 29: max → math.max
  • Line 31: min → math.min
  • Line 32: min → math.min
⋯// © QuantCT-//@version=4+//@version=5strategy("Ichimoku Cloud Strategy Idea",⋯// ____ Logic-donchian(len) => avg(lowest(len), highest(len))+donchian(len) => math.avg(ta.lowest(len), ta.highest(len))conversion_line = donchian(conversion_period)base_line = donchian(base_period)-lead_line1 = avg(conversion_line, base_line)+lead_line1 = math.avg(conversion_line, base_line)lead_line2 = donchian(lagging_span2_period)chikou = close-chikou_free_long = close > high[displacement] and close > max(lead_line1[2 * displacement], lead_line2[2 * displacement])+chikou_free_long = close > high[displacement] and close > math.max(lead_line1[2 * displacement], lead_line2[2 * displacement])-enter_long = chikou_free_long and close > max(lead_line1[displacement], lead_line2[displacement])+enter_long = chikou_free_long and close > math.max(lead_line1[displacement], lead_line2[displacement])exit_long = close < lead_line1[displacement] or close < lead_line2[displacement]-chikou_free_short = close < low[displacement] and  close < min(lead_line1[2 * displacement], lead_line2[2 * displacement])+chikou_free_short = close < low[displacement] and  close < math.min(lead_line1[2 * displacement], lead_line2[2 * displacement])-enter_short = chikou_free_short and close < min(lead_line1[displacement], lead_line2[displacement])+enter_short = chikou_free_short and close < math.min(lead_line1[displacement], lead_line2[displacement])exit_short = close > lead_line1[displacement] or close > lead_line2[displacement]⋯

Clean v5

VerifiedDownload the v5 script

Same 32 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 14: input() → input.int()
  • Line 15: input() → input.int()
  • Line 16: input() → input.int()
  • Line 17: input() → input.int()
  • Line 18: input() → input.bool()
  • Line 19: input() → input.float()
5 more edits
  • Line 20: input() → input.bool()
  • Line 34: when = enter_long → if block
  • Line 35: when = exit_long → if block
  • Line 37: when = enter_short → if block
  • Line 38: when = exit_short → if block
⋯// ____ Inputs-conversion_period = input(9, minval=1, title="Conversion Line Period")+conversion_period = input.int(9, minval=1, title="Conversion Line Period")-base_period = input(26, minval=1, title="Base Line Period")+base_period = input.int(26, minval=1, title="Base Line Period")-lagging_span2_period = input(52, minval=1, title="Lagging Span 2 Period")+lagging_span2_period = input.int(52, minval=1, title="Lagging Span 2 Period")-displacement = input(26, minval=1, title="Displacement")+displacement = input.int(26, minval=1, title="Displacement")-long_only = input(title="Long Only", defval=false)+long_only = input.bool(title="Long Only", defval=false)-slp = input(title="Stop-loss (%)", minval=1.0, maxval=25.0, defval=5.0)+slp = input.float(title="Stop-loss (%)", minval=1.0, maxval=25.0, defval=5.0)-use_sl = input(title="Use Stop-Loss", defval=false)+use_sl = input.bool(title="Use Stop-Loss", defval=false)// ____ Logic⋯exit_short = close > lead_line1[displacement] or close > lead_line2[displacement]-strategy.entry("Long", strategy.long, when=enter_long)+if enter_long+    strategy.entry("Long", strategy.long)-strategy.close("Long", when=exit_long) +if exit_long+    strategy.close("Long") if (not long_only)-    strategy.entry("Short", strategy.short, when=enter_short)+    if enter_short+        strategy.entry("Short", strategy.short)-    strategy.close("Short", when=exit_short) +    if exit_short+        strategy.close("Short") // ____ SL⋯

Does it run in Pine Script v6?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 32 before, 91 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © QuantCT-//@version=5+//@version=6strategy("Ichimoku Cloud Strategy Idea",⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Conversion Line Period9int · min 1conversion_line
Base Line Period26int · min 1base_line
Lagging Span 2 Period52int · min 1lead_line2
Displacement26int · min 1chikou_free_long enter_long exit_long chikou_free_short enter_short exit_short Lead 1 Lead 2 plot
Long Onlyfalseboolentry Short close Short line 36
Stop-loss (%)5.0float · min 1.0 · max 25.0sl_long sl_short
Use Stop-Lossfalseboolexit SL exit SL line 42

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

conversion_periodConversion Line Periodsetting · 9base_periodBase Line Periodsetting · 26lagging_span2_periodLagging Span 2 Periodsetting · 52closecloseprice dataslpStop-loss (%)setting · 5.0displacementDisplacementsetting · 26highhighprice datalowlowprice dataconversion_lineconversion_linevaluebase_linebase_linevaluelead_line1lead_line1valuelead_line2lead_line2valuechikouchikouvaluesl_long, sl_shortsl_long · sl_short2 valuesenter_longenter_longconditionexit_longexit_longconditionenter_shortenter_shortconditionexit_shortexit_shortconditionchikou_free_longchikou_free_longconditionchikou_free_shortchikou_free_shortconditioncolorsColourcolorsentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeentry:ShortOpen Shortstrategy.entryclose:ShortClose Shortstrategy.closeexit:SLexit SLstrategy.exitplot:51Lead 1plotplot:53Lead 2plotfill:55Fillfillplot:56plotplot

Order rules

OrderFires whenBy defaultLine
Open Long longenter_longchikou_free_long and close > max(lead_line1[displacement], lead_line2[displacement])On34
Close Longexit_longclose < lead_line1[displacement] or close < lead_line2[displacement]On35
Open Short shortenter_shortchikou_free_short and close < min(lead_line1[displacement], lead_line2[displacement])On37
Close Shortexit_shortclose > lead_line1[displacement] or close > lead_line2[displacement]On38
Exit SL stop(use_sl)On43
Exit SL stop(use_sl)On44

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

7/7trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D−9.3%+102.5%3225%0.8949.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+8.4%+5.5%2335%1.2613.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+112.9%+9.8%1656%2.8639.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+4.0%+8.4%3020%1.0622.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−58.0%+16.7%3023%0.4277.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+33.6%+21.5%2425%1.6524.4%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+28.8%+148.3%3027%1.4240.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−2.4%+17.1%2528%0.9218.9%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market714%−$126.04
Sideways market1833%$124.27
Falling market714%−$90.38

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

53.2%

The 95th percentile of the worst drawdown when the same 32 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 28.9% to 53.2%; the tick is what actually happened, 45.3%. Order luck alone moves it this much.

0%61%
All 32 trades
SideEntryExitBarsP&L
long16 May 2024 66,206.5017 May 2024 65,235.201−$16.47
long18 May 2024 67,024.0020 May 2024 66,274.002−$12.82
long21 May 2024 71,446.6019 Jun 2024 65,175.3029−$86.10
short22 Jun 2024 64,143.6016 Jul 2024 64,724.1024−$9.68
long22 Jul 2024 68,165.403 Aug 2024 61,498.3012−$86.28
short6 Aug 2024 54,018.809 Aug 2024 61,686.003−$112.38
short12 Aug 2024 58,712.6014 Aug 2024 60,587.202−$22.71
short15 Aug 2024 58,683.4024 Aug 2024 64,037.209−$60.32
short28 Aug 2024 59,415.003 Sep 2024 59,132.106$1.62
short5 Sep 2024 57,970.9014 Sep 2024 60,498.009−$26.85
short17 Sep 2024 58,214.0018 Sep 2024 60,314.001−$21.41
long25 Sep 2024 64,262.701 Jan 2025 93,576.0098$245.26
long6 Jan 2025 98,363.609 Jan 2025 95,060.603−$27.84
long16 Jan 2025 100,497.003 Feb 2025 97,700.6018−$22.52
long4 Feb 2025 101,329.005 Feb 2025 97,763.101−$27.25
short24 Feb 2025 96,258.0013 Apr 2025 85,276.9048$79.26
short16 Apr 2025 83,644.0022 Apr 2025 87,516.206−$37.94
long25 Apr 2025 93,980.5020 Jun 2025 104,659.0056$83.33
long26 Jun 2025 107,341.0019 Aug 2025 116,227.0054$66.96
short6 Sep 2025 110,660.008 Sep 2025 111,137.002−$5.66
long19 Sep 2025 117,074.0020 Sep 2025 115,632.001−$12.73
long2 Oct 2025 118,595.0011 Oct 2025 112,774.009−$44.79
short11 Oct 2025 112,774.0013 Oct 2025 114,959.002−$17.84
short15 Oct 2025 113,028.0027 Oct 2025 114,559.0012−$12.69
short29 Oct 2025 112,898.005 Jan 2026 91,529.7068$150.57
short26 Jan 2026 86,670.4028 Jan 2026 89,250.002−$30.27
short30 Jan 2026 84,650.2016 Mar 2026 72,815.3045$127.22
short30 Mar 2026 66,010.906 Apr 2026 69,034.207−$50.14
short7 Apr 2026 68,853.708 Apr 2026 71,924.201−$46.57
long2 May 2026 78,231.1028 May 2026 74,449.3026−$47.90
short3 Jun 2026 66,760.8021 Jul 2026 65,255.5048$18.62
short17 Aug 2026 62,900.0018 Aug 2026 64,532.101−$25.83

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 14 msYes 1,000 bars in 50 msNot measured
PineTSNo v5 and v6 only—Not measured

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © QuantCT//@version=4strategy("Ichimoku Cloud Strategy Idea",         shorttitle="Ichimoku",          overlay=true,         pyramiding=0,              default_qty_type=strategy.percent_of_equity,          default_qty_value=99,          initial_capital=1000,                    commission_type=strategy.commission.percent,          commission_value=0.1)// ____ Inputsconversion_period = input(9, minval=1, title="Conversion Line Period")base_period = input(26, minval=1, title="Base Line Period")lagging_span2_period = input(52, minval=1, title="Lagging Span 2 Period")displacement = input(26, minval=1, title="Displacement")long_only = input(title="Long Only", defval=false)slp = input(title="Stop-loss (%)", minval=1.0, maxval=25.0, defval=5.0)use_sl = input(title="Use Stop-Loss", defval=false)// ____ Logicdonchian(len) => avg(lowest(len), highest(len))conversion_line = donchian(conversion_period)base_line = donchian(base_period)lead_line1 = avg(conversion_line, base_line)lead_line2 = donchian(lagging_span2_period)chikou = closechikou_free_long = close > high[displacement] and close > max(lead_line1[2 * displacement], lead_line2[2 * displacement])enter_long = chikou_free_long and close > max(lead_line1[displacement], lead_line2[displacement])exit_long = close < lead_line1[displacement] or close < lead_line2[displacement]chikou_free_short = close < low[displacement] and  close < min(lead_line1[2 * displacement], lead_line2[2 * displacement])enter_short = chikou_free_short and close < min(lead_line1[displacement], lead_line2[displacement])exit_short = close > lead_line1[displacement] or close > lead_line2[displacement]strategy.entry("Long", strategy.long, when=enter_long)strategy.close("Long", when=exit_long) if (not long_only)    strategy.entry("Short", strategy.short, when=enter_short)    strategy.close("Short", when=exit_short) // ____ SLsl_long = strategy.position_avg_price * (1- (slp/100))sl_short = strategy.position_avg_price * (1 + (slp/100))if (use_sl)    strategy.exit(id="SL", from_entry="Long", stop=sl_long)    strategy.exit(id="SL", from_entry="Short", stop=sl_short)// ____ Plotscolors =  enter_long ? #27D600 : enter_short ? #E30202 : color.orange p1 = plot(lead_line1, offset = displacement, color=colors,     title="Lead 1")p2 = plot(lead_line2, offset = displacement, color=colors,     title="Lead 2")fill(p1, p2, color = colors)plot(chikou, offset = -displacement, color=color.blue)