Pine Script v5 · Strategy
The Impeccable by zyberal
A Pine Script v5 strategy built on MACD (close, 3). It has 2 order rules and no entry of its own. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 16 settings; defaults include Ichimoku Tenkan Period 9, Ichimoku Kijun Period 190 and Ichimoku Senkou 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 The Impeccable by zyberal repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- How did The Impeccable by zyberal do on BTCUSDT 1D with default settings?
- +1.05%
- From 26 Jan 2024 to 21 Oct 2026, over 9 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does The Impeccable by zyberal 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: 9 before, 8 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does The Impeccable by zyberal use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does The Impeccable by zyberal run in Zeal Terminal?
- Yes
- It compiles in 31 ms and runs 1,000 bars in 86 ms, in the browser.
BTCUSDT · 1D · default settings
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +1.05%
- $10,527.20
- Buy and hold
- +102.5%
- same period
- Closed trades
- 9
- 5 won · 4 lost
- Profitable
- 55.6%
- of closed trades
- Profit factor
- 1.17
- gross profit ÷ gross loss
- Max drawdown
- 4.41%
- −$44,274.80
One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A short 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
5 settings do nothing
“Ichimoku Kijun Period”, “Ichimoku Senkou Period”, “Exit After Bars”, “Profit Target”, “Stop Loss” are declared but never read.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
16 settings have no label
In the settings dialog IchimokuTenkanPeriod (line 7), IchimokuKijunPeriod (line 8), IchimokuSenkouPeriod (line 9), MACDMainFast (line 10), MACDMainSlow (line 11), MACDMainSmooth (line 12), ExitAfterBars (line 13), ProfitTarget (line 14), StopLoss (line 15), DontTradeOnWeekends (line 17), ExitAtEndOfDay (line 18), DayExitTimeHour (line 19), DayExitTimeMinute (line 20), ExitOnFriday (line 21), FridayExitTimeHour (line 22), FridayExitTimeMinute (line 23) 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 61, 62. The upgraded version below moves each call inside an if block.
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 |
|---|---|---|---|
| Ichimoku Tenkan Period (no label in the script) | 9 | int | Tenkan |
| Ichimoku Kijun Period (no label in the script) | 190 | int | unused |
| Ichimoku Senkou Period (no label in the script) | 52 | int | unused |
| MACDMain Fast (no label in the script) | 3 | int | macdLine signalLine |
| MACDMain Slow (no label in the script) | 10 | int | macdLine signalLine |
| MACDMain Smooth (no label in the script) | 9 | int | macdLine signalLine |
| Exit After Bars (no label in the script) | 2 | int | unused |
| Profit Target (no label in the script) | 135 | int | unused |
| Stop Loss (no label in the script) | 70 | int | unused |
| Dont Trade On Weekends (no label in the script) | true | bool | line 28 |
| Exit At End Of Day (no label in the script) | true | bool | line 34 |
| Day Exit Time Hour (no label in the script) | 23 | int | line 36 |
| Day Exit Time Minute (no label in the script) | 04 | int | line 36 |
| Exit On Friday (no label in the script) | true | bool | line 40 |
| Friday Exit Time Hour (no label in the script) | 20 | int | line 42 |
| Friday Exit Time Minute (no label in the script) | 40 | int | line 42 |
What it calculates
- MACDclose, MACDMain Fast (3), MACDMain Slow (10), MACDMain Smooth (9)
macdLine · line 49 - MACDclose, MACDMain Fast (3), MACDMain Slow (10), MACDMain Smooth (9)
signalLine · line 49
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 |
|---|---|---|---|
| order buy long | longConditionOpenOrdersAllowed and not IsLong() and LongEntrySignal | On | 61 |
| order sell short | shortConditionOpenOrdersAllowed and not IsShort() and ShortEntrySignal | On | 62 |
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.
- ClearHigher-timeframe data1 request.security call(s), none with lookahead on.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- CheckIntrabar recalculationreads realtime-only state. 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +1.1% | +102.5% | 9 | 56% | 1.17 | 4.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +1.5% | +5.5% | 11 | 82% | 2.25 | 1.8% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.1% | +9.8% | 8 | 38% | 0.54 | 0.4% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 10 | 80% | 1.35 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 8 | 75% | 1.28 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 9 | 56% | 0.69 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.0% | +148.3% | 11 | 82% | 2.23 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 11 | 82% | 2.16 | 0.0% | 8 May 2026 – 21 Oct 2026 |
Higher-timeframe data for request.security(): BINANCE:BTCUSDT W (Binance BTCUSDT 1w), fetched from Binance's public market data for each market.
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% | −$23,479.40 |
| Sideways market | 5 | 60% | $23,173.90 |
| Falling market | 1 | 100% | $10,832.70 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
5.7%
The 95th percentile of the worst drawdown when the same 9 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 2.8% to 5.7%; the tick is what actually happened, 3.5%. Order luck alone moves it this much.
All 9 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 1 Mar 2024 61,131.00 | 16 Apr 2024 63,420.00 | 46 | −$2,289.00 |
| long | 30 Apr 2024 63,866.00 | 8 Jun 2024 69,355.60 | 39 | $5,489.60 |
| long | 2 Jul 2024 62,900.00 | 20 Aug 2024 59,438.50 | 49 | −$3,461.50 |
| short | 1 Nov 2024 70,292.00 | 21 Feb 2025 98,305.00 | 112 | −$28,013.00 |
| long | 28 Feb 2025 84,708.60 | 24 May 2025 107,318.00 | 85 | $22,609.70 |
| long | 11 Jul 2025 116,010.00 | 6 Dec 2025 89,330.00 | 148 | −$26,680.00 |
| short | 17 Jan 2026 95,550.90 | 27 Feb 2026 67,485.20 | 41 | $28,065.80 |
| short | 14 Mar 2026 70,930.00 | 27 Jun 2026 60,097.30 | 105 | $10,832.70 |
| long | 4 Jul 2026 62,583.30 | 22 Jul 2026 66,556.10 | 18 | $3,972.89 |
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 |
|---|---|---|---|---|---|
| The Impeccable by zyberal this page | — | v5 strategy | +1.1% | 9 | 4.4% |
| Ichimoku Cloud with MACD (By Coinrule) by Coinrule | macd | v5 strategy | −8.4% | 6 | 19.3% |
| Dual MACD Strategy by Trading_Solutions_ | macd | v4 strategy | No trades on this market | ||
| Short Swing Bearish MACD Cross (By Coinrule) by Coinrule | macd | v5 strategy | −6.9% | 8 | 6.9% |
| [blackcat] L2 Reversal Labels Strategy by blackcat1402 | macd | v5 strategy | +13.9% | 7 | 2.7% |
| MACD Trend Strategy by Zeal Terminal | macd | v5 strategy | −1.0% | 21 | 3.5% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- 2 strategy calls use the when = argument (line 61, 62). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 16 settings use the untyped input() (line 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23). It still compiles in v6; input.int, input.float or input.source state the type.
- No v6-only features. v6 is not needed to run this script.
Same 9 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 11: input() → input.int()
- Line 12: input() → input.int()
12 more edits
- Line 13: input() → input.int()
- Line 14: input() → input.int()
- Line 15: input() → input.int()
- Line 17: input() → input.bool()
- Line 18: input() → input.bool()
- Line 19: input() → input.int()
- Line 20: input() → input.int()
- Line 21: input() → input.bool()
- Line 22: input() → input.int()
- Line 23: input() → input.int()
- Line 61: when = longCondition → if block
- Line 62: when = shortCondition → if block
⋯// Strategy variables-IchimokuTenkanPeriod = input(9)+IchimokuTenkanPeriod = input.int(9)-IchimokuKijunPeriod = input(190)+IchimokuKijunPeriod = input.int(190)-IchimokuSenkouPeriod = input(52)+IchimokuSenkouPeriod = input.int(52)-MACDMainFast = input(3)+MACDMainFast = input.int(3)-MACDMainSlow = input(10)+MACDMainSlow = input.int(10)-MACDMainSmooth = input(9)+MACDMainSmooth = input.int(9)-ExitAfterBars = input(2)+ExitAfterBars = input.int(2)-ProfitTarget = input(135)+ProfitTarget = input.int(135)-StopLoss = input(70)+StopLoss = input.int(70)// Trading Options-DontTradeOnWeekends = input(true)+DontTradeOnWeekends = input.bool(true)-ExitAtEndOfDay = input(true)+ExitAtEndOfDay = input.bool(true)-DayExitTimeHour = input(23)+DayExitTimeHour = input.int(23)-DayExitTimeMinute = input(04)+DayExitTimeMinute = input.int(04)-ExitOnFriday = input(true)+ExitOnFriday = input.bool(true)-FridayExitTimeHour = input(20)+FridayExitTimeHour = input.int(20)-FridayExitTimeMinute = input(40)+FridayExitTimeMinute = input.int(40)// }⋯// Open positions based on conditions {-strategy.order(id = "buy", direction = strategy.long, qty = 1, when = longCondition)+if longCondition+ strategy.order(id = "buy", direction = strategy.long, qty = 1)-strategy.order(id = "sell", direction = strategy.short, qty = 1, when = shortCondition)+if shortCondition+ strategy.order(id = "sell", direction = strategy.short, qty = 1)// }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: 9 before, 8 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.
⋯// © Revazi-//@version=5+//@version=6strategy("The Impeccable by zyberal", overlay = true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 31 ms | With a workaround 1,000 bars in 86 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 61, 62) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“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.
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/// © Revazi//@version=5strategy("The Impeccable by zyberal", overlay = true)// Inputs {// Strategy variablesIchimokuTenkanPeriod = input(9)IchimokuKijunPeriod = input(190)IchimokuSenkouPeriod = input(52)MACDMainFast = input(3)MACDMainSlow = input(10)MACDMainSmooth = input(9)ExitAfterBars = input(2)ProfitTarget = input(135)StopLoss = input(70)// Trading OptionsDontTradeOnWeekends = input(true)ExitAtEndOfDay = input(true)DayExitTimeHour = input(23)DayExitTimeMinute = input(04)ExitOnFriday = input(true)FridayExitTimeHour = input(20)FridayExitTimeMinute = input(40)// }// TRADING OPTIONS LOGIC {OpenOrdersAllowed = true// Dont trade on weekends {if DontTradeOnWeekends if dayofweek == dayofweek.saturday or dayofweek == dayofweek.sunday OpenOrdersAllowed := false// }// Exit on close (end of day) {if ExitAtEndOfDay if timeframe.isintraday and time >= timestamp(year(timenow), month(timenow), dayofmonth(timenow), DayExitTimeHour, DayExitTimeMinute) OpenOrdersAllowed := false// }// Exit on Friday {if ExitOnFriday if timeframe.isintraday and time >= timestamp(year(timenow), month(timenow), dayofmonth(timenow), FridayExitTimeHour, FridayExitTimeMinute) OpenOrdersAllowed := false// }// Rule: Trading signals {openW3 = request.security(syminfo.tickerid, "W", open)[3]middleDonchian(Length) => math.avg(ta.highest(Length), ta.lowest(Length))Tenkan = middleDonchian(IchimokuTenkanPeriod)[2][macdLine, signalLine, _] = ta.macd(close, MACDMainFast, MACDMainSlow, MACDMainSmooth)LongEntrySignal = openW3 > Tenkan and ta.crossunder(macdLine, signalLine)[3] //macdLine[3] < signalLine[3]ShortEntrySignal = openW3 < Tenkan and ta.crossover(macdLine, signalLine)[3] //macdLine[3] > signalLine[3]// }// Calculate conditions {IsFlat() => strategy.position_size == 0IsLong() => strategy.position_size > 0IsShort() => strategy.position_size < 0longCondition = OpenOrdersAllowed and not IsLong() and LongEntrySignalshortCondition = OpenOrdersAllowed and not IsShort() and ShortEntrySignal// }// Open positions based on conditions {strategy.order(id = "buy", direction = strategy.long, qty = 1, when = longCondition)strategy.order(id = "sell", direction = strategy.short, qty = 1, when = shortCondition)// }