Pine Script v4 · Strategy
BTC_ISHIMOKU
A Pine Script v4 strategy built on Highest (high, 20) and Lowest (low, 20). It has 2 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 100% of equity and pays 0.25 commission. 5 settings; defaults include Period max 20, Period med 10 and Period min 16.
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 BTC_ISHIMOKU repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did BTC_ISHIMOKU do on BTCUSDT 1D with default settings?
- −1.39%
- From 26 Jan 2024 to 21 Oct 2026, over 8 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can BTC_ISHIMOKU 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 BTC_ISHIMOKU use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does BTC_ISHIMOKU run in Zeal Terminal?
- Yes
- It compiles in 7 ms and runs 1,000 bars in 28 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −1.39%
- −$13.94
- Buy and hold
- +102.5%
- same period
- Closed trades
- 8
- 3 won · 5 lost
- Profitable
- 37.5%
- of closed trades
- Profit factor
- 0.95
- gross profit ÷ gross loss
- Max drawdown
- 39.80%
- −$399.57
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.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
5 settings have no label
In the settings dialog period_max (line 5), period_med (line 6), period_min (line 7), start (line 19), finish (line 20) show an empty name. The labels on this page come from the variable names.
-
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 22, 24. The upgraded version below moves each call inside an if block.
-
Note
Uses transp =, which v5 removed line 18
transp = on line 18. v5 folds the transparency into the colour with color.new(c, transp).
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 highest → ta.highest, lowest → ta.lowest, crossover → ta.crossover, crossunder → ta.crossunder.
- 2 strategy calls use the when = argument (line 22, 24). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 8 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 8: highest → ta.highest
- Line 9: lowest → ta.lowest
- Line 10: highest → ta.highest
- Line 11: lowest → ta.lowest
- Line 12: highest → ta.highest
5 more edits
- Line 13: lowest → ta.lowest
- Line 18: transp = 90 → color.new(HL1 < HL2 ? color.green : color.red, 90)
- Line 22: strategy.entry(…, true) → strategy.entry(…, strategy.long)
- Line 22: crossover → ta.crossover
- Line 24: crossunder → ta.crossunder
⋯// © Alferow-//@version=4+//@version=5strategy("BTC_ISHIMOKU", overlay=true, initial_capital=1000, commission_value=0.25, default_qty_type=strategy.percent_of_equity, default_qty_value=100)⋯period_min = input(16, minval = 1)-Lmax = highest(high, period_max)+Lmax = ta.highest(high, period_max)-Smax = lowest(low, period_max)+Smax = ta.lowest(low, period_max)-Lmed = highest(high, period_med)+Lmed = ta.highest(high, period_med)-Smed = lowest(low, period_med)+Smed = ta.lowest(low, period_med)-Lmin = highest(high, period_min)+Lmin = ta.highest(high, period_min)-Smin = lowest(low, period_min)+Smin = ta.lowest(low, period_min)HL1 = (Lmax + Smax + Lmed + Smed)/4⋯p2 = plot(HL2, color = color.green, linewidth = 2)-fill(p1, p2, color = HL1 < HL2 ? color.green : color.red, transp = 90)+fill(p1, p2, color = color.new(HL1 < HL2 ? color.green : color.red, 90))start = timestamp(input(2020, minval=1), 01, 01, 00, 00)⋯trig = time > start and time < finish ? true : false-strategy.entry("Long", true, when = crossover(HL2, HL1) and trig)+strategy.entry("Long", strategy.long, when = ta.crossover(HL2, HL1) and trig)// strategy.entry("Short", false, when = crossunder(HL2, HL1) and trig)-strategy.close("Long", when = crossunder(HL2, HL1) and trig)+strategy.close("Long", when = ta.crossunder(HL2, HL1) and trig)Same 8 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: input() → input.int()
- Line 6: input() → input.int()
- Line 7: input() → input.int()
- Line 19: input() → input.int()
- Line 20: input() → input.int()
- Line 22: when = ta.crossover(HL2, HL1) and trig → if block
- Line 24: when = ta.crossunder(HL2, HL1) and trig → if block
⋯strategy("BTC_ISHIMOKU", overlay=true, initial_capital=1000, commission_value=0.25, default_qty_type=strategy.percent_of_equity, default_qty_value=100)-period_max = input(20, minval = 1)+period_max = input.int(20, minval = 1)-period_med = input(10, minval = 1)+period_med = input.int(10, minval = 1)-period_min = input(16, minval = 1)+period_min = input.int(16, minval = 1)Lmax = ta.highest(high, period_max)⋯fill(p1, p2, color = color.new(HL1 < HL2 ? color.green : color.red, 90))-start = timestamp(input(2020, minval=1), 01, 01, 00, 00)+start = timestamp(input.int(2020, minval=1), 01, 01, 00, 00)-finish = timestamp(input(2025, minval=1),01, 01, 00, 00)+finish = timestamp(input.int(2025, minval=1),01, 01, 00, 00)trig = time > start and time < finish ? true : false-strategy.entry("Long", strategy.long, when = ta.crossover(HL2, HL1) and trig)+if ta.crossover(HL2, HL1) and trig+ strategy.entry("Long", strategy.long)// strategy.entry("Short", false, when = crossunder(HL2, HL1) and trig)-strategy.close("Long", when = ta.crossunder(HL2, HL1) and trig)+if ta.crossunder(HL2, HL1) and trig+ strategy.close("Long")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: 8 before, 9 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.
⋯// © Alferow-//@version=5+//@version=6strategy("BTC_ISHIMOKU", overlay=true, initial_capital=1000, commission_value=0.25, default_qty_type=strategy.percent_of_equity, default_qty_value=100)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Period max (no label in the script) | 20 | int · min 1 | Lmax Smax |
| Period med (no label in the script) | 10 | int · min 1 | Lmed Smed |
| Period min (no label in the script) | 16 | int · min 1 | Lmin Smin |
| Start (no label in the script) | 2020 | int · min 1 | trig |
| Finish (no label in the script) | 2025 | int · min 1 | trig |
What it calculates
- Highest (
highest,ta.highestin v5)high, Period max (20)Lmax · line 8 - Lowest (
lowest,ta.lowestin v5)low, Period max (20)Smax · line 9 - Highest (
highest,ta.highestin v5)high, Period med (10)Lmed · line 10 - Lowest (
lowest,ta.lowestin v5)low, Period med (10)Smed · line 11 - Highest (
highest,ta.highestin v5)high, Period min (16)Lmin · line 12 - Lowest (
lowest,ta.lowestin v5)low, Period min (16)Smin · line 13
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | crossover(HL2, HL1) and trig | On | 22 |
| Close Long | crossunder(HL2, HL1) and trig | On | 24 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −1.4% | +102.5% | 8 | 38% | 0.95 | 39.8% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −32.5% | +9.8% | 11 | 45% | 0.43 | 49.6% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +106.1% | +16.7% | 9 | 78% | 2.56 | 44.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +41.7% | +148.3% | 12 | 67% | 1.78 | 37.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.0% | 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 3 | 33% | −$86.95 |
| Sideways market | 4 | 50% | $96.18 |
| Falling market | 1 | 0% | −$20.71 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
27.2%
The 95th percentile of the worst drawdown when the same 8 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 15.1% to 27.2%; the tick is what actually happened, 27.2%. Order luck alone moves it this much.
All 8 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 11 Mar 2024 68,955.90 | 31 Mar 2024 69,582.20 | 20 | $4.05 |
| long | 6 Apr 2024 67,820.60 | 25 Apr 2024 64,289.60 | 19 | −$57.02 |
| long | 17 May 2024 65,235.20 | 24 Jun 2024 63,210.00 | 38 | −$33.98 |
| long | 22 Jul 2024 68,165.40 | 15 Aug 2024 58,683.40 | 24 | −$130.93 |
| long | 22 Aug 2024 61,156.00 | 29 Aug 2024 59,034.90 | 7 | −$30.89 |
| long | 1 Sep 2024 58,974.00 | 11 Sep 2024 57,636.00 | 10 | −$20.71 |
| long | 19 Sep 2024 61,760.00 | 14 Oct 2024 62,870.00 | 25 | $9.42 |
| long | 22 Oct 2024 67,377.50 | 19 Nov 2024 90,464.10 | 28 | $248.58 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| BTC_ISHIMOKU this page | — | v4 strategy | −1.4% | 8 | 39.8% |
| Alex Days HiLo Rajib by 14rajib | highest lowest | v4 strategy | No trades on this market | ||
| Donchian Strat EXMO by pskoroplas | highest lowest | v4 strategy | +12.1% | 22 | 68.0% |
| Average Highest High and Lowest Low Swinger Strategy by exlux99 | lowest highest | v4 strategy | +6.4% | 20 | 49.6% |
| Highest High and Lowest Low Channel Strategy by ceyhun | highest lowest | v5 strategy | −3.7% | 26 | 7.9% |
| Donchian Channels System [racer8] by racer8 | highest lowest | v4 strategy | −3.2% | 36 | 43.6% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 7 ms | With a workaround 1,000 bars in 28 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 22) so the engine trades the way the script says.
“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/// © Alferow//@version=4strategy("BTC_ISHIMOKU", overlay=true, initial_capital=1000, commission_value=0.25, default_qty_type=strategy.percent_of_equity, default_qty_value=100)period_max = input(20, minval = 1)period_med = input(10, minval = 1)period_min = input(16, minval = 1)Lmax = highest(high, period_max)Smax = lowest(low, period_max)Lmed = highest(high, period_med)Smed = lowest(low, period_med)Lmin = highest(high, period_min)Smin = lowest(low, period_min)HL1 = (Lmax + Smax + Lmed + Smed)/4HL2 = (Lmed + Smed + Lmin + Smin)/4p1 = plot(HL1, color = color.red, linewidth = 2)p2 = plot(HL2, color = color.green, linewidth = 2)fill(p1, p2, color = HL1 < HL2 ? color.green : color.red, transp = 90)start = timestamp(input(2020, minval=1), 01, 01, 00, 00)finish = timestamp(input(2025, minval=1),01, 01, 00, 00)trig = time > start and time < finish ? true : falsestrategy.entry("Long", true, when = crossover(HL2, HL1) and trig)// strategy.entry("Short", false, when = crossunder(HL2, HL1) and trig)strategy.close("Long", when = crossunder(HL2, HL1) and trig)