Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Ichimoku Cloud Strategy Long Only [Bitduke]

A Pine Script v4 strategy with no technical-analysis calculation. It has 4 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 1000 in cash and pays 0.075% commission. 13 settings; defaults include Conversion Line Periods 9, Base Line Periods 26 and Lagging Span 2 Periods 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 Long Only [Bitduke] repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Ichimoku Cloud Strategy Long Only [Bitduke] do on BTCUSDT 1D with default settings?
−2.10%
From 26 Jan 2024 to 21 Oct 2026, over 14 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Ichimoku Cloud Strategy Long Only [Bitduke] 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 Long Only [Bitduke] use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Ichimoku Cloud Strategy Long Only [Bitduke] run in Zeal Terminal?
Yes
It compiles in 18 ms and runs 1,000 bars in 48 ms, in the browser.

BTCUSDT · 1D · default settings

  • Conversion Line
  • Base Line
  • Lagging Span
  • Lead 1
  • Lead 2
  • 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 (13)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$979$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
−2.10%
−$21.00
Buy and hold
+102.5%
same period
Closed trades
14
0 won · 14 lost
Profitable
0.0%
of closed trades
Profit factor
0.00
gross profit ÷ gross loss
Max drawdown
2.10%
−$21.00

One run with the author's default settings, $1,000 starting capital, commission as the script sets it. 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.

  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • 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 26, 27. 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, crossover → ta.crossover.
  • 2 strategy calls use the when = argument (line 26, 27). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 5: //@version=4 → //@version=5
  • Line 11: avg → math.avg
  • Line 11: lowest → ta.lowest
  • Line 11: highest → ta.highest
  • Line 14: avg → math.avg
  • Line 24: crossover → ta.crossover
  • Line 25: crossover → ta.crossover
⋯// Additional condition for open / close the trade is lagging span, it should be higher than cloud to open position and below - to close it.-//@version=4+//@version=5strategy("Ichimoku Cloud Strategy Long Only", shorttitle="Ichimoku Cloud Strategy (long only)", overlay=true, calc_on_every_tick=true,pyramiding=0, default_qty_type=strategy.cash,default_qty_value=1000, currency=currency.USD, initial_capital=1000,commission_type=strategy.commission.percent, commission_value=0.075)⋯delta = input(26, minval=1, title="Delta")-average(len) => avg(lowest(len), highest(len))+average(len) => math.avg(ta.lowest(len), ta.highest(len))conversion_line = average(conversion_length) // tenkan sen - trendbase_line = average(base_length) // kijun sen - movement-lead_line_a = avg(conversion_line, base_line) // senkou span A+lead_line_a = math.avg(conversion_line, base_line) // senkou span Alead_line_b = average(lagging_length) // senkou span B⋯// Strategy logic-long_signal = crossover(conversion_line,base_line) and ((lagging_span) > (lead_line_a)) and ((lagging_span) > (lead_line_b))+long_signal = ta.crossover(conversion_line,base_line) and ((lagging_span) > (lead_line_a)) and ((lagging_span) > (lead_line_b))-short_signal = crossover(base_line, conversion_line) and ((lagging_span) < (lead_line_a)) and ((lagging_span) < (lead_line_b))+short_signal = ta.crossover(base_line, conversion_line) and ((lagging_span) < (lead_line_a)) and ((lagging_span) < (lead_line_b))strategy.entry("LONG", strategy.long, when=strategy.opentrades == 0 and long_signal, alert_message='BUY')⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 26: when = strategy.opentrades == 0 and long_signal → if block
  • Line 27: when = strategy.opentrades > 0 and short_signal → if block
9 more edits
  • Line 30: input() → input.bool()
  • Line 31: input() → input.int()
  • Line 32: input() → input.int()
  • Line 33: input() → input.int()
  • Line 34: input() → input.int()
  • Line 36: input() → input.int()
  • Line 37: input() → input.int()
  • Line 38: input() → input.int()
  • Line 39: input() → input.int()
⋯strategy("Ichimoku Cloud Strategy Long Only", shorttitle="Ichimoku Cloud Strategy (long only)", overlay=true, calc_on_every_tick=true,pyramiding=0, default_qty_type=strategy.cash,default_qty_value=1000, currency=currency.USD, initial_capital=1000,commission_type=strategy.commission.percent, commission_value=0.075)-conversion_length = input(9, minval=1, title="Conversion Line Periods"),+conversion_length = input.int(9, minval=1, title="Conversion Line Periods"),-base_length = input(26, minval=1, title="Base Line Periods")+base_length = input.int(26, minval=1, title="Base Line Periods")-lagging_length = input(52, minval=1, title="Lagging Span 2 Periods"),+lagging_length = input.int(52, minval=1, title="Lagging Span 2 Periods"),-delta = input(26, minval=1, title="Delta")+delta = input.int(26, minval=1, title="Delta")average(len) => math.avg(ta.lowest(len), ta.highest(len))⋯short_signal = ta.crossover(base_line, conversion_line) and ((lagging_span) < (lead_line_a)) and ((lagging_span) < (lead_line_b))-strategy.entry("LONG", strategy.long, when=strategy.opentrades == 0 and long_signal, alert_message='BUY')+if strategy.opentrades == 0 and long_signal+    strategy.entry("LONG", strategy.long, alert_message='BUY')-strategy.close("LONG", when=strategy.opentrades > 0 and short_signal, alert_message='SELL')+if strategy.opentrades > 0 and short_signal+    strategy.close("LONG", alert_message='SELL')        // === Backtesting Dates === thanks to Trost-testPeriodSwitch = input(true, "Custom Backtesting Dates")+testPeriodSwitch = input.bool(true, "Custom Backtesting Dates")-testStartYear = input(2021, "Backtest Start Year")+testStartYear = input.int(2021, "Backtest Start Year")-testStartMonth = input(1, "Backtest Start Month")+testStartMonth = input.int(1, "Backtest Start Month")-testStartDay = input(1, "Backtest Start Day")+testStartDay = input.int(1, "Backtest Start Day")-testStartHour = input(0, "Backtest Start Hour")+testStartHour = input.int(0, "Backtest Start Hour")testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, testStartHour, 0)-testStopYear = input(2021, "Backtest Stop Year")+testStopYear = input.int(2021, "Backtest Stop Year")-testStopMonth = input(12, "Backtest Stop Month")+testStopMonth = input.int(12, "Backtest Stop Month")-testStopDay = input(1, "Backtest Stop Day")+testStopDay = input.int(1, "Backtest Stop Day")-testStopHour = input(0, "Backtest Stop Hour")+testStopHour = input.int(0, "Backtest Stop Hour")testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, testStopHour, 0)⋯

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: 14 before, 1 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.

⋯// Additional condition for open / close the trade is lagging span, it should be higher than cloud to open position and below - to close it.-//@version=5+//@version=6strategy("Ichimoku Cloud Strategy Long Only", shorttitle="Ichimoku Cloud Strategy (long only)", overlay=true, calc_on_every_tick=true,pyramiding=0, default_qty_type=strategy.cash,default_qty_value=1000, currency=currency.USD, initial_capital=1000,commission_type=strategy.commission.percent, commission_value=0.075)⋯

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 Periods9int · min 1conversion_line
Base Line Periods26int · min 1base_line
Lagging Span 2 Periods52int · min 1lead_line_b
Delta26int · min 1Lead 1 Lead 2 Lagging Span
Custom Backtesting DatestrueboolisPeriod
Backtest Start Year2021inttestPeriodStart
Backtest Start Month1inttestPeriodStart
Backtest Start Day1inttestPeriodStart
Backtest Start Hour0inttestPeriodStart
Backtest Stop Year2021inttestPeriodStop
Backtest Stop Month12inttestPeriodStop
Backtest Stop Day1inttestPeriodStop
Backtest Stop Hour0inttestPeriodStop

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_lengthConversion Line Periodssetting · 9base_lengthBase Line Periodssetting · 26lagging_lengthLagging Span 2 Periodssetting · 52closecloseprice datatestStartYearBacktest Start Yearsetting · 2021testStartMonthBacktest Start Monthsetting · 1testStartDayBacktest Start Daysetting · 1testStartHourBacktest Start Hoursetting · 0testStopYearBacktest Stop Yearsetting · 2021testStopMonthBacktest Stop Monthsetting · 12testStopDayBacktest Stop Daysetting · 1testStopHourBacktest Stop Hoursetting · 0conversion_lineconversion_linevaluebase_linebase_linevaluelead_line_alead_line_avaluelead_line_blead_line_bvaluelagging_spanlagging_spanvaluetestPeriodStarttestPeriodStartvaluetestPeriodStoptestPeriodStopvalueisPeriodisPeriodvaluelong_signal, short_signallong_signal · short_sig…2 conditionsentry:LONGOpen LONGstrategy.entryclose:LONGClose LONGstrategy.closecancel_all:cancel_all strategy.cancel_allclose_all:close_all strategy.close_allplot:17Conversion Lineplotplot:18Base Lineplotplot:19Lagging Spanplotplot:20Lead 1plotplot:21Lead 2plotfill:22Fillfill

Order rules

OrderFires whenBy defaultLine
Open LONG longstrategy.opentrades == 0 and long_signalOn26
Close LONGstrategy.opentrades > 0 and short_signalOn27
cancel_all not isPeriodOn47
Close not isPeriodOn48

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

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

4/4trades 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. On 0 of them the position changed while the bar was forming before it settled. Anyone watching live sees those changes; once the bar closes it matches history.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
  • 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−2.1%+102.5%140%0.002.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−2.1%+5.5%140%0.002.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−1.8%+9.8%120%0.001.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−1.2%+8.4%80%0.001.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−1.7%+16.7%110%0.001.7%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−2.1%+21.5%140%0.002.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−2.9%+148.3%190%0.002.9%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−2.1%+17.1%140%0.002.1%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 market50%−$7.50
Sideways market70%−$10.50
Falling market20%−$3.00

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

How bad could the drawdown be?

2.1%

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

0%2%
All 14 trades
SideEntryExitBarsP&L
long30 Mar 2024 69,850.5030 Mar 2024 69,850.500−$1.50
long17 Jul 2024 65,044.0017 Jul 2024 65,044.000−$1.50
long24 Aug 2024 64,037.2024 Aug 2024 64,037.200−$1.50
long20 Sep 2024 62,948.0020 Sep 2024 62,948.000−$1.50
long20 Oct 2024 68,378.0020 Oct 2024 68,378.000−$1.50
long23 Jan 2025 103,707.0023 Jan 2025 103,707.000−$1.50
long3 Jul 2025 108,850.003 Jul 2025 108,850.000−$1.50
long13 Aug 2025 120,134.0013 Aug 2025 120,134.000−$1.50
long13 Sep 2025 116,029.0013 Sep 2025 116,029.000−$1.50
long6 Oct 2025 123,482.006 Oct 2025 123,482.000−$1.50
long6 Jan 2026 93,859.706 Jan 2026 93,859.700−$1.50
long13 Apr 2026 70,741.6013 Apr 2026 70,741.600−$1.50
long20 Aug 2026 69,334.8020 Aug 2026 69,334.800−$1.50
long25 Sep 2026 84,410.2025 Sep 2026 84,410.200−$1.50

Similar scripts

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

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 18 msYes 1,000 bars in 48 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/// Simple long-only Ichimoku Cloud Strategy// Enter position when conversion line crosses base line up, and close it when the opposite happens. // Additional condition for open / close the trade is lagging span, it should be higher than cloud to open position and below - to close it.//@version=4strategy("Ichimoku Cloud Strategy Long Only", shorttitle="Ichimoku Cloud Strategy (long only)", overlay=true, calc_on_every_tick=true,pyramiding=0, default_qty_type=strategy.cash,default_qty_value=1000, currency=currency.USD, initial_capital=1000,commission_type=strategy.commission.percent, commission_value=0.075)conversion_length = input(9, minval=1, title="Conversion Line Periods"),base_length = input(26, minval=1, title="Base Line Periods")lagging_length = input(52, minval=1, title="Lagging Span 2 Periods"),delta = input(26, minval=1, title="Delta")average(len) => avg(lowest(len), highest(len))conversion_line = average(conversion_length) // tenkan sen - trendbase_line = average(base_length) // kijun sen - movementlead_line_a = avg(conversion_line, base_line) // senkou span Alead_line_b = average(lagging_length) // senkou span Blagging_span = close // chikou span - trend / move powerplot(conversion_line, color=color.blue, linewidth=2, title="Conversion Line")plot(base_line, color=color.white, linewidth=2, title="Base Line")plot(lagging_span, offset = -delta, color=color.purple, linewidth=2, title="Lagging Span")lead_line_a_plot = plot(lead_line_a, offset = delta, color=color.green, title="Lead 1")lead_line_b_plot = plot(lead_line_b, offset = delta, color=color.red, title="Lead 2")fill(lead_line_a_plot, lead_line_b_plot, color = lead_line_a > lead_line_b ? color.green : color.red)// Strategy logiclong_signal = crossover(conversion_line,base_line) and ((lagging_span) > (lead_line_a)) and ((lagging_span) > (lead_line_b))short_signal = crossover(base_line, conversion_line) and ((lagging_span) < (lead_line_a)) and ((lagging_span) < (lead_line_b))strategy.entry("LONG", strategy.long, when=strategy.opentrades == 0 and long_signal, alert_message='BUY')strategy.close("LONG", when=strategy.opentrades > 0 and short_signal, alert_message='SELL')        // === Backtesting Dates === thanks to TrosttestPeriodSwitch = input(true, "Custom Backtesting Dates")testStartYear = input(2021, "Backtest Start Year")testStartMonth = input(1, "Backtest Start Month")testStartDay = input(1, "Backtest Start Day")testStartHour = input(0, "Backtest Start Hour")testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, testStartHour, 0)testStopYear = input(2021, "Backtest Stop Year")testStopMonth = input(12, "Backtest Stop Month")testStopDay = input(1, "Backtest Stop Day")testStopHour = input(0, "Backtest Stop Hour")testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, testStopHour, 0)testPeriod() =>    time >= testPeriodStart and time <= testPeriodStop ? true : falsetestPeriod_1 = testPeriod()isPeriod = testPeriodSwitch == true ? testPeriod_1 : true// === /ENDif not isPeriod    strategy.cancel_all()    strategy.close_all()