Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Trendelicious Strategy

A Pine Script v5 strategy built on Highest or Lowest (hl2, 30), Change (PP, 1) and Crossover (hl2, PP). It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays 0.1% commission. 5 settings; defaults include Length 30 and Price Source hl2.

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 Trendelicious Strategy repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Trendelicious Strategy do on BTCUSDT 1D with default settings?
−12.83%
From 26 Jan 2024 to 21 Oct 2026, over 9 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Trendelicious Strategy 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: 9 before, 18 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 Trendelicious Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Trendelicious Strategy run in Zeal Terminal?
Yes
It compiles in 40 ms and runs 1,000 bars in 65 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Up Trend
  • Down Trend
  • 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 (5)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,134$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.
Table drawn by the script, as it stood on the last bar
Net Profit-128 -13 %
Buy & Hold386 39 %
Win / Loss4 / 5
Open PnL263
Net profit
−12.83%
−$128.27
Buy and hold
+102.5%
same period
Closed trades
9
4 won · 5 lost
Profitable
44.4%
of closed trades
Profit factor
0.81
gross profit ÷ gross loss
Max drawdown
41.43%
−$546.75

One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A long 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 stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    1 setting has no label

    In the settings dialog length (line 5) shows an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Settings

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

SettingDefaultType and rangeFeeds
Length (no label in the script)30intuptrend PP trendline
Price Sourcehl2sourceuptrend PP priceOverPP priceUnderPP risingPrice fallingPrice uptrendCondition1 downtrendCondition1 trendline
Aggressive Modefalsebooluptrend uptrendCondition1 uptrendCondition2 uptrendCondition3 downtrendCondition1 downtrendCondition2 downtrendCondition3 trendline
Start Timetimestamp("01 Jan 1900 00:00 +0000")timeline 11
End Timetimestamp("31 Dec 2050 23:59 +0000")timeline 11

What it calculates

  • Highest / LowestPrice Source (hl2), Length (30)PP · line 16
  • ChangePP, 1ppChange · line 17
  • CrossoverPrice Source (hl2), PPpriceOverPP · line 19
  • CrossunderPrice Source (hl2), PPpriceUnderPP · line 20
  • RisingPrice Source (hl2), 5risingPrice · line 21
  • RisingPP, 5risingPP · line 22
  • FallingPrice Source (hl2), 5fallingPrice · line 23
  • FallingPP, 5fallingPP · line 24

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.

hl2hl2price datalengthLengthsetting · 30closecloseprice dataopenopenprice dataPPHighest / Lowest→ PPppChangeChange→ ppChangepriceOverPPCrossover→ priceOverPPpriceUnderPPCrossunder→ priceUnderPPrisingPriceRising→ risingPricerisingPPRising→ risingPPfallingPriceFalling→ fallingPricefallingPPFalling→ fallingPPuptrend, trendlineuptrend · trendline2 valuesfirstTradePrice, bhprofitfirstTradePrice · bhpro…2 valuesnetprofit, openprofit, trades, wins, losses, testTablenetprofit · openprofit …6 valuesnetprofitPercentnetprofitPercentvaluebhprofitPercentbhprofitPercentvaluebuyConditionbuyConditionconditionsellConditionsellConditionconditionppFlatppFlatconditionuptrendCondition1, downtrendCondition1uptrendCondition1 · dow…2 conditionsuptrendCondition2uptrendCondition2conditionuptrendCondition3uptrendCondition3conditiondowntrendCondition2downtrendCondition2conditiondowntrendCondition3downtrendCondition3conditionend_timeend_timeconditionwinColor, loseColor, neutralColorColourwinColor · loseColor +1cancel_all:cancel_all strategy.cancel_allentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeplot:39plotplotplot:40Up Trendplotplot:41Down Trendplotfill:42Fillfill × 2fill:43Fillfill × 2

Order rules

OrderFires whenBy defaultLine
cancel_all not window()On13
Open Long longbuyConditionOn49
Close LongsellConditionOn53

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

2/2trades 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. On 0 of them the position changed while the bar was forming before it settled. Anyone watching live sees those changes; once the bar closes it matches history.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationreads realtime-only state. Live values can differ from history.
  • 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.8%+102.5%944%0.8141.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+13.6%+5.5%850%2.087.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−1.3%+9.8%743%0.9840.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+46.7%+8.4%757%4.187.8%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−56.6%+16.7%933%0.2863.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+22.3%+21.5%743%2.149.8%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+20.6%+148.3%743%1.2838.6%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−19.4%+17.1%1040%0.3927.8%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 market333%−$69.48
Sideways market540%−$82.53
Falling market1100%$24.61

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

How bad could the drawdown be?

46.1%

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

0%53%
All 9 trades
SideEntryExitBarsP&L
long1 Mar 2024 61,131.0015 Apr 2024 65,661.9045$71.97
long23 May 2024 69,166.6021 Jun 2024 64,870.0029−$68.60
long23 Jul 2024 67,532.001 Sep 2024 58,974.0040−$128.90
long30 Sep 2024 65,602.0026 Feb 2025 88,680.40149$305.27
long25 Apr 2025 93,980.5024 Jun 2025 105,334.0060$139.88
long12 Jul 2025 117,528.0028 Aug 2025 111,262.0047−$72.85
long4 Oct 2025 122,232.007 Nov 2025 101,346.0034−$215.10
long16 Jan 2026 95,604.801 Feb 2026 78,741.1016−$183.67
long19 Mar 2026 71,246.6030 May 2026 73,460.8072$24.61

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
Trendelicious Strategy this page—v5 strategy−12.8%941.4%
ICHIMOKU Crypto Swing Strategy by exlux99highest lowest rising fallingv4 strategydoes not run in Zeal Terminal
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%

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.

  • 3 settings use the untyped input() (line 5, 6, 7). 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 9 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.source()
  • Line 7: input() → input.bool()
⋯strategy(title='Trendelicious Strategy', shorttitle='Trendelicious Strategy', initial_capital=1000, overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)-length=input(defval=30)+length=input.int(defval=30)-price=input(defval=hl2, title="Price Source")+price=input.source(defval=hl2, title="Price Source")-aggressiveMode=input(defval=false,title="Aggressive Mode")+aggressiveMode=input.bool(defval=false,title="Aggressive Mode")start = input.time(defval = timestamp("01 Jan 1900 00:00 +0000"), title = "Start Time")⋯

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

⋯// © levieux-//@version=5+//@version=6strategy(title='Trendelicious Strategy', shorttitle='Trendelicious Strategy', initial_capital=1000, overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 40 msYes 1,000 bars in 65 msNot measured
PineTSNot testedNot testedNot 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.

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/// © levieux//@version=5strategy(title='Trendelicious Strategy', shorttitle='Trendelicious Strategy', initial_capital=1000, overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)length=input(defval=30)price=input(defval=hl2, title="Price Source")aggressiveMode=input(defval=false,title="Aggressive Mode")start = input.time(defval = timestamp("01 Jan 1900 00:00 +0000"), title = "Start Time")end = input.time(defval = timestamp("31 Dec 2050 23:59 +0000"), title = "End Time")window() =>    time >= start and time < endif not window()    strategy.cancel_all()isUptrend(price,length,aggressiveMode) =>    uptrend= false    PP= (ta.highest(price,length)+ta.lowest(price,length))/2    ppChange= ta.change(PP,1)    ppFlat= ppChange==0    priceOverPP=ta.crossover(price,PP)    priceUnderPP=ta.crossunder(price,PP)    risingPrice= ta.rising(price,5)    risingPP= ta.rising(PP,5)    fallingPrice= ta.falling(price,5)    fallingPP= ta.falling(PP,5)    uptrendCondition1= price>PP and (ppChange>0 or (ppChange==0 and aggressiveMode)) and (ppChange[1]>0 or (ppChange[1]==0 and aggressiveMode)) and ppChange[2]>=0 and ppChange[3]>=0    uptrendCondition2= (priceOverPP or risingPrice) and ppFlat and aggressiveMode    uptrendCondition3= risingPrice and fallingPP and aggressiveMode    downtrendCondition1= price < PP and (ppChange<0 or (ppChange==0 and aggressiveMode)) and (ppChange[1]<0 or (ppChange[1]==0 and aggressiveMode)) and ppChange[2]<=0 and ppChange[3]<=0    downtrendCondition2= (priceUnderPP or fallingPrice) and ppFlat and aggressiveMode    downtrendCondition3= fallingPrice and risingPP and aggressiveMode    if uptrendCondition1 or uptrendCondition2 or uptrendCondition3        uptrend:= true    else if downtrendCondition1 or downtrendCondition2 or downtrendCondition3        uptrend:= false    else        uptrend:= uptrend[1]    [PP,uptrend][trendline,uptrend]= isUptrend(price,length,aggressiveMode)baseLinePlot = plot((open + close) / 2, display=display.none)upTrendPlot = plot(uptrend ? trendline : na, "Up Trend", color = color.green, style=plot.style_linebr)downTrendPlot = plot(not uptrend ? trendline : na, "Down Trend", color = color.red, style=plot.style_linebr)fill(baseLinePlot, upTrendPlot, color.new(color.green, 90), fillgaps=false)fill(baseLinePlot, downTrendPlot, color.new(color.red, 90), fillgaps=false)buyCondition= window() and uptrend and uptrend[1] and strategy.position_size<=0sellCondition= window() and not uptrend and not uptrend[1] and strategy.position_size>=0firstTradePrice= close-closefirstTradePrice:= nz(firstTradePrice[1],0)if buyCondition    strategy.entry("Long", strategy.long)    if firstTradePrice==0        firstTradePrice:= closeelse if sellCondition    strategy.close("Long")end_time= time_close>timenowend_time:= time_close + (time_close - time_close[1]) > timenow or barstate.islastconfirmedhistoryprecision= 0if end_time    netprofit=math.round(strategy.netprofit,precision)    netprofitPercent=math.round(100*netprofit/strategy.initial_capital,precision)    bhprofit= math.round((strategy.initial_capital/firstTradePrice)*close-strategy.initial_capital,precision)    bhprofitPercent= math.round(100*bhprofit/strategy.initial_capital,precision)    openprofit=math.round(strategy.openprofit,precision)    trades= strategy.closedtrades    wins= strategy.wintrades    losses= strategy.losstrades    winColor= color.new(color.green, transp = 20)    loseColor= color.new(color.red, transp = 20)    neutralColor= color.new(color.silver, transp = 70)    testTable = table.new(position = position.bottom_right, columns = 2, rows = 4, border_width = 1)    table.cell(table_id = testTable, column = 0, row = 0, text = "Net Profit",  bgcolor = #cccccc)    table.cell(table_id = testTable, column = 1, row = 0, text = str.tostring(netprofit)+"\n"+str.tostring(netprofitPercent)+" %", bgcolor= netprofit>0?winColor:loseColor)    table.cell(table_id = testTable, column = 0, row = 1, text = "Buy & Hold",  bgcolor = #cccccc)    table.cell(table_id = testTable, column = 1, row = 1, text = str.tostring(bhprofit)+"\n"+str.tostring(bhprofitPercent)+" %", bgcolor= bhprofitPercent>0?winColor:loseColor)    table.cell(table_id = testTable, column = 0, row = 2, text = "Win / Loss",  bgcolor = #cccccc)    table.cell(table_id = testTable, column = 1, row = 2, text = str.tostring(wins)+" / "+str.tostring(losses), bgcolor=neutralColor)    table.cell(table_id = testTable, column = 0, row = 3, text = "Open PnL",  bgcolor = #cccccc)    table.cell(table_id = testTable, column = 1, row = 3, text = str.tostring(openprofit), bgcolor= openprofit==0?neutralColor:openprofit>0?winColor:loseColor)