Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Donchian Strat EXMO

A Pine Script v4 strategy built on Highest (high, 20) and Lowest (low, 20). 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. 1 setting; defaults include Long Period 20.

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 Strat EXMO repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
How did Donchian Strat EXMO do on BTCUSDT 1D with default settings?
+12.13%
From 26 Jan 2024 to 21 Oct 2026, over 22 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Donchian Strat EXMO 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 Strat EXMO use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Donchian Strat EXMO run in Zeal Terminal?
Yes
It compiles in 6 ms and runs 1,000 bars in 16 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • 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 (1)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$112,127$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. Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 12, 15) so the engine trades the way the script says.
Net profit
+12.13%
$12,127.20
Buy and hold
+102.5%
same period
Closed trades
22
7 won · 15 lost
Profitable
31.8%
of closed trades
Profit factor
1.13
gross profit ÷ gross loss
Max drawdown
68.00%
−$68,002.40

One run with the author's default settings, $100,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.

  • 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

    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 highest → ta.highest, lowest → ta.lowest.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 6: highest → ta.highest
  • Line 7: lowest → ta.lowest
  • Line 12: strategy.order(…, true) → strategy.order(…, strategy.long)
  • Line 15: strategy.order(…, false) → strategy.order(…, strategy.short)
⋯// © pskoroplas-//@version=4+//@version=5strategy("Donchian Strat EXMO", overlay=true)long_per = input(defval = 20, title = "Long Period")-h = highest(high, long_per)+h = ta.highest(high, long_per)-l = lowest(low, long_per)+l = ta.lowest(low, long_per)plot(l)⋯if h[1] < h[2]-    strategy.order("BUY", true, stop = h)+    strategy.order("BUY", strategy.long, stop = h)    //strategy.exit("BUY", profit = 400)if l[1] > l[2]-    strategy.order("SELL", false, stop = l)+    strategy.order("SELL", strategy.short, stop = l)    //strategy.exit("SELL", profit = 400)

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.int()
⋯strategy("Donchian Strat EXMO", overlay=true)-long_per = input(defval = 20, title = "Long Period")+long_per = input.int(defval = 20, title = "Long Period")h = ta.highest(high, long_per)⋯

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

⋯// © pskoroplas-//@version=5+//@version=6strategy("Donchian Strat EXMO", 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
Long Period20inth l

What it calculates

  • Highest (highest, ta.highest in v5)high, Long Period (20)h · line 6
  • Lowest (lowest, ta.lowest in v5)low, Long Period (20)l · line 7

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.

highhighprice datalong_perLong Periodsetting · 20lowlowprice dataclosecloseprice datahHighest→ hlLowest→ lpercpercvalueorder:BUYorder BUYstrategy.orderorder:SELLorder SELLstrategy.orderplot:8plotplotplot:9plotplot

Order rules

OrderFires whenBy defaultLine
order BUY longh[1] < h[2]On12
order SELL shortl[1] > l[2]On15

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.

6/6trades 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+12.1%+102.5%2232%1.1368.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−34.3%+5.5%1631%0.6277.9%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.9%+9.8%1741%1.1211.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−1.7%+8.4%1932%0.584.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.2%+16.7%2060%1.900.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%2138%0.660.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.2%+148.3%2030%0.850.9%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.3%+17.1%2129%0.430.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 market70%−$46,795.50
Sideways market1050%$57,367.40
Falling market540%$1,555.30

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

How bad could the drawdown be?

56.0%

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

0%64%
All 22 trades
SideEntryExitBarsP&L
long8 Apr 2024 71,769.5013 Apr 2024 63,772.305−$7,997.25
short17 Apr 2024 60,660.6015 May 2024 65,500.0028−$4,839.43
long16 May 2024 66,444.2011 Jun 2024 66,312.2026−$132.00
long15 Jul 2024 63,861.804 Aug 2024 59,850.0020−$4,011.76
short5 Aug 2024 57,122.8023 Aug 2024 62,745.1018−$5,622.37
long25 Aug 2024 64,955.004 Sep 2024 56,078.5010−$8,876.46
long17 Sep 2024 61,167.0010 Oct 2024 59,828.1023−$1,338.88
long18 Sep 2024 61,320.0030 Dec 2024 92,232.50103$30,912.50
long17 Jan 2025 102,724.0025 Feb 2025 91,349.3039−$11,375.10
short6 Apr 2025 81,134.7022 Apr 2025 88,500.0016−$7,365.34
short5 Jun 2025 101,383.002 Jul 2025 108,952.0027−$7,569.31
short22 Jun 2025 100,372.003 Jul 2025 109,730.0011−$9,357.74
short1 Aug 2025 114,723.0011 Aug 2025 120,248.0010−$5,524.64
long15 Sep 2025 116,666.0025 Sep 2025 109,329.0010−$7,336.51
short26 Sep 2025 108,632.009 Dec 2025 94,150.0074$14,481.50
short4 Nov 2025 103,528.002 Jan 2026 90,634.6059$12,893.70
long4 Jan 2026 90,961.8021 Jan 2026 87,550.4017−$3,411.38
short25 Jan 2026 87,263.504 Mar 2026 70,983.0038$16,280.50
short27 Mar 2026 65,618.508 Apr 2026 72,761.0012−$7,142.51
long9 Apr 2026 72,857.0022 May 2026 76,051.0043$3,194.00
long14 Jul 2026 64,700.0015 Sep 2026 76,046.6063$11,346.60
long19 Aug 2026 65,474.5015 Oct 2026 80,393.6057$14,919.10

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 Strat EXMO this page—v4 strategy+12.1%2268.0%
Alex Days HiLo Rajib by 14rajibhighest lowestv4 strategyNo trades on this market
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%
eswaran ab by ESWARMONK2515lowest highestv4 strategy+8.4%1339.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 6 msWith a workaround 1,000 bars in 16 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 12, 15) so the engine trades the way the script says.

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © pskoroplas//@version=4strategy("Donchian Strat EXMO", overlay=true)long_per = input(defval = 20, title = "Long Period")h = highest(high, long_per)l = lowest(low, long_per)plot(l)plot(h)perc = close/100if h[1] < h[2]    strategy.order("BUY", true, stop = h)    //strategy.exit("BUY", profit = 400)if l[1] > l[2]    strategy.order("SELL", false, stop = l)    //strategy.exit("SELL", profit = 400)