Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Donchian Channel Strategy [for free bot]

A Pine Script v4 strategy built on Highest (10), Highest or Lowest (10) and Lowest (20). It has 6 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 commits 20% of equity and pays 0.036% commission. 16 settings; defaults include Channel Period for Long enter position 10, Channel Period for Long exit position 10 and Take Profit (%) for Long position 2.5.

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 Donchian Channel Strategy [for free bot] repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 33 of 33 trades.
How did Donchian Channel Strategy [for free bot] do on BTCUSDT 1D with default settings?
−9.43%
From 26 Jan 2024 to 21 Oct 2026, over 128 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Donchian Channel Strategy [for free bot] 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 Donchian Channel Strategy [for free bot] use a stop loss?
Yes
strategy.exit sets a stop on line 51, 56.
Does Donchian Channel Strategy [for free bot] run in Zeal Terminal?
Yes
It compiles in 19 ms and runs 1,000 bars in 50 ms, in the browser.

BTCUSDT · 1D · default settings

  • Buy Enter
  • Buy Exit
  • Sell Enter
  • Sell Exit
  • 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 (16)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$906$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
−9.43%
−$94.26
Buy and hold
+102.5%
same period
Closed trades
128
71 won · 57 lost
Profitable
55.5%
of closed trades
Profit factor
0.80
gross profit ÷ gross loss
Max drawdown
12.51%
−$125.11

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.

  • 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 49, 51, 54, 56. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 36

    transp = on line 36, 38. 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.
  • 4 strategy calls use the when = argument (line 49, 51, 54, 56). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 4: //@version=4 → //@version=5
  • Line 30: highest → ta.highest
  • Line 31: highest → ta.highest
  • Line 31: lowest → ta.lowest
  • Line 31: lowest → ta.lowest
  • Line 32: lowest → ta.lowest
5 more edits
  • Line 33: highest → ta.highest
  • Line 33: lowest → ta.lowest
  • Line 33: highest → ta.highest
  • Line 36: transp = 50 → color.new(color.blue, 50)
  • Line 38: transp = 50 → color.new(color.red, 50)
⋯// Strategy testing and optimisation for free trading bot -//@version=4+//@version=5strategy("Donchian Channel Strategy [for free bot]", overlay=true, default_qty_type= strategy.percent_of_equity, initial_capital = 1000, default_qty_value = 20, commission_type=strategy.commission.percent, commission_value=0.036)⋯// Long&Short Levels-BuyEnter = highest(buyPeriodEnter)+BuyEnter = ta.highest(buyPeriodEnter)-BuyExit = isMiddleBuy ? ((highest(buyPeriodExit) + lowest(buyPeriodExit)) / 2): lowest(buyPeriodExit)+BuyExit = isMiddleBuy ? ((ta.highest(buyPeriodExit) + ta.lowest(buyPeriodExit)) / 2): ta.lowest(buyPeriodExit)-SellEnter = lowest(sellPeriodEnter)+SellEnter = ta.lowest(sellPeriodEnter)-SellExit = isMiddleSell ? ((highest(sellPeriodExit) + lowest(sellPeriodExit)) / 2): highest(sellPeriodExit)+SellExit = isMiddleSell ? ((ta.highest(sellPeriodExit) + ta.lowest(sellPeriodExit)) / 2): ta.highest(sellPeriodExit)// Plot Dataplot(BuyEnter, style=plot.style_line, linewidth=2, color=color.blue, title="Buy Enter")-plot(BuyExit, style=plot.style_line, linewidth=1, color=color.blue, title="Buy Exit", transp=50)+plot(BuyExit, style=plot.style_line, linewidth=1, color=color.new(color.blue, 50), title="Buy Exit")plot(SellEnter, style=plot.style_line, linewidth=2, color=color.red, title="Sell Enter")-plot(SellExit, style=plot.style_line, linewidth=1, color=color.red, title="Sell Exit", transp=50)+plot(SellExit, style=plot.style_line, linewidth=1, color=color.new(color.red, 50), title="Sell Exit")// Calc Take Profits⋯

Clean v5

VerifiedDownload the v5 script

Same 128 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.bool()
  • Line 10: input() → input.float()
  • Line 11: input() → input.bool()
  • Line 13: input() → input.int()
14 more edits
  • Line 14: input() → input.int()
  • Line 15: input() → input.bool()
  • Line 16: input() → input.float()
  • Line 17: input() → input.bool()
  • Line 19: input() → input.int()
  • Line 20: input() → input.int()
  • Line 21: input() → input.int()
  • Line 24: input() → input.int()
  • Line 25: input() → input.int()
  • Line 26: input() → input.int()
  • Line 49: when = strategy.position_size == 0 → if block
  • Line 51: when = strategy.position_size > 0 → if block
  • Line 54: when = strategy.position_size == 0 → if block
  • Line 56: when = strategy.position_size < 0 → if block
⋯//Long optopns-buyPeriodEnter = input(10, "Channel Period for Long enter position")+buyPeriodEnter = input.int(10, "Channel Period for Long enter position")-buyPeriodExit = input(10, "Channel Period for Long exit position")+buyPeriodExit = input.int(10, "Channel Period for Long exit position")-isMiddleBuy = input(true, "Is exit on Base Line? If 'no' - exit on bottom line")+isMiddleBuy = input.bool(true, "Is exit on Base Line? If 'no' - exit on bottom line")-takeProfitBuy = input(2.5, "Take Profit (%) for Long position")+takeProfitBuy = input.float(2.5, "Take Profit (%) for Long position")-isBuy = input(true, "Allow Long?")+isBuy = input.bool(true, "Allow Long?")//Short Options-sellPeriodEnter = input(20, "Channel Period for Short enter position")+sellPeriodEnter = input.int(20, "Channel Period for Short enter position")-sellPeriodExit = input(20, "Channel Period for Short exit position")+sellPeriodExit = input.int(20, "Channel Period for Short exit position")-isMiddleSell = input(true, "Is exit on Base Line? If 'no' - exit on upper line")+isMiddleSell = input.bool(true, "Is exit on Base Line? If 'no' - exit on upper line")-takeProfitSell = input(2.5, "Take Profit (%) for Short position")+takeProfitSell = input.float(2.5, "Take Profit (%) for Short position")-isSell = input(true, "Allow Short?")+isSell = input.bool(true, "Allow Short?")// Test Start-startYear = input(2005, "Test Start Year")+startYear = input.int(2005, "Test Start Year")-startMonth = input(1, "Test Start Month")+startMonth = input.int(1, "Test Start Month")-startDay = input(1, "Test Start Day")+startDay = input.int(1, "Test Start Day")startTest = timestamp(startYear,startMonth,startDay,0,0)//Test End-endYear = input(2050, "Test End Year")+endYear = input.int(2050, "Test End Year")-endMonth = input(12, "Test End Month")+endMonth = input.int(12, "Test End Month")-endDay = input(30, "Test End Day")+endDay = input.int(30, "Test End Day")endTest = timestamp(endYear,endMonth,endDay,23,59)⋯if isBuy and timeRange-    strategy.entry("Long", strategy.long, stop = BuyEnter, when = strategy.position_size == 0) +    if strategy.position_size == 0+        strategy.entry("Long", strategy.long, stop = BuyEnter)     -strategy.exit("Long Exit", "Long", stop=BuyExit, limit = TakeProfitBuy, when = strategy.position_size > 0)+if strategy.position_size > 0+    strategy.exit("Long Exit", "Long", stop=BuyExit, limit = TakeProfitBuy)// Short Positionif isSell and timeRange-    strategy.entry("Short", strategy.short, stop = SellEnter, when = strategy.position_size == 0) +    if strategy.position_size == 0+        strategy.entry("Short", strategy.short, stop = SellEnter)     -strategy.exit("Short Exit", "Short", stop=SellExit, limit = TakeProfitSell, when = strategy.position_size < 0)+if strategy.position_size < 0+    strategy.exit("Short Exit", "Short", stop=SellExit, limit = TakeProfitSell)// Close & Cancel when over End of the Test⋯

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

⋯// Strategy testing and optimisation for free trading bot -//@version=5+//@version=6strategy("Donchian Channel Strategy [for free bot]", overlay=true, default_qty_type= strategy.percent_of_equity, initial_capital = 1000, default_qty_value = 20, commission_type=strategy.commission.percent, commission_value=0.036)⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Channel Period for Long enter position10intBuyEnter
Channel Period for Long exit position10intBuyExit
Is exit on Base Line? If 'no' - exit on bottom linetrueboolBuyExit
Take Profit (%) for Long position2.5floatTakeProfitBuy
Allow Long?trueboolentry Long line 48
Channel Period for Short enter position20intSellEnter
Channel Period for Short exit position20intSellExit
Is exit on Base Line? If 'no' - exit on upper linetrueboolSellExit
Take Profit (%) for Short position2.5floatTakeProfitSell
Allow Short?trueboolentry Short line 53
Test Start Year2005intstartTest
Test Start Month1intstartTest
Test Start Day1intstartTest
Test End Year2050intendTest
Test End Month12intendTest
Test End Day30intendTest

What it calculates

  • Highest (highest, ta.highest in v5)Channel Period for Long enter position (10)BuyEnter · line 30
  • Highest / Lowest (highest, ta.highest in v5)Channel Period for Long exit position (10)BuyExit · line 31
  • Lowest (lowest, ta.lowest in v5)Channel Period for Short enter position (20)SellEnter · line 32
  • Highest / Lowest (highest, ta.highest in v5)Channel Period for Short exit position (20)SellExit · line 33

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.

buyPeriodEnterChannel Period for Long…setting · 10buyPeriodExitChannel Period for Long…setting · 10sellPeriodEnterChannel Period for Shor…setting · 20sellPeriodExitChannel Period for Shor…setting · 20startYearTest Start Yearsetting · 2005startMonthTest Start Monthsetting · 1startDayTest Start Daysetting · 1endYearTest End Yearsetting · 2050endMonthTest End Monthsetting · 12endDayTest End Daysetting · 30timetimeprice datatakeProfitBuyTake Profit (%) for Lon…setting · 2.5takeProfitSellTake Profit (%) for Sho…setting · 2.5BuyEnterHighest→ BuyEnterBuyExitHighest / Lowest→ BuyExitSellEnterLowest→ SellEnterSellExitHighest / Lowest→ SellExitstartTeststartTestvalueendTestendTestvaluetimeRangetimeRangevalueTakeProfitBuyTakeProfitBuyvalueTakeProfitSellTakeProfitSellvalueentry:LongOpen Longstrategy.entryexit:Long Exitexit Long Exitstrategy.exitentry:ShortOpen Shortstrategy.entryexit:Short Exitexit Short Exitstrategy.exitclose_all:close_all strategy.close_allcancel_all:cancel_all strategy.cancel_allplot:35Buy Enterplotplot:36Buy Exitplotplot:37Sell Enterplotplot:38Sell Exitplot

Order rules

OrderFires whenBy defaultLine
Open Long longstrategy.position_size == 0On49
Exit Long Exit stop and limitstrategy.position_size > 0On51
Open Short shortstrategy.position_size == 0On54
Exit Short Exit stop and limitstrategy.position_size < 0On56
Close time > endTestOn59
cancel_all time > endTestOn60

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.

33/33trades 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−9.4%+102.5%12855%0.8012.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.9%+5.5%9332%1.072.5%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+4.2%+9.8%13368%1.0810.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−2.7%+8.4%10738%0.874.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−5.4%+16.7%14172%0.9121.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−4.3%+21.5%11241%0.845.6%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+5.1%+148.3%12565%1.129.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−1.8%+17.1%10133%0.893.5%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 market4549%−$73.63
Sideways market6156%−$18.05
Falling market2268%−$2.57

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

How bad could the drawdown be?

18.4%

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

0%21%
All 128 trades
SideEntryExitBarsP&L
long27 Jan 2024 41,823.5027 Jan 2024 41,823.500−$0.14
short27 Jan 2024 41,823.5015 Feb 2024 51,795.2019−$47.83
long20 Feb 2024 52,816.6023 Feb 2024 50,643.003−$7.97
long26 Feb 2024 52,985.0027 Feb 2024 54,476.501$5.18
long28 Feb 2024 57,588.2029 Feb 2024 62,432.101$15.82
long4 Mar 2024 64,000.005 Mar 2024 68,245.701$12.66
long8 Mar 2024 69,000.0011 Mar 2024 70,725.003$4.74
long12 Mar 2024 72,800.0015 Mar 2024 66,391.003−$17.43
long26 Mar 2024 71,150.002 Apr 2024 67,384.807−$10.35
long8 Apr 2024 71,366.009 Apr 2024 68,645.501−$7.41
short13 Apr 2024 63,772.3014 Apr 2024 62,178.001$4.60
short17 Apr 2024 60,660.6022 Apr 2024 66,199.005−$17.52
short30 Apr 2024 59,600.001 May 2024 58,110.001$4.54
long6 May 2024 64,820.008 May 2024 61,026.402−$11.12
long15 May 2024 65,500.0017 May 2024 67,137.502$4.50
long19 May 2024 67,451.2020 May 2024 69,137.501$4.52
long21 May 2024 71,515.6023 May 2024 66,364.102−$13.62
long4 Jun 2024 70,687.607 Jun 2024 69,214.003−$3.98
short11 Jun 2024 66,312.2012 Jun 2024 69,024.001−$7.65
short14 Jun 2024 66,051.0018 Jun 2024 64,399.704$4.43
short21 Jun 2024 64,060.0024 Jun 2024 62,458.503$4.45
short4 Jul 2024 58,402.005 Jul 2024 56,941.901$4.47
long14 Jul 2024 60,498.2015 Jul 2024 62,010.701$4.49
long16 Jul 2024 64,900.0019 Jul 2024 66,522.503$4.51
long20 Jul 2024 67,386.0025 Jul 2024 64,553.405−$7.98
long27 Jul 2024 68,474.6030 Jul 2024 66,768.303−$4.74
short4 Aug 2024 59,850.005 Aug 2024 58,161.001$5.07
long23 Aug 2024 61,820.9024 Aug 2024 64,037.201$6.50
long25 Aug 2024 64,955.0027 Aug 2024 61,393.702−$10.35
short4 Sep 2024 56,078.506 Sep 2024 54,676.602$4.48
long13 Sep 2024 59,809.7017 Sep 2024 61,304.904$4.50
long18 Sep 2024 61,320.0019 Sep 2024 62,853.001$4.52
long20 Sep 2024 63,850.0026 Sep 2024 65,446.306$4.54
long27 Sep 2024 65,839.0030 Sep 2024 64,424.003−$4.17
short10 Oct 2024 59,828.1011 Oct 2024 62,722.001−$9.19
long14 Oct 2024 64,478.2015 Oct 2024 66,090.101$4.50
long16 Oct 2024 67,950.0023 Oct 2024 65,784.807−$6.07
long28 Oct 2024 69,519.5029 Oct 2024 71,257.501$4.49
long6 Nov 2024 73,620.107 Nov 2024 75,572.001$4.79
long8 Nov 2024 76,850.0010 Nov 2024 78,771.202$4.54
long11 Nov 2024 81,500.0012 Nov 2024 88,648.001$16.33
long13 Nov 2024 89,940.0018 Nov 2024 92,188.505$4.64
long19 Nov 2024 93,265.6021 Nov 2024 95,597.302$4.66
long22 Nov 2024 98,988.0025 Nov 2024 93,330.703−$11.16
long4 Dec 2024 98,871.805 Dec 2024 101,344.001$4.63
long15 Dec 2024 104,088.0016 Dec 2024 106,690.001$4.65
long17 Dec 2024 107,793.0018 Dec 2024 101,252.001−$11.82
short30 Dec 2024 92,232.506 Jan 2025 99,941.707−$16.04
long6 Jan 2025 99,963.707 Jan 2025 102,463.001$4.62
short9 Jan 2025 91,530.4014 Jan 2025 95,990.505−$9.29
long17 Jan 2025 102,724.0019 Jan 2025 105,292.002$4.52
long20 Jan 2025 106,422.0026 Jan 2025 103,462.006−$5.33
short3 Feb 2025 94,346.204 Feb 2025 101,329.001−$13.89
long21 Feb 2025 98,826.0022 Feb 2025 96,182.001−$5.03
short24 Feb 2025 93,388.1025 Feb 2025 91,053.401$4.42
short26 Feb 2025 86,051.0027 Feb 2025 83,899.701$4.44
short28 Feb 2025 82,256.002 Mar 2025 88,866.802−$14.91
short10 Mar 2025 78,258.5019 Mar 2025 85,803.009−$17.57
long20 Mar 2025 87,000.0022 Mar 2025 83,696.802−$6.86
long24 Mar 2025 87,453.7028 Mar 2025 84,950.004−$5.16
short6 Apr 2025 81,134.707 Apr 2025 78,430.001$5.71
long13 Apr 2025 85,905.0021 Apr 2025 88,052.608$4.27
long22 Apr 2025 88,466.0023 Apr 2025 93,443.001$9.82
long25 Apr 2025 94,696.101 May 2025 97,063.506$4.34
long2 May 2025 97,424.004 May 2025 94,777.802−$5.01
long8 May 2025 97,895.709 May 2025 103,262.001$9.67
long10 May 2025 104,361.0019 May 2025 106,970.009$4.39
long20 May 2025 107,109.0021 May 2025 109,786.001$4.41
long22 May 2025 110,797.0025 May 2025 106,682.003−$6.91
short5 Jun 2025 102,000.008 Jun 2025 106,176.003−$7.55
long9 Jun 2025 106,795.0010 Jun 2025 110,263.001$5.70
short22 Jun 2025 100,372.0023 Jun 2025 104,365.001−$7.32
long29 Jun 2025 108,272.004 Jul 2025 107,576.005−$1.28
long9 Jul 2025 110,529.0010 Jul 2025 113,292.001$4.34
long11 Jul 2025 116,868.0014 Jul 2025 119,790.003$4.37
short1 Aug 2025 114,723.007 Aug 2025 116,370.006−$2.73
long10 Aug 2025 118,922.0011 Aug 2025 121,896.001$4.37
long13 Aug 2025 122,335.0014 Aug 2025 118,159.001−$6.31
short22 Aug 2025 111,920.0026 Aug 2025 109,122.004$4.37
short29 Aug 2025 108,667.005 Sep 2025 112,915.007−$7.20
long10 Sep 2025 113,385.0012 Sep 2025 116,219.002$4.35
long15 Sep 2025 116,666.0021 Sep 2025 115,665.006−$1.67
short25 Sep 2025 109,977.0029 Sep 2025 113,260.004−$5.50
long1 Oct 2025 115,819.002 Oct 2025 118,715.001$4.34
long3 Oct 2025 121,022.005 Oct 2025 124,048.002$4.36
long6 Oct 2025 125,708.0010 Oct 2025 119,428.004−$9.14
short10 Oct 2025 108,620.0012 Oct 2025 114,100.002−$9.24
long26 Oct 2025 114,000.0029 Oct 2025 111,252.003−$4.39
short4 Nov 2025 103,528.005 Nov 2025 100,940.001$4.27
short13 Nov 2025 98,944.4014 Nov 2025 96,470.801$4.29
short16 Nov 2025 94,012.4017 Nov 2025 91,662.101$4.31
short18 Nov 2025 91,220.0019 Nov 2025 88,939.501$4.33
short20 Nov 2025 88,608.0021 Nov 2025 86,392.801$4.36
long3 Dec 2025 93,092.005 Dec 2025 88,986.402−$8.07
long9 Dec 2025 94,150.0012 Dec 2025 90,386.703−$7.26
long2 Jan 2026 90,406.105 Jan 2026 92,666.203$4.30
long13 Jan 2026 94,789.1014 Jan 2026 97,158.801$4.32
short21 Jan 2026 87,550.4029 Jan 2026 85,361.708$4.34
short30 Jan 2026 83,383.3031 Jan 2026 81,298.701$4.37
short1 Feb 2026 75,719.903 Feb 2026 73,826.902$4.39
short4 Feb 2026 72,945.505 Feb 2026 71,121.901$4.41
short6 Feb 2026 62,345.0025 Feb 2026 66,670.6019−$12.79
long2 Mar 2026 69,988.803 Mar 2026 66,303.101−$9.59
long4 Mar 2026 70,096.005 Mar 2026 72,666.801$6.39
long16 Mar 2026 73,913.7017 Mar 2026 75,761.601$4.35
short27 Mar 2026 65,618.507 Apr 2026 69,836.2011−$11.70
long8 Apr 2026 72,761.0013 Apr 2026 74,580.005$4.31
long14 Apr 2026 74,900.0017 Apr 2026 76,772.503$4.33
long22 Apr 2026 78,333.0027 Apr 2026 76,598.605−$4.10
long4 May 2026 79,485.705 May 2026 81,472.801$4.33
long6 May 2026 81,791.5012 May 2026 80,445.006−$3.08
short22 May 2026 76,051.0028 May 2026 74,149.706$4.34
short29 May 2026 72,582.801 Jun 2026 70,768.203$4.36
short2 Jun 2026 70,686.703 Jun 2026 66,760.801$9.90
short4 Jun 2026 64,092.505 Jun 2026 62,490.201$4.43
long14 Jun 2026 64,764.3015 Jun 2026 66,383.401$4.45
short24 Jun 2026 59,130.903 Jul 2026 62,546.209−$10.78
long4 Jul 2026 63,239.1013 Jul 2026 62,974.409−$0.89
long14 Jul 2026 64,700.0017 Jul 2026 63,572.303−$3.30
long20 Jul 2026 65,600.0024 Jul 2026 64,614.204−$2.85
long9 Aug 2026 65,409.6010 Aug 2026 63,874.701−$4.37
long19 Aug 2026 65,474.5020 Aug 2026 69,334.801$10.47
long21 Aug 2026 73,400.0022 Aug 2026 78,338.001$12.11
long24 Aug 2026 79,500.001 Sep 2026 78,512.308−$2.42
long3 Sep 2026 81,478.904 Sep 2026 79,282.001−$5.09
short15 Sep 2026 76,046.6018 Sep 2026 78,634.003−$6.36
long18 Sep 2026 80,560.0021 Sep 2026 82,574.003$4.44
short15 Oct 2026 80,393.6021 Oct 2026 83,510.006−$7.21

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
Donchian Channel Strategy [for free bot] this page—v4 strategy−9.4%12812.5%
Alex Days HiLo Rajib by 14rajibhighest lowestv4 strategyNo trades on this market
Donchian Strat EXMO by pskoroplashighest lowestv4 strategy+12.1%2268.0%
Average Highest High and Lowest Low Swinger Strategy by exlux99lowest highestv4 strategy+6.4%2049.6%
Highest High and Lowest Low Channel Strategy by ceyhunhighest lowestv5 strategy−3.7%267.9%
Donchian Channels System [racer8] by racer8highest lowestv4 strategy−3.2%3643.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 19 msYes 1,000 bars in 50 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/// © algotradingcc// Strategy testing and optimisation for free trading bot //@version=4strategy("Donchian Channel Strategy [for free bot]", overlay=true, default_qty_type= strategy.percent_of_equity, initial_capital = 1000, default_qty_value = 20, commission_type=strategy.commission.percent, commission_value=0.036)//Long optopnsbuyPeriodEnter = input(10, "Channel Period for Long enter position")buyPeriodExit = input(10, "Channel Period for Long exit position")isMiddleBuy = input(true, "Is exit on Base Line? If 'no' - exit on bottom line")takeProfitBuy = input(2.5, "Take Profit (%) for Long position")isBuy = input(true, "Allow Long?")//Short OptionssellPeriodEnter = input(20, "Channel Period for Short enter position")sellPeriodExit = input(20, "Channel Period for Short exit position")isMiddleSell = input(true, "Is exit on Base Line? If 'no' - exit on upper line")takeProfitSell = input(2.5, "Take Profit (%) for Short position")isSell = input(true, "Allow Short?")// Test StartstartYear = input(2005, "Test Start Year")startMonth = input(1, "Test Start Month")startDay = input(1, "Test Start Day")startTest = timestamp(startYear,startMonth,startDay,0,0)//Test EndendYear = input(2050, "Test End Year")endMonth = input(12, "Test End Month")endDay = input(30, "Test End Day")endTest = timestamp(endYear,endMonth,endDay,23,59)timeRange = time > startTest and time < endTest ? true : false// Long&Short LevelsBuyEnter = highest(buyPeriodEnter)BuyExit = isMiddleBuy ? ((highest(buyPeriodExit) + lowest(buyPeriodExit)) / 2): lowest(buyPeriodExit)SellEnter = lowest(sellPeriodEnter)SellExit = isMiddleSell ? ((highest(sellPeriodExit) + lowest(sellPeriodExit)) / 2): highest(sellPeriodExit)// Plot Dataplot(BuyEnter, style=plot.style_line, linewidth=2, color=color.blue, title="Buy Enter")plot(BuyExit, style=plot.style_line, linewidth=1, color=color.blue, title="Buy Exit", transp=50)plot(SellEnter, style=plot.style_line, linewidth=2, color=color.red, title="Sell Enter")plot(SellExit, style=plot.style_line, linewidth=1, color=color.red, title="Sell Exit", transp=50)// Calc Take ProfitsTakeProfitBuy = 0.0TakeProfitSell = 0.0if strategy.position_size > 0    TakeProfitBuy := strategy.position_avg_price*(1 + takeProfitBuy/100)    if strategy.position_size < 0    TakeProfitSell := strategy.position_avg_price*(1 - takeProfitSell/100)// Long Position    if isBuy and timeRange    strategy.entry("Long", strategy.long, stop = BuyEnter, when = strategy.position_size == 0)     strategy.exit("Long Exit", "Long", stop=BuyExit, limit = TakeProfitBuy, when = strategy.position_size > 0)// Short Positionif isSell and timeRange    strategy.entry("Short", strategy.short, stop = SellEnter, when = strategy.position_size == 0)     strategy.exit("Short Exit", "Short", stop=SellExit, limit = TakeProfitSell, when = strategy.position_size < 0)// Close & Cancel when over End of the Testif time > endTest    strategy.close_all()    strategy.cancel_all()