Pine Script v4 · Strategy
BV's ICHIMOKU CLOUD - All Signals
A Pine Script v4 strategy built on Crossover (conversionLine, baseLine), Crossunder (conversionLine, baseLine) and ATR (14). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 9 settings; defaults include SIGNAL - Choose your signal Tenkan/Kijun, Conversion Line Periods 9 and Base Line Periods 26.
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 BV's ICHIMOKU CLOUD - All Signals repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 11 of 11 trades.
- How did BV's ICHIMOKU CLOUD - All Signals do on BTCUSDT 1D with default settings?
- −28.69%
- From 26 Jan 2024 to 21 Oct 2026, over 42 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can BV's ICHIMOKU CLOUD - All Signals 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 BV's ICHIMOKU CLOUD - All Signals use a stop loss?
- Yes
- strategy.exit sets a stop on line 78, 79.
- Does BV's ICHIMOKU CLOUD - All Signals run in Zeal Terminal?
- Yes
- It compiles in 15 ms and runs 1,000 bars in 59 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
- Net profit
- −28.69%
- −$28,693.20
- Buy and hold
- +102.5%
- same period
- Closed trades
- 42
- 13 won · 29 lost
- Profitable
- 31.0%
- of closed trades
- Profit factor
- 0.83
- gross profit ÷ gross loss
- Max drawdown
- 62.30%
- −$62,321.20
One run with the author's default settings, $100,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
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
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, crossover → ta.crossover, crossunder → ta.crossunder, atr → ta.atr.
v4 → v5
VerifiedSame 42 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 7: input(type = input.bool) → input.bool()
- Line 15: avg → math.avg
- Line 15: lowest → ta.lowest
- Line 15: highest → ta.highest
- Line 18: avg → math.avg
22 more edits
- Line 28: max → math.max
- Line 29: min → math.min
- Line 31: crossover → ta.crossover
- Line 32: crossover → ta.crossover
- Line 33: crossover → ta.crossover
- Line 34: crossover → ta.crossover
- Line 35: crossover → ta.crossover
- Line 36: crossover → ta.crossover
- Line 37: crossover → ta.crossover
- Line 38: crossover → ta.crossover
- Line 41: crossunder → ta.crossunder
- Line 42: crossunder → ta.crossunder
- Line 43: crossunder → ta.crossunder
- Line 44: crossunder → ta.crossunder
- Line 45: crossunder → ta.crossunder
- Line 46: crossunder → ta.crossunder
- Line 47: crossunder → ta.crossunder
- Line 48: crossunder → ta.crossunder
- Line 55: input(type = input.float) → input.float()
- Line 56: input(type = input.float) → input.float()
- Line 58: atr → ta.atr
- Line 64: input(type = input.integer) → input.int()
⋯// © vuagnouxb-//@version=4+//@version=5strategy("BV's ICHIMOKU CLOUD SIGNAL TESTER", overlay=true)⋯signalChoice = input(title = "SIGNAL - Choose your signal", defval = "Tenkan/Kijun", options = ["Tenkan/Kijun", "Tenkan/Kijun+Kumo", "Price/Tenkan", "Price/Tenkan+Kumo", "Price/Kijun", "Price/Kijun+Kumo", "Price/Kumo", "Kumo Color"])-JPYPair = input(type = input.bool, title = "ATR - Check if JPY Pair ", defval = false)+JPYPair = input.bool(title = "ATR - Check if JPY Pair ", defval = false)//------------------------------------------------------------------------⋯displacement = input(26, minval=1, title="Displacement")-donchian(len) => avg(lowest(len), highest(len))+donchian(len) => math.avg(ta.lowest(len), ta.highest(len))conversionLine = donchian(conversionPeriods)baseLine = donchian(basePeriods)-leadLine1 = avg(conversionLine, baseLine)+leadLine1 = math.avg(conversionLine, baseLine)leadLine2 = donchian(laggingSpan2Periods)⋯fill(p1, p2, color = leadLine1 > leadLine2 ? color.green : color.red)-kumoHigh = max(leadLine1[displacement-1], leadLine2[displacement-1])+kumoHigh = math.max(leadLine1[displacement-1], leadLine2[displacement-1])-kumoLow = min(leadLine1[displacement-1], leadLine2[displacement-1])+kumoLow = math.min(leadLine1[displacement-1], leadLine2[displacement-1])// -- Trade entry signals-continuationSignalLong = signalChoice == "Tenkan/Kijun" ? crossover(conversionLine, baseLine) :+continuationSignalLong = signalChoice == "Tenkan/Kijun" ? ta.crossover(conversionLine, baseLine) :- signalChoice == "Tenkan/Kijun+Kumo" ? crossover(conversionLine, baseLine) and close > kumoHigh : + signalChoice == "Tenkan/Kijun+Kumo" ? ta.crossover(conversionLine, baseLine) and close > kumoHigh : - signalChoice == "Price/Tenkan" ? crossover(close, conversionLine) : + signalChoice == "Price/Tenkan" ? ta.crossover(close, conversionLine) : - signalChoice == "Price/Tenkan+Kumo" ? crossover(close, conversionLine) and close > kumoHigh :+ signalChoice == "Price/Tenkan+Kumo" ? ta.crossover(close, conversionLine) and close > kumoHigh :- signalChoice == "Price/Kijun" ? crossover(close, baseLine) :+ signalChoice == "Price/Kijun" ? ta.crossover(close, baseLine) :- signalChoice == "Price/Kijun+Kumo" ? crossover(close, baseLine) and close > kumoHigh : + signalChoice == "Price/Kijun+Kumo" ? ta.crossover(close, baseLine) and close > kumoHigh : - signalChoice == "Price/Kumo" ? crossover(close, kumoHigh) :+ signalChoice == "Price/Kumo" ? ta.crossover(close, kumoHigh) :- signalChoice == "Kumo Color" ? crossover(leadLine1, leadLine2) :+ signalChoice == "Kumo Color" ? ta.crossover(leadLine1, leadLine2) : false -continuationSignalShort = signalChoice == "Tenkan/Kijun" ? crossunder(conversionLine, baseLine) :+continuationSignalShort = signalChoice == "Tenkan/Kijun" ? ta.crossunder(conversionLine, baseLine) :- signalChoice == "Tenkan/Kijun+Kumo" ? crossunder(conversionLine, baseLine) and close < kumoLow : + signalChoice == "Tenkan/Kijun+Kumo" ? ta.crossunder(conversionLine, baseLine) and close < kumoLow : - signalChoice == "Price/Tenkan" ? crossunder(close, conversionLine) : + signalChoice == "Price/Tenkan" ? ta.crossunder(close, conversionLine) : - signalChoice == "Price/Tenkan+Kumo" ? crossunder(close, conversionLine) and close < kumoLow :+ signalChoice == "Price/Tenkan+Kumo" ? ta.crossunder(close, conversionLine) and close < kumoLow :- signalChoice == "Price/Kijun" ? crossunder(close, baseLine) :+ signalChoice == "Price/Kijun" ? ta.crossunder(close, baseLine) :- signalChoice == "Price/Kijun+Kumo" ? crossunder(close, baseLine) and close < kumoLow : + signalChoice == "Price/Kijun+Kumo" ? ta.crossunder(close, baseLine) and close < kumoLow : - signalChoice == "Price/Kumo" ? crossunder(close, kumoLow) :+ signalChoice == "Price/Kumo" ? ta.crossunder(close, kumoLow) :- signalChoice == "Kumo Color" ? crossunder(leadLine1, leadLine2) :+ signalChoice == "Kumo Color" ? ta.crossunder(leadLine1, leadLine2) : false⋯//-------------------------------------------------------------------------SLmultiplier = input(title = "ATR - Stop Loss Multiplier", type = input.float, defval = 1.5, step = 0.1)+SLmultiplier = input.float(title = "ATR - Stop Loss Multiplier", defval = 1.5, step = 0.1)-TPmultiplier = input(title = "ATR - Take Profit Multiplier", type = input.float, defval = 1.0, step = 0.1)+TPmultiplier = input.float(title = "ATR - Take Profit Multiplier", defval = 1.0, step = 0.1)pipAdjuster = JPYPair ? 1000 : 100000-ATR = atr(14) * pipAdjuster // 1000 for jpy pairs : 100000+ATR = ta.atr(14) * pipAdjuster // 1000 for jpy pairs : 100000SL = ATR * SLmultiplier⋯//-------------------------------------------------------------------------YearOfTesting = input(title = "Time - How many years of testing ?" , type = input.integer, defval = 3)+YearOfTesting = input.int(title = "Time - How many years of testing ?" , defval = 3)_time = 2020 - YearOfTesting⋯Same 42 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.string()
- Line 11: input() → input.int()
- Line 12: input() → input.int()
- Line 13: input() → input.int()
- Line 14: input() → input.int()
⋯// Signal imputs -signalChoice = input(title = "SIGNAL - Choose your signal", defval = "Tenkan/Kijun", options = ["Tenkan/Kijun", "Tenkan/Kijun+Kumo", "Price/Tenkan", "Price/Tenkan+Kumo", "Price/Kijun", "Price/Kijun+Kumo", "Price/Kumo", "Kumo Color"])+signalChoice = input.string(title = "SIGNAL - Choose your signal", defval = "Tenkan/Kijun", options = ["Tenkan/Kijun", "Tenkan/Kijun+Kumo", "Price/Tenkan", "Price/Tenkan+Kumo", "Price/Kijun", "Price/Kijun+Kumo", "Price/Kumo", "Kumo Color"])JPYPair = input.bool(title = "ATR - Check if JPY Pair ", defval = false)⋯//-------------------------------------------------------------------------conversionPeriods = input(9, minval=1, title="Conversion Line Periods"),+conversionPeriods = input.int(9, minval=1, title="Conversion Line Periods"),-basePeriods = input(26, minval=1, title="Base Line Periods")+basePeriods = input.int(26, minval=1, title="Base Line Periods")-laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Periods"),+laggingSpan2Periods = input.int(52, minval=1, title="Lagging Span 2 Periods"),-displacement = input(26, minval=1, title="Displacement")+displacement = input.int(26, minval=1, title="Displacement")donchian(len) => math.avg(ta.lowest(len), ta.highest(len))⋯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: 42 before, 29 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.
⋯// © vuagnouxb-//@version=5+//@version=6strategy("BV's ICHIMOKU CLOUD SIGNAL TESTER", overlay=true)⋯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 |
|---|---|---|---|
| SIGNAL - Choose your signal | Tenkan/Kijun | string · options ["Tenkan/Kijun", "Tenkan/Kijun+Kumo", "Price/Tenkan", "Price/Tenkan+Kumo", "Price/Kijun", "Price/Kijun+Kumo", "Price/Kumo", "Kumo Color"] | continuationSignalLong continuationSignalShort |
| ATR - Check if JPY Pair | false | bool | pipAdjuster |
| Conversion Line Periods | 9 | int · min 1 | conversionLine |
| Base Line Periods | 26 | int · min 1 | baseLine |
| Lagging Span 2 Periods | 52 | int · min 1 | leadLine2 |
| Displacement | 26 | int · min 1 | Lead 1 Lead 2 kumoHigh kumoLow Lagging Span |
| ATR - Stop Loss Multiplier | 1.5 | float · step 0.1 | SL |
| ATR - Take Profit Multiplier | 1.0 | float · step 0.1 | TP |
| Time - How many years of testing ? | 3 | int (written input.integer) | _time |
What it calculates
- Crossover (
crossover,ta.crossoverin v5)conversionLine, baseLine · chosen by SIGNAL - Choose your signalcontinuationSignalLong · line 31 - Crossunder (
crossunder,ta.crossunderin v5)conversionLine, baseLine · chosen by SIGNAL - Choose your signalcontinuationSignalShort · line 41 - ATR (
atr,ta.atrin v5)14ATR · line 58
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 | (longCondition and timeFilter) | On | 71 |
| Open Short short | (shortCondition and timeFilter) | On | 73 |
| Exit ATR stop and limit | every bar | On | 78 |
| Exit ATR stop and limit | every bar | On | 79 |
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.
- 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 | −28.7% | +102.5% | 42 | 31% | 0.83 | 62.3% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −15.2% | +5.5% | 47 | 34% | 0.71 | 20.1% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.5% | +9.8% | 44 | 32% | 0.93 | 3.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.4% | +8.4% | 46 | 37% | 1.40 | 0.3% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.1% | +16.7% | 44 | 43% | 1.27 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 47 | 32% | 1.21 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.2% | +148.3% | 44 | 36% | 1.20 | 0.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.1% | +17.1% | 53 | 38% | 1.19 | 0.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 15 | 33% | −$24,421.50 |
| Sideways market | 16 | 31% | −$9,707.33 |
| Falling market | 11 | 27% | $5,435.60 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
75.8%
The 95th percentile of the worst drawdown when the same 42 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 47.5% to 75.8%; the tick is what actually happened, 53.5%. Order luck alone moves it this much.
All 42 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 26 Mar 2024 69,880.00 | 30 Mar 2024 69,850.50 | 4 | $29.47 |
| long | 30 Mar 2024 69,850.50 | 18 Apr 2024 61,277.40 | 19 | −$8,573.15 |
| short | 18 Apr 2024 61,277.40 | 12 May 2024 60,826.00 | 24 | $451.39 |
| long | 12 May 2024 60,826.00 | 17 Jun 2024 66,676.90 | 36 | $5,850.87 |
| short | 17 Jun 2024 66,676.90 | 17 Jul 2024 65,044.00 | 30 | $1,632.86 |
| long | 17 Jul 2024 65,044.00 | 8 Aug 2024 55,133.80 | 22 | −$9,910.24 |
| short | 8 Aug 2024 55,133.80 | 24 Aug 2024 64,037.20 | 16 | −$8,903.48 |
| long | 24 Aug 2024 64,037.20 | 5 Sep 2024 57,970.90 | 12 | −$6,066.34 |
| short | 5 Sep 2024 57,970.90 | 20 Sep 2024 62,948.00 | 15 | −$4,977.10 |
| long | 20 Sep 2024 62,948.00 | 11 Oct 2024 60,326.40 | 21 | −$2,621.60 |
| short | 11 Oct 2024 60,326.40 | 20 Oct 2024 68,378.00 | 9 | −$8,051.59 |
| long | 20 Oct 2024 68,378.00 | 27 Dec 2024 95,791.60 | 68 | $27,413.60 |
| short | 27 Dec 2024 95,791.60 | 23 Jan 2025 103,707.00 | 27 | −$7,915.06 |
| long | 23 Jan 2025 103,707.00 | 4 Feb 2025 101,329.00 | 12 | −$2,378.15 |
| short | 4 Feb 2025 101,329.00 | 29 Mar 2025 84,424.40 | 53 | $16,904.10 |
| long | 29 Mar 2025 84,424.40 | 7 Apr 2025 78,430.00 | 9 | −$5,994.38 |
| short | 7 Apr 2025 78,430.00 | 19 Apr 2025 84,474.70 | 12 | −$6,044.70 |
| long | 19 Apr 2025 84,474.70 | 6 Jun 2025 101,509.00 | 48 | $17,034.00 |
| short | 6 Jun 2025 101,509.00 | 16 Jun 2025 105,594.00 | 10 | −$4,085.33 |
| long | 16 Jun 2025 105,594.00 | 22 Jun 2025 102,120.00 | 6 | −$3,474.00 |
| short | 22 Jun 2025 102,120.00 | 3 Jul 2025 108,850.00 | 11 | −$6,729.57 |
| long | 3 Jul 2025 108,850.00 | 5 Aug 2025 115,055.00 | 33 | $6,205.44 |
| short | 5 Aug 2025 115,055.00 | 13 Aug 2025 120,134.00 | 8 | −$5,079.06 |
| long | 13 Aug 2025 120,134.00 | 24 Aug 2025 115,438.00 | 11 | −$4,696.03 |
| short | 24 Aug 2025 115,438.00 | 13 Sep 2025 116,029.00 | 20 | −$591.35 |
| long | 13 Sep 2025 116,029.00 | 28 Sep 2025 109,636.00 | 15 | −$6,393.56 |
| short | 28 Sep 2025 109,636.00 | 6 Oct 2025 123,482.00 | 8 | −$13,846.50 |
| long | 6 Oct 2025 123,482.00 | 16 Oct 2025 110,763.00 | 10 | −$12,719.00 |
| short | 16 Oct 2025 110,763.00 | 11 Dec 2025 92,015.40 | 56 | $18,747.90 |
| long | 11 Dec 2025 92,015.40 | 20 Dec 2025 88,136.90 | 9 | −$3,878.43 |
| short | 20 Dec 2025 88,136.90 | 6 Jan 2026 93,859.70 | 17 | −$5,722.76 |
| long | 6 Jan 2026 93,859.70 | 24 Jan 2026 89,600.30 | 18 | −$4,259.45 |
| short | 24 Jan 2026 89,600.30 | 4 Mar 2026 68,338.00 | 39 | $21,262.30 |
| long | 4 Mar 2026 68,338.00 | 28 Mar 2026 66,407.30 | 24 | −$1,930.73 |
| short | 28 Mar 2026 66,407.30 | 13 Apr 2026 70,741.60 | 16 | −$4,334.28 |
| long | 13 Apr 2026 70,741.60 | 23 May 2026 75,539.50 | 40 | $4,797.94 |
| short | 23 May 2026 75,539.50 | 12 Jul 2026 63,819.00 | 50 | $11,720.50 |
| long | 12 Jul 2026 63,819.00 | 2 Aug 2026 62,823.70 | 21 | −$995.36 |
| short | 2 Aug 2026 62,823.70 | 20 Aug 2026 69,334.80 | 18 | −$6,511.13 |
| long | 20 Aug 2026 69,334.80 | 17 Sep 2026 76,206.00 | 28 | $6,871.22 |
| short | 17 Sep 2026 76,206.00 | 25 Sep 2026 84,410.20 | 8 | −$8,204.24 |
| long | 25 Sep 2026 84,410.20 | 15 Oct 2026 81,682.00 | 20 | −$2,728.22 |
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 |
|---|---|---|---|---|---|
| BV's ICHIMOKU CLOUD - All Signals this page | — | v4 strategy | −28.7% | 42 | 62.3% |
| SOJA PIVOT by ParaBellum68 | atr | v4 strategy | +3.3% | 9 | 18.2% |
| Volatility System by EduardoMattje | atr | v5 strategy | +150.2% | 2 | 21.5% |
| ATR Stop Buy Strategy by phobo3s | atr | v4 strategy | No trades on this market | ||
| VBand Strategy by Saravanan_Ragavan | atr | v4 strategy | No trades on this market | ||
| Volatility Breakout Strategy [Angel Algo] by AngelAlgo | atr | v5 strategy | +3.1% | 18 | 3.6% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 15 ms | Yes 1,000 bars in 59 ms | Not measured |
| PineTS | No 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/// © vuagnouxb//@version=4strategy("BV's ICHIMOKU CLOUD SIGNAL TESTER", overlay=true)// Signal imputs signalChoice = input(title = "SIGNAL - Choose your signal", defval = "Tenkan/Kijun", options = ["Tenkan/Kijun", "Tenkan/Kijun+Kumo", "Price/Tenkan", "Price/Tenkan+Kumo", "Price/Kijun", "Price/Kijun+Kumo", "Price/Kumo", "Kumo Color"])JPYPair = input(type = input.bool, title = "ATR - Check if JPY Pair ", defval = false)//------------------------------------------------------------------------//---------- ICHIMOKU CLOUD Calculation ----------- INPUT//------------------------------------------------------------------------conversionPeriods = input(9, minval=1, title="Conversion Line Periods"),basePeriods = input(26, minval=1, title="Base Line Periods")laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Periods"),displacement = input(26, minval=1, title="Displacement")donchian(len) => avg(lowest(len), highest(len))conversionLine = donchian(conversionPeriods)baseLine = donchian(basePeriods)leadLine1 = avg(conversionLine, baseLine)leadLine2 = donchian(laggingSpan2Periods)plot(conversionLine, color=#0496ff, title="Conversion Line")plot(baseLine, color=#991515, title="Base Line")plot(close, offset = -displacement + 1, color=#459915, title="Lagging Span")p1 = plot(leadLine1, offset = displacement - 1, color=color.green, title="Lead 1")p2 = plot(leadLine2, offset = displacement - 1, color=color.red, title="Lead 2")fill(p1, p2, color = leadLine1 > leadLine2 ? color.green : color.red)kumoHigh = max(leadLine1[displacement-1], leadLine2[displacement-1])kumoLow = min(leadLine1[displacement-1], leadLine2[displacement-1])// -- Trade entry signalscontinuationSignalLong = signalChoice == "Tenkan/Kijun" ? crossover(conversionLine, baseLine) : signalChoice == "Tenkan/Kijun+Kumo" ? crossover(conversionLine, baseLine) and close > kumoHigh : signalChoice == "Price/Tenkan" ? crossover(close, conversionLine) : signalChoice == "Price/Tenkan+Kumo" ? crossover(close, conversionLine) and close > kumoHigh : signalChoice == "Price/Kijun" ? crossover(close, baseLine) : signalChoice == "Price/Kijun+Kumo" ? crossover(close, baseLine) and close > kumoHigh : signalChoice == "Price/Kumo" ? crossover(close, kumoHigh) : signalChoice == "Kumo Color" ? crossover(leadLine1, leadLine2) : false continuationSignalShort = signalChoice == "Tenkan/Kijun" ? crossunder(conversionLine, baseLine) : signalChoice == "Tenkan/Kijun+Kumo" ? crossunder(conversionLine, baseLine) and close < kumoLow : signalChoice == "Price/Tenkan" ? crossunder(close, conversionLine) : signalChoice == "Price/Tenkan+Kumo" ? crossunder(close, conversionLine) and close < kumoLow : signalChoice == "Price/Kijun" ? crossunder(close, baseLine) : signalChoice == "Price/Kijun+Kumo" ? crossunder(close, baseLine) and close < kumoLow : signalChoice == "Price/Kumo" ? crossunder(close, kumoLow) : signalChoice == "Kumo Color" ? crossunder(leadLine1, leadLine2) : falselongCondition = continuationSignalLongshortCondition = continuationSignalShort//------------------------------------------------------------------------//---------- ATR MONEY MANAGEMENT ------------//------------------------------------------------------------------------SLmultiplier = input(title = "ATR - Stop Loss Multiplier", type = input.float, defval = 1.5, step = 0.1)TPmultiplier = input(title = "ATR - Take Profit Multiplier", type = input.float, defval = 1.0, step = 0.1)pipAdjuster = JPYPair ? 1000 : 100000ATR = atr(14) * pipAdjuster // 1000 for jpy pairs : 100000SL = ATR * SLmultiplierTP = ATR * TPmultiplier//------------------------------------------------------------------------//---------- TIME FILTER ------------//------------------------------------------------------------------------YearOfTesting = input(title = "Time - How many years of testing ?" , type = input.integer, defval = 3)_time = 2020 - YearOfTestingtimeFilter = (year > _time) //------------------------------------------------------------------------//--------- ENTRY FUNCTIONS ----------- INPUT//------------------------------------------------------------------------if (longCondition and timeFilter) strategy.entry("Long", strategy.long)if (shortCondition and timeFilter) strategy.entry("Short", strategy.short) //------------------------------------------------------------------------//--------- EXIT FUNCTIONS -----------//------------------------------------------------------------------------strategy.exit("ATR", from_entry = "Long", profit = TP, loss = SL) strategy.exit("ATR", from_entry = "Short", profit = TP, loss = SL)