Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Turtle Trend Trading System [racer8]

A Pine Script v4 strategy built on Highest (55) and Lowest (55). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 2 settings; defaults include Entry Length 55 and Exit Length 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 Turtle Trend Trading System [racer8] 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 Turtle Trend Trading System [racer8] do on BTCUSDT 1D with default settings?
+12.43%
From 26 Jan 2024 to 21 Oct 2026, over 14 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Turtle Trend Trading System [racer8] 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 Turtle Trend Trading System [racer8] use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Turtle Trend Trading System [racer8] run in Zeal Terminal?
Yes
It compiles in 13 ms and runs 1,000 bars in 21 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • 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 (2)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$112,426$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
+12.43%
$12,429.40
Buy and hold
+102.5%
same period
Closed trades
14
6 won · 8 lost
Profitable
42.9%
of closed trades
Profit factor
1.30
gross profit ÷ gross loss
Max drawdown
17.33%
−$17,329.70

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 14 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: highest → ta.highest
  • Line 8: lowest → ta.lowest
  • Line 9: highest → ta.highest
  • Line 10: lowest → ta.lowest
⋯// © racer8-//@version=4+//@version=5strategy("Turtle System", overlay=true)⋯e = input(20,"Exit Length")-HI = highest(n)+HI = ta.highest(n)-LO = lowest(n)+LO = ta.lowest(n)-hi = highest(e)+hi = ta.highest(e)-lo = lowest(e)+lo = ta.lowest(e)if close>HI[1]⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.int()
  • Line 6: input() → input.int()
⋯strategy("Turtle System", overlay=true)-n = input(55,"Entry Length")+n = input.int(55,"Entry Length")-e = input(20,"Exit Length")+e = input.int(20,"Exit Length")HI = ta.highest(n)⋯

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

⋯// © racer8-//@version=5+//@version=6strategy("Turtle System", 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
Entry Length55intHI LO
Exit Length20inthi lo

What it calculates

  • Highest (highest, ta.highest in v5)Entry Length (55)HI · line 7
  • Lowest (lowest, ta.lowest in v5)Entry Length (55)LO · line 8
  • Highest (highest, ta.highest in v5)Exit Length (20)hi · line 9
  • Lowest (lowest, ta.lowest in v5)Exit Length (20)lo · line 10

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.

nEntry Lengthsetting · 55eExit Lengthsetting · 20closecloseprice datalowlowprice datahighhighprice dataHIHighest→ HILOLowest→ LOhiHighest→ hiloLowest→ loentry:BuyOpen Buystrategy.entryentry:SellOpen Sellstrategy.entryclose:BuyClose Buystrategy.closeclose:SellClose Sellstrategy.closeplot:20plotplotplot:21plotplotplot:22plotplotplot:23plotplot

Order rules

OrderFires whenBy defaultLine
Open Buy longclose>HI[1]On12
Open Sell shortclose<LO[1]On14
Close Buylow<lo[1]On17
Close Sellhigh>hi[1]On19

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.4%+102.5%1443%1.3017.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+13.2%+5.5%1354%2.463.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+3.5%+9.8%1173%7.790.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.4%+8.4%1242%1.640.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.1%+16.7%1436%0.550.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%1145%3.140.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.1%+148.3%1331%1.190.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.1%+17.1%1613%0.390.2%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 market30%−$14,927.70
Sideways market863%$30,489.40
Falling market333%−$3,132.22

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

How bad could the drawdown be?

28.4%

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

0%33%
All 14 trades
SideEntryExitBarsP&L
short2 May 2024 58,365.0016 May 2024 66,206.5014−$7,841.54
short5 Jul 2024 57,050.0016 Jul 2024 64,724.1011−$7,674.04
long16 Oct 2024 67,074.1031 Dec 2024 92,792.1076$25,717.90
short26 Feb 2025 88,680.4023 Apr 2025 93,443.0056−$4,762.60
long2 May 2025 96,489.906 Jun 2025 101,509.0035$5,018.79
long11 Jul 2025 116,010.002 Aug 2025 113,298.0022−$2,712.09
long14 Aug 2025 123,306.0023 Aug 2025 116,936.009−$6,370.44
short5 Nov 2025 101,497.0010 Dec 2025 92,678.8035$8,818.42
long14 Jan 2026 95,414.0022 Jan 2026 89,454.708−$5,959.26
short1 Feb 2026 78,741.105 Mar 2026 72,666.8032$6,074.33
long18 Apr 2026 77,072.0023 May 2026 75,539.5035−$1,532.51
short3 Jun 2026 66,760.8015 Jul 2026 65,044.0042$1,716.85
long20 Aug 2026 69,334.8016 Sep 2026 75,644.5027$6,309.70
long22 Sep 2026 86,620.0016 Oct 2026 82,245.9024−$4,374.08

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
Turtle Trend Trading System [racer8] this page—v4 strategy+12.4%1417.3%
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 13 msYes 1,000 bars in 21 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/// © racer8//@version=4strategy("Turtle System", overlay=true)n = input(55,"Entry Length")e = input(20,"Exit Length")HI = highest(n)LO = lowest(n)hi = highest(e)lo = lowest(e)if close>HI[1]    strategy.entry("Buy", strategy.long)if close<LO[1]    strategy.entry("Sell", strategy.short)    if low<lo[1]    strategy.close("Buy")if high>hi[1]    strategy.close("Sell")plot(HI,color=color.lime)plot(LO,color=color.red)plot(hi,color=color.blue)plot(lo,color=color.maroon)