Zeal Terminal Open in Zeal Terminal

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
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (9)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$68,283$202,527Equity from $100,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
−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

Verified

Same 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⋯

Clean v5

VerifiedDownload the v5 script

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.

SettingDefaultType and rangeFeeds
SIGNAL - Choose your signalTenkan/Kijunstring · 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 falseboolpipAdjuster
Conversion Line Periods9int · min 1conversionLine
Base Line Periods26int · min 1baseLine
Lagging Span 2 Periods52int · min 1leadLine2
Displacement26int · min 1Lead 1 Lead 2 kumoHigh kumoLow Lagging Span
ATR - Stop Loss Multiplier1.5float · step 0.1SL
ATR - Take Profit Multiplier1.0float · step 0.1TP
Time - How many years of testing ?3int (written input.integer)_time

What it calculates

  • Crossover (crossover, ta.crossover in v5)conversionLine, baseLine · chosen by SIGNAL - Choose your signalcontinuationSignalLong · line 31
  • Crossunder (crossunder, ta.crossunder in v5)conversionLine, baseLine · chosen by SIGNAL - Choose your signalcontinuationSignalShort · line 41
  • ATR (atr, ta.atr in 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.

closecloseprice datasignalChoiceSIGNAL - Choose your si…setting · Tenkan/Kijunhigh · low · closehigh · low · closeprice dataconversionPeriodsConversion Line Periodssetting · 9basePeriodsBase Line Periodssetting · 26laggingSpan2PeriodsLagging Span 2 Periodssetting · 52displacementDisplacementsetting · 26SLmultiplierATR - Stop Loss Multipl…setting · 1.5TPmultiplierATR - Take Profit Multi…setting · 1.0YearOfTestingTime - How many years o…setting · 3continuationSignalLongCrossover→ continuationSignalLong · by…continuationSignalShortCrossunder→ continuationSignalShort · b…ATRATR→ ATRconversionLineconversionLinevaluebaseLinebaseLinevalueleadLine1leadLine1valueleadLine2leadLine2valuekumoHigh, kumoLowkumoHigh · kumoLow2 valueslongConditionlongConditionvalueshortConditionshortConditionvaluepipAdjusterpipAdjustervalueSLSLvalueTPTPvalue_time_timevaluetimeFiltertimeFilterconditionentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryexit:ATRexit ATRstrategy.exitplot:20Conversion Lineplotplot:21Base Lineplotplot:22Lagging Spanplotplot:23Lead 1plotplot:25Lead 2plotfill:27Fillfill

Order rules

OrderFires whenBy defaultLine
Open Long long(longCondition and timeFilter)On71
Open Short short(shortCondition and timeFilter)On73
Exit ATR stop and limitevery barOn78
Exit ATR stop and limitevery barOn79

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.

11/11trades 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−28.7%+102.5%4231%0.8362.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−15.2%+5.5%4734%0.7120.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.5%+9.8%4432%0.933.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.4%+8.4%4637%1.400.3%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.1%+16.7%4443%1.270.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%4732%1.210.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.2%+148.3%4436%1.200.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.1%+17.1%5338%1.190.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 market1533%−$24,421.50
Sideways market1631%−$9,707.33
Falling market1127%$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.

0%87%
All 42 trades
SideEntryExitBarsP&L
short26 Mar 2024 69,880.0030 Mar 2024 69,850.504$29.47
long30 Mar 2024 69,850.5018 Apr 2024 61,277.4019−$8,573.15
short18 Apr 2024 61,277.4012 May 2024 60,826.0024$451.39
long12 May 2024 60,826.0017 Jun 2024 66,676.9036$5,850.87
short17 Jun 2024 66,676.9017 Jul 2024 65,044.0030$1,632.86
long17 Jul 2024 65,044.008 Aug 2024 55,133.8022−$9,910.24
short8 Aug 2024 55,133.8024 Aug 2024 64,037.2016−$8,903.48
long24 Aug 2024 64,037.205 Sep 2024 57,970.9012−$6,066.34
short5 Sep 2024 57,970.9020 Sep 2024 62,948.0015−$4,977.10
long20 Sep 2024 62,948.0011 Oct 2024 60,326.4021−$2,621.60
short11 Oct 2024 60,326.4020 Oct 2024 68,378.009−$8,051.59
long20 Oct 2024 68,378.0027 Dec 2024 95,791.6068$27,413.60
short27 Dec 2024 95,791.6023 Jan 2025 103,707.0027−$7,915.06
long23 Jan 2025 103,707.004 Feb 2025 101,329.0012−$2,378.15
short4 Feb 2025 101,329.0029 Mar 2025 84,424.4053$16,904.10
long29 Mar 2025 84,424.407 Apr 2025 78,430.009−$5,994.38
short7 Apr 2025 78,430.0019 Apr 2025 84,474.7012−$6,044.70
long19 Apr 2025 84,474.706 Jun 2025 101,509.0048$17,034.00
short6 Jun 2025 101,509.0016 Jun 2025 105,594.0010−$4,085.33
long16 Jun 2025 105,594.0022 Jun 2025 102,120.006−$3,474.00
short22 Jun 2025 102,120.003 Jul 2025 108,850.0011−$6,729.57
long3 Jul 2025 108,850.005 Aug 2025 115,055.0033$6,205.44
short5 Aug 2025 115,055.0013 Aug 2025 120,134.008−$5,079.06
long13 Aug 2025 120,134.0024 Aug 2025 115,438.0011−$4,696.03
short24 Aug 2025 115,438.0013 Sep 2025 116,029.0020−$591.35
long13 Sep 2025 116,029.0028 Sep 2025 109,636.0015−$6,393.56
short28 Sep 2025 109,636.006 Oct 2025 123,482.008−$13,846.50
long6 Oct 2025 123,482.0016 Oct 2025 110,763.0010−$12,719.00
short16 Oct 2025 110,763.0011 Dec 2025 92,015.4056$18,747.90
long11 Dec 2025 92,015.4020 Dec 2025 88,136.909−$3,878.43
short20 Dec 2025 88,136.906 Jan 2026 93,859.7017−$5,722.76
long6 Jan 2026 93,859.7024 Jan 2026 89,600.3018−$4,259.45
short24 Jan 2026 89,600.304 Mar 2026 68,338.0039$21,262.30
long4 Mar 2026 68,338.0028 Mar 2026 66,407.3024−$1,930.73
short28 Mar 2026 66,407.3013 Apr 2026 70,741.6016−$4,334.28
long13 Apr 2026 70,741.6023 May 2026 75,539.5040$4,797.94
short23 May 2026 75,539.5012 Jul 2026 63,819.0050$11,720.50
long12 Jul 2026 63,819.002 Aug 2026 62,823.7021−$995.36
short2 Aug 2026 62,823.7020 Aug 2026 69,334.8018−$6,511.13
long20 Aug 2026 69,334.8017 Sep 2026 76,206.0028$6,871.22
short17 Sep 2026 76,206.0025 Sep 2026 84,410.208−$8,204.24
long25 Sep 2026 84,410.2015 Oct 2026 81,682.0020−$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.

ScriptSharesTypeNetTradesMax drawdown
BV's ICHIMOKU CLOUD - All Signals this page—v4 strategy−28.7%4262.3%
SOJA PIVOT by ParaBellum68atrv4 strategy+3.3%918.2%
Volatility System by EduardoMattjeatrv5 strategy+150.2%221.5%
ATR Stop Buy Strategy by phobo3satrv4 strategyNo trades on this market
VBand Strategy by Saravanan_Ragavanatrv4 strategyNo trades on this market
Volatility Breakout Strategy [Angel Algo] by AngelAlgoatrv5 strategy+3.1%183.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 15 msYes 1,000 bars in 59 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/// © 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)