Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Crunchster's Turtle and Trend System

A Pine Script v5 strategy built on Lowest (low[1], 20), Highest (high[1], 20) and EMA (close[1], 10). It has 12 order rules, 4 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade is 0.1 contracts and pays 0.06 commission. 19 settings; defaults include Source close, Lookback period for fast EMA 10 and Lookback period for Breakout 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 Crunchster's Turtle and Trend System repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 9 of 9 trades.
How did Crunchster's Turtle and Trend System do on BTCUSDT 1D with default settings?
+17.99%
From 26 Jan 2024 to 21 Oct 2026, over 31 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Crunchster's Turtle and Trend System 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: 31 before, 31 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Crunchster's Turtle and Trend System use a stop loss?
Yes
strategy.exit sets a stop on line 72, 81, 91, 100.
Does Crunchster's Turtle and Trend System run in Zeal Terminal?
Yes
It compiles in 44 ms and runs 1,000 bars in 117 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA Forecast
  • Fast EMA
  • Slow EMA
  • 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 (19)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1,180$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. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
Net profit
+17.99%
$179.85
Buy and hold
+102.5%
same period
Closed trades
31
11 won · 20 lost
Profitable
35.5%
of closed trades
Profit factor
1.36
gross profit ÷ gross loss
Max drawdown
16.69%
−$204.51

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.

  • Check

    1 setting does nothing

    “Source” is declared but never read.

Settings

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

SettingDefaultType and rangeFeeds
Strategy Settings
Sourceclosesourceunused
Lookback period for fast EMAThis sets the lookback period for the fast exponential moving average. The slow EMA is 5x the fast EMA length10int · min 2fEMA sEMA
Lookback period for Breakout20int · min 5 · step 5lower upper
Strategy toggle
Longtrueboolline 66 line 85
ShortToggle long/short strategy on/offtrueboolline 75 line 94
Trendfalseboolline 65
BreakoutToggle trend/breakout strategy on/offtrueboolline 84
Risk Management Settings
Stop multipleMultiple for ATR, setting hard stop loss from entry price2float · step 0.5exit Stop Long exit Stop Short
Trail lookbackLookback period for the trailing stop10int · step 5tlower tupper
Max LeverageMax leverage sets maximum allowable leverage of total capital (initial capital + any net profit), capping maximum volatility adjusted position size1float · step 0.5shares line 51
Annualised Volatility Target %Specify annual risk target, used to determine volatility adjusted position size. Annualised daily volatility is referenced to this value and position size adjusted accordingly15float · max 75shares
Compoundingtrueboolline 46
%Toggle compounding of profit, and set % of profit to compound50float · step 5risk
Backtest range
From Day1int · min 1 · max 31start
From Mon1int · min 1 · max 12start
From YrSet start of backtesting period2018int · min 1900start
To Day1int · min 1 · max 31finish
To Mon1int · min 1 · max 12finish
To YrSet end of backtesting period9999int · min 1900finish

What it calculates

  • Lowestlow[1], Lookback period for Breakout (20)lower · line 30
  • Highesthigh[1], Lookback period for Breakout (20)upper · line 31
  • EMAclose[1], Lookback period for fast EMA (10)fEMA · line 35
  • EMAclose[1], length*5sEMA · line 36
  • Stdevclose - close[1], 252nemadiff · line 38
  • SMAtr, 14stopL · line 41
  • Stdevclose-close[1], 14stdev · line 42
  • Lowestlow[1], Trail lookback (10)tlower · line 60
  • Highesthigh[1], Trail lookback (10)tupper · line 61

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.

The script has 61 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open Trend Long! long(longCondition2)On70
Exit Stop Long stopstrategy.position_size > 0On72
Close Trend Long!(exitlong)On74
Open Trend Short! short(shortCondition2)On79
Exit Stop Short stopstrategy.position_size < 0On81
Close Trend Short!(exitshort)On83
Open Break Long! long(longCondition1)On89
Exit Stop Long stopstrategy.position_size > 0On91
Close Break Long!(exitlong)On93
Open Break Short! short(shortCondition1)On98
Exit Stop Short stopstrategy.position_size < 0On100
Close Break Short!(exitshort)On102

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.

9/9trades 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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+18.0%+102.5%3135%1.3616.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.2%+5.5%3030%1.0014.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+9.3%+9.8%3142%1.248.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+22.2%+8.4%2726%1.4515.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−6.7%+16.7%3327%0.8316.7%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+22.8%+21.5%2928%1.5113.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+32.6%+148.3%2733%1.7126.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−15.9%+17.1%3628%0.6222.0%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 market922%−$55.07
Sideways market1644%$273.77
Falling market633%−$38.85

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

How bad could the drawdown be?

23.5%

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

0%27%
All 31 trades
SideEntryExitBarsP&L
long14 Feb 2024 51,795.3019 Mar 2024 61,937.3034$103.52
short1 May 2024 58,364.904 May 2024 63,994.403−$31.82
long15 May 2024 66,206.6014 Jun 2024 66,043.9030−$1.05
short14 Jun 2024 66,043.9014 Jul 2024 60,798.0030$40.33
long15 Jul 2024 64,724.202 Aug 2024 61,498.2018−$15.23
short4 Aug 2024 58,160.9023 Aug 2024 64,523.9019−$37.27
long23 Aug 2024 64,037.3027 Aug 2024 58,688.104−$28.06
short6 Sep 2024 53,962.9013 Sep 2024 58,763.407−$29.69
long18 Sep 2024 61,760.101 Oct 2024 60,805.7013−$5.77
long15 Oct 2024 67,074.202 Feb 2025 97,700.50110$204.50
short24 Feb 2025 91,552.8019 Mar 2025 86,846.0023$23.54
short6 Apr 2025 78,429.9012 Apr 2025 85,373.706−$32.44
long22 Apr 2025 93,443.1030 May 2025 103,985.0038$35.01
short5 Jun 2025 101,509.009 Jun 2025 107,051.004−$31.31
long9 Jul 2025 111,234.001 Aug 2025 113,298.0023$12.50
short1 Aug 2025 113,298.0010 Aug 2025 118,095.009−$33.79
long13 Aug 2025 123,307.0015 Aug 2025 117,196.002−$31.07
short25 Aug 2025 110,112.0010 Sep 2025 113,960.0016−$13.37
long16 Sep 2025 116,789.0022 Sep 2025 112,452.006−$40.08
short25 Sep 2025 108,994.0029 Sep 2025 113,244.004−$24.55
long1 Oct 2025 118,595.0010 Oct 2025 113,622.009−$19.70
short4 Nov 2025 101,497.003 Dec 2025 93,430.1029$28.59
long4 Jan 2026 91,529.8020 Jan 2026 88,427.6016−$34.65
short25 Jan 2026 86,670.304 Mar 2026 72,666.9038$59.66
long4 Mar 2026 72,666.907 Mar 2026 67,535.803−$20.64
long16 Mar 2026 74,884.8019 Mar 2026 69,088.803−$26.68
long13 Apr 2026 74,418.1016 May 2026 78,147.9033$18.91
short22 May 2026 75,539.4014 Jun 2026 65,746.6023$70.05
long14 Jul 2026 65,044.1015 Sep 2026 75,644.4063$82.46
short15 Sep 2026 75,644.4018 Sep 2026 79,320.403−$20.93
long21 Sep 2026 86,620.108 Oct 2026 81,730.0017−$21.11

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
Crunchster's Turtle and Trend System this page—v5 strategy+18.0%3116.7%
The Z-score by jensenvilhelmsma stdev ema highest lowestv5 strategy+2.4%525.5%
MZ SRSI Strategy V1.0 by MightyZingerema sma highest lowest stdevv4 strategyNo trades on this market
BBPBΔ(OBV-PVT)BB - Time Series Decomposition & Volume Weighted by tathalema stdev sma highest lowestv4 strategyNo trades on this market
WOMBO COMBO- EMA & VWAP & MACD & BB & STC by MakeMoneyCoESTB2020ema sma stdev highest lowestv4 strategy−0.5%62.2%
Lawyers Trend Pro Strategy by ErdemDemirsma stdev lowest highestv4 strategy+12.1%10241.7%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 6 settings use the untyped input() (line 6, 9, 10, 11, 12, 17). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 6: input() → input.source()
  • Line 9: input() → input.bool()
  • Line 10: input() → input.bool()
  • Line 11: input() → input.bool()
  • Line 12: input() → input.bool()
  • Line 17: input() → input.bool()
⋯// Inputs and Parameters-src = input(close, 'Source', group='Strategy Settings')+src = input.source(close, 'Source', group='Strategy Settings')length = input.int(title="Lookback period for fast EMA", defval=10, minval=2, group='Strategy Settings', tooltip='This sets the lookback period for the fast exponential moving average. The slow EMA is 5x the fast EMA length')blength = input.int(title="Lookback period for Breakout", defval=20, minval=5, step=5, group='Strategy Settings')-long = input(true, 'Long', inline='08', group='Strategy toggle')+long = input.bool(true, 'Long', inline='08', group='Strategy toggle')-short = input(true, 'Short', inline='08', group='Strategy toggle', tooltip='Toggle long/short strategy on/off')+short = input.bool(true, 'Short', inline='08', group='Strategy toggle', tooltip='Toggle long/short strategy on/off')-EMAwt = input(false, 'Trend', inline='01', group='Strategy toggle')+EMAwt = input.bool(false, 'Trend', inline='01', group='Strategy toggle')-breakwt = input(true, 'Breakout', inline='01', group='Strategy toggle', tooltip='Toggle trend/breakout strategy on/off')+breakwt = input.bool(true, 'Breakout', inline='01', group='Strategy toggle', tooltip='Toggle trend/breakout strategy on/off')stopMultiple = input.float(2, 'Stop multiple', step=0.5, group='Risk Management Settings', tooltip='Multiple for ATR, setting hard stop loss from entry price')⋯riskT = input.float(15, maxval=75, title='Annualised Volatility Target %', group='Risk Management Settings', tooltip='Specify annual risk target, used to determine volatility adjusted position size. Annualised daily volatility is referenced to this value and position size adjusted accordingly')-comp = input(true, 'Compounding', inline='09', group='Risk Management Settings')+comp = input.bool(true, 'Compounding', inline='09', group='Risk Management Settings')Comppct = input.float(50, '%', step=5, inline='09', group='Risk Management Settings', tooltip='Toggle compounding of profit, and set % of profit to compound')⋯

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

⋯// © Crunchster1-//@version=5+//@version=6strategy(title="Crunchster's Turtle and Trend System", shorttitle="Turtle Trend", overlay=true, slippage=10, pyramiding=1, precision = 4, calc_on_order_fills = false, calc_on_every_tick = false, default_qty_value = 0.1, initial_capital = 1000, commission_value = 0.06, process_orders_on_close = true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 44 msWith a workaround 1,000 bars in 117 msNot measured
PineTSNot testedNot testedNot measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“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.

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/// © Crunchster1//@version=5strategy(title="Crunchster's Turtle and Trend System", shorttitle="Turtle Trend", overlay=true, slippage=10, pyramiding=1, precision = 4, calc_on_order_fills = false, calc_on_every_tick = false, default_qty_value = 0.1, initial_capital = 1000, commission_value = 0.06, process_orders_on_close = true)// Inputs and Parameterssrc = input(close, 'Source', group='Strategy Settings')length = input.int(title="Lookback period for fast EMA", defval=10, minval=2, group='Strategy Settings', tooltip='This sets the lookback period for the fast exponential moving average. The slow EMA is 5x the fast EMA length')blength = input.int(title="Lookback period for Breakout", defval=20, minval=5, step=5, group='Strategy Settings')long = input(true, 'Long', inline='08', group='Strategy toggle')short = input(true, 'Short', inline='08', group='Strategy toggle', tooltip='Toggle long/short strategy on/off')EMAwt = input(false, 'Trend', inline='01', group='Strategy toggle')breakwt = input(true, 'Breakout', inline='01', group='Strategy toggle', tooltip='Toggle trend/breakout strategy on/off')stopMultiple = input.float(2, 'Stop multiple', step=0.5, group='Risk Management Settings', tooltip='Multiple for ATR, setting hard stop loss from entry price')trail = input.int(10, 'Trail lookback', step=5, group='Risk Management Settings', tooltip='Lookback period for the trailing stop')lev = input.float(1, 'Max Leverage', step=0.5, group='Risk Management Settings', tooltip='Max leverage sets maximum allowable leverage of total capital (initial capital + any net profit), capping maximum volatility adjusted position size')riskT = input.float(15, maxval=75, title='Annualised Volatility Target %', group='Risk Management Settings', tooltip='Specify annual risk target, used to determine volatility adjusted position size. Annualised daily volatility is referenced to this value and position size adjusted accordingly')comp = input(true, 'Compounding', inline='09', group='Risk Management Settings')Comppct = input.float(50, '%', step=5, inline='09', group='Risk Management Settings', tooltip='Toggle compounding of profit, and set % of profit to compound')// Backtesting periodFromDay = input.int(defval=1, title='From Day', minval=1, maxval=31, inline='04', group='Backtest range')FromMonth = input.int(defval=1, title='From Mon', minval=1, maxval=12, inline='04', group='Backtest range')FromYear = input.int(defval=2018, title='From Yr', minval=1900, inline='04', group='Backtest range', tooltip='Set start of backtesting period')ToDay = input.int(defval=1, title='To Day', minval=1, maxval=31, inline='05', group='Backtest range')ToMonth = input.int(defval=1, title='To Mon', minval=1, maxval=12, inline='05', group='Backtest range')ToYear = input.int(defval=9999, title='To Yr', minval=1900, inline='05', group='Backtest range', tooltip='Set end of backtesting period')start = timestamp(FromYear, FromMonth, FromDay, 00, 00)finish = timestamp(ToYear, ToMonth, ToDay, 23, 59)window = time >= start and time <= finish// Breakout strategylower = ta.lowest(low[1], blength)upper = ta.highest(high[1], blength)basis = math.avg(upper, lower)signal = 20*(close - basis) / (upper - lower)// Trend strategyfEMA = ta.ema(close[1], length)sEMA = ta.ema(close[1], length*5)emadiff = fEMA - sEMAnemadiff = 5*emadiff/(ta.stdev(close - close[1], 252))//Risk Management formulaetr = math.max(high - low, math.abs(high - close), math.abs(low - close)) //True rangestopL = ta.sma(tr, 14) //Average true rangestdev = ta.stdev(close-close[1], 14) //volatility of recent returnsmaxcapital = strategy.initial_capital+strategy.netprofit //Maximum capital available to invest - initial capital net of profitannvol = 100*math.sqrt(365)*stdev/close //converts recent volatility of returns into annualised volatility of returns - assumes daily timeframerisk = 1.1if comp    risk := (strategy.initial_capital+(Comppct*strategy.netprofit/100))//adjust investment capital to include compoundingelse    risk := strategy.initial_capitalshares = (risk * (riskT/annvol)) / close //calculates volatility adjusted position size, dependent on user specified annualised risk targetif ((shares*close) > lev*maxcapital) //ensures position size does not exceed available capital multiplied by user specified maximum leverage    shares := lev*maxcapital/close//To set the price at the entry point of tradePosopen() =>    math.abs(strategy.position_size[1]) <= 0 and math.abs(strategy.position_size) > 0var float openN = naif Posopen()    openN := stopL// Trailing stoptlower = ta.lowest(low[1], trail)tupper = ta.highest(high[1], trail)tbasis = math.avg(tupper, tlower)tsignal = 20*(close - tbasis) / (tupper - tlower)// Strategy Rulesif EMAwt    if long        longCondition2 = (nemadiff >2 and nemadiff[1] <2) and window        exitlong = tsignal <= -10        if (longCondition2)            strategy.entry('Trend Long!', strategy.long, qty=shares)        if strategy.position_size > 0                strategy.exit('Stop Long', from_entry = 'Trend Long!', stop=(strategy.opentrades.entry_price(0) - (openN * stopMultiple)))        if (exitlong)            strategy.close('Trend Long!', immediately = true)    if short        shortCondition2 = (nemadiff <-1 and nemadiff[1] >-1) and window        exitshort = tsignal >= 10        if (shortCondition2)            strategy.entry('Trend Short!', strategy.short, qty=shares)        if strategy.position_size < 0               strategy.exit('Stop Short', from_entry = 'Trend Short!', stop=(strategy.opentrades.entry_price(0) + (openN * stopMultiple)))        if (exitshort)            strategy.close('Trend Short!', immediately = true)if breakwt    if long        longCondition1 = (signal >= 10) and window        exitlong = tsignal <= -10        if (longCondition1)            strategy.entry('Break Long!', strategy.long, qty=shares)        if strategy.position_size > 0                strategy.exit('Stop Long', from_entry = 'Break Long!', stop=(strategy.opentrades.entry_price(0) - (openN * stopMultiple)))        if (exitlong)            strategy.close('Break Long!', immediately = true)    if short        shortCondition1 = (signal <= -10) and window        exitshort = tsignal >= 10        if (shortCondition1)            strategy.entry('Break Short!', strategy.short, qty=shares)        if strategy.position_size < 0               strategy.exit('Stop Short', from_entry = 'Break Short!', stop=(strategy.opentrades.entry_price(0) + (openN * stopMultiple)))        if (exitshort)            strategy.close('Break Short!', immediately = true)// Visuals of trend and directionplot(nemadiff, title='EMA Forecast', color=color.black, display=display.none)plot(ta.sma(ta.median(math.sqrt(math.pow(nemadiff,2)), 700), 350), 'Forecast mean', color=color.rgb(245, 0, 0), display=display.none)MAColor = fEMA > sEMA ? #00ff00 : #ff0000MA1 = plot(fEMA, title='Fast EMA', color=MAColor)MA2 = plot(sEMA, title='Slow EMA', color=MAColor)fill(MA1, MA2, title='Band Filler', color=MAColor)