Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Qullamaggie Breakout

A Pine Script v4 strategy built on ATR (14), Pivothigh (high, pvtLenL) and Pivotlow (low, pvtLenL). It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss. Each trade commits 100% of equity and pays 0.1% commission. 13 settings; defaults include Lookback Period for Swing High 3, Lookback Bars for Stop Level 3 and Timeframe of Moving Averages D.

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 Qullamaggie Breakout repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
How did Qullamaggie Breakout do on BTCUSDT 1D with default settings?
+61.35%
From 26 Jan 2024 to 21 Oct 2026, over 25 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Qullamaggie Breakout 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 Qullamaggie Breakout use a stop loss?
Yes
strategy.exit sets a stop on line 101.
Does Qullamaggie Breakout run in Zeal Terminal?
Yes
It compiles in 24 ms and runs 1,000 bars in 95 ms, in the browser.

BTCUSDT · 1D · default settings

  • MA1
  • MA2
  • MA3
  • Top Levels
  • Top Levels 2
  • Current Breakout Level
  • Current Stop Level
  • Historical Stop Levels
  • 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 (13)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$16,201$20,253Equity from $10,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
+61.35%
$6,134.91
Buy and hold
+102.5%
same period
Closed trades
25
9 won · 16 lost
Profitable
36.0%
of closed trades
Profit factor
1.93
gross profit ÷ gross loss
Max drawdown
20.24%
−$3,068.60

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

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • 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 100, 103. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 37

    transp = on line 37, 38, 39, 69, 71, 76, 96, 97. 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 ema → ta.ema, sma → ta.sma, security → request.security, atr → ta.atr, pivothigh → ta.pivothigh, pivotlow → ta.pivotlow, barssince → ta.barssince, change → ta.change, valuewhen → ta.valuewhen, crossover → ta.crossover, crossunder → ta.crossunder, lowest → ta.lowest.
  • 2 strategy calls use the when = argument (line 100, 103). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 8: //@version=4 → //@version=5
  • Line 13: input(type = input.time) → input.time()
  • Line 14: input(type = input.time) → input.time()
  • Line 20: input(type = input.resolution) → input.timeframe()
  • Line 27: input(type = input.bool) → input.bool()
  • Line 33: ema → ta.ema
26 more edits
  • Line 33: sma → ta.sma
  • Line 34: security → request.security
  • Line 35: security → request.security
  • Line 36: security → request.security
  • Line 37: transp = 60 → color.new(color.purple, 60)
  • Line 38: transp = 60 → color.new(color.yellow, 60)
  • Line 39: transp = 60 → color.new(color.white, 60)
  • Line 43: input(type = input.bool) → input.bool()
  • Line 47: security → request.security
  • Line 47: atr → ta.atr
  • Line 53: pivothigh → ta.pivothigh
  • Line 54: pivotlow → ta.pivotlow
  • Line 61: barssince → ta.barssince
  • Line 62: barssince → ta.barssince
  • Line 66: change → ta.change
  • Line 67: change → ta.change
  • Line 69: transp = 0 → color.new(hipc, 0)
  • Line 71: transp = 0 → color.new(hipc, 0)
  • Line 74: valuewhen → ta.valuewhen
  • Line 75: valuewhen → ta.valuewhen
  • Line 76: transp = 50 → color.new(color.blue, 50)
  • Line 84: crossover → ta.crossover
  • Line 86: crossunder → ta.crossunder
  • Line 91: lowest → ta.lowest
  • Line 96: transp = 50 → color.new(color.orange, 50)
  • Line 97: transp = 50 → color.new(color.orange, 50)
⋯// (If the difference between the breakout point and your stop level is below a certain % of ATR, it could possibly find those consolidating periods.)-//@version=4+//@version=5strategy("Qullamaggie Breakout", overlay=true, initial_capital=10000, currency='USD', ⋯// === BACKTEST RANGE ===-Start = input(defval = timestamp("01 Jan 2019 06:00 +0000"), title = "Backtest Start Date", type = input.time)+Start = input.time(defval = timestamp("01 Jan 2019 06:00 +0000"), title = "Backtest Start Date")-Finish = input(defval = timestamp("01 Jan 2100 00:00 +0000"), title = "Backtest End Date", type = input.time)+Finish = input.time(defval = timestamp("01 Jan 2100 00:00 +0000"), title = "Backtest End Date")// Inputs⋯   tooltip = "Initial stop placement is the lowest low this many bars back. Allows for tighter stop placement than referencing swing lows.")  -htf = input(defval="D", title="Timeframe of Moving Averages", type=input.resolution,+htf = input.timeframe(defval="D", title="Timeframe of Moving Averages",  tooltip = "Allows you to set a different time frame for the moving averages. The default behavior is to identify good tightening setups on a larger timeframe⋯ma3Length = input(defval = 50, title = "3rd Moving Average Length", minval = 1)-useMaFilter = input(title = "Use 3rd Moving Average for Filtering?", type = input.bool, defval = true,+useMaFilter = input.bool(title = "Use 3rd Moving Average for Filtering?", defval = true,  tooltip = "Signals will be ignored when price is under this slowest moving average.  The intent is to keep you out of bear periods and only⋯ma(maType, src, length) =>-    maType == "EMA" ? ema(src, length) : sma(src, length) //Ternary Operator (if maType equals EMA, then do ema calc, else do sma calc)+    maType == "EMA" ? ta.ema(src, length) : ta.sma(src, length) //Ternary Operator (if maType equals EMA, then do ema calc, else do sma calc)-ma1 = security(syminfo.tickerid, htf, ma(maType, close, ma1Length))+ma1 = request.security(syminfo.tickerid, htf, ma(maType, close, ma1Length))-ma2 = security(syminfo.tickerid, htf, ma(maType, close, ma2Length))+ma2 = request.security(syminfo.tickerid, htf, ma(maType, close, ma2Length))-ma3 = security(syminfo.tickerid, htf, ma(maType, close, ma3Length))+ma3 = request.security(syminfo.tickerid, htf, ma(maType, close, ma3Length))-plot(ma1, color=color.purple, style=plot.style_line, title="MA1", linewidth=2, transp = 60)+plot(ma1, color=color.new(color.purple, 60), style=plot.style_line, title="MA1", linewidth=2)-plot(ma2, color=color.yellow, style=plot.style_line, title="MA2", linewidth=2, transp = 60)+plot(ma2, color=color.new(color.yellow, 60), style=plot.style_line, title="MA2", linewidth=2)-plot(ma3, color=color.white, style=plot.style_line, title="MA3", linewidth=2, transp = 60)+plot(ma3, color=color.new(color.white, 60), style=plot.style_line, title="MA3", linewidth=2)// === USE ATR FOR FILTERING ===⋯// support/resistance vs.the ATR and make sure you aren't buying at a point that is too extended from normal.-useAtrFilter = input(title = "Use ATR for Filtering?", type = input.bool, defval = false,+useAtrFilter = input.bool(title = "Use ATR for Filtering?", defval = false,  tooltip = "Signals will be ignored if the distance between support and resistance is larger than a user-defined percentage of Daily ATR. ⋯atrPerc = input(defval = 100, title = "% of Daily ATR Value", minval = 1)-atrValue = security(syminfo.tickerid, "D", atr(14))*atrPerc*.01+atrValue = request.security(syminfo.tickerid, "D", ta.atr(14))*atrPerc*.01// === PLOT SWING HIGH/LOW AND MOST RECENT LOW TO USE AS STOP LOSS EXIT POINT ===⋯// Get High and Low Pivot Points-pvthi_ = pivothigh(high, pvtLenL, pvtLenR)+pvthi_ = ta.pivothigh(high, pvtLenL, pvtLenR)-pvtlo_ = pivotlow(low, pvtLenL, pvtLenR)+pvtlo_ = ta.pivotlow(low, pvtLenL, pvtLenR)// Force Pivot completion before plotting.⋯// Count How many candles for current Pivot Level, If new reset.-counthi = barssince(not na(pvthi))+counthi = ta.barssince(not na(pvthi))-countlo = barssince(not na(pvtlo))+countlo = ta.barssince(not na(pvtlo)) ⋯pvtlos = fixnan(pvtlo)-hipc = change(pvthis) != 0 ? na : color.maroon+hipc = ta.change(pvthis) != 0 ? na : color.maroon-lopc = change(pvtlos) != 0 ? na : color.green+lopc = ta.change(pvtlos) != 0 ? na : color.green// Display Pivot lines-plot((maxLvlLen == 0 or counthi < maxLvlLen) ? pvthis : na, color=hipc, transp=0, linewidth=1, offset=-pvtLenR-Shunt, title="Top Levels")+plot((maxLvlLen == 0 or counthi < maxLvlLen) ? pvthis : na, color=color.new(hipc, 0), linewidth=1, offset=-pvtLenR-Shunt, title="Top Levels")// plot((maxLvlLen == 0 or countlo < maxLvlLen) ? pvtlos : na, color=lopc, transp=0, linewidth=1, offset=-pvtLenR-Shunt, title="Bottom Levels")-plot((maxLvlLen == 0 or counthi < maxLvlLen) ? pvthis : na, color=hipc, transp=0, linewidth=1, offset=0, title="Top Levels 2")+plot((maxLvlLen == 0 or counthi < maxLvlLen) ? pvthis : na, color=color.new(hipc, 0), linewidth=1, offset=0, title="Top Levels 2")// plot((maxLvlLen == 0 or countlo < maxLvlLen) ? pvtlos : na, color=lopc, transp=0, linewidth=1, offset=0, title="Bottom Levels 2")// BUY CONDITIONS-stopLevelCalc = valuewhen(pvtlo_, low[pvtLenR], 0) //Stop Level at Swing Low+stopLevelCalc = ta.valuewhen(pvtlo_, low[pvtLenR], 0) //Stop Level at Swing Low-buyLevel = valuewhen(pvthi_, high[pvtLenR], 0) //Buy level at Swing High+buyLevel = ta.valuewhen(pvthi_, high[pvtLenR], 0) //Buy level at Swing High-plot(buyLevel, style=plot.style_line, color=color.blue, title = "Current Breakout Level", show_last=1, linewidth=1, transp=50, trackprice=true)+plot(buyLevel, style=plot.style_line, color=color.new(color.blue, 50), title = "Current Breakout Level", show_last=1, linewidth=1, trackprice=true)// Conditions for entry and exit⋯// buySignal = high > buyLevel and buyConditions-buySignal = crossover(high, buyLevel) and buyConditions+buySignal = ta.crossover(high, buyLevel) and buyConditionstrailMa = trailMaInput == "1st Moving Average" ? ma1 : ma2-sellSignal = crossunder(close, trailMa)+sellSignal = ta.crossunder(close, trailMa)// sellSignal = security(syminfo.tickerid, htf, close < trailMa) and security(syminfo.tickerid, htf, close[1] < trailMa)⋯inPosition := buySignal[1] ? true : sellSignal[1] ? false : low <= stopLevel[1] ? false : inPosition[1]-lowDefine = lowest(low, lbStop)+lowDefine = ta.lowest(low, lbStop)stopLevel := inPosition ? stopLevel[1] : lowDefine⋯buyPrice := inPosition ? buyPrice[1] : buyLevel-plot(stopLevel, style=plot.style_line, color=color.orange, title = "Current Stop Level", show_last=1, linewidth=1, transp=50, trackprice=true)+plot(stopLevel, style=plot.style_line, color=color.new(color.orange, 50), title = "Current Stop Level", show_last=1, linewidth=1, trackprice=true)-plot(inPosition ? stopLevel : na, style=plot.style_circles, color=color.orange, title = "Historical Stop Levels", transp=50, trackprice=false)+plot(inPosition ? stopLevel : na, style=plot.style_circles, color=color.new(color.orange, 50), title = "Historical Stop Levels", trackprice=false)// plot(buyPrice, style=plot.style_line, color=color.blue, linewidth=1, transp=50, trackprice=true)⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 16: input() → input.int()
  • Line 18: input() → input.int()
  • Line 23: input() → input.string()
  • Line 24: input() → input.int()
  • Line 25: input() → input.int()
  • Line 26: input() → input.int()
4 more edits
  • Line 30: input() → input.string()
  • Line 46: input() → input.int()
  • Line 100: when = buyConditions → if block
  • Line 103: when = sellSignal → if block
⋯// Inputs-lb = input(defval = 3, title = "Lookback Period for Swing High", minval = 1,+lb = input.int(defval = 3, title = "Lookback Period for Swing High", minval = 1,   tooltip = "Lookback period for defining the breakout level.")-lbStop = input(defval = 3, title = "Lookback Bars for Stop Level", minval = 1,+lbStop = input.int(defval = 3, title = "Lookback Bars for Stop Level", minval = 1,   tooltip = "Initial stop placement is the lowest low this many bars back. Allows for tighter stop placement than referencing swing lows.")  ⋯  (like daily) and enter the trade on a breakout occuring on a smaller timeframe, using the moving averages of the larger timeframe to trail your stop.")-maType = input(defval="SMA", options=["EMA", "SMA"], title = "Moving Average Type")+maType = input.string(defval="SMA", options=["EMA", "SMA"], title = "Moving Average Type")-ma1Length = input(defval = 10, title = "1st Moving Average Length", minval = 1)+ma1Length = input.int(defval = 10, title = "1st Moving Average Length", minval = 1)-ma2Length = input(defval = 20, title = "2nd Moving Average Length", minval = 1)+ma2Length = input.int(defval = 20, title = "2nd Moving Average Length", minval = 1)-ma3Length = input(defval = 50, title = "3rd Moving Average Length", minval = 1)+ma3Length = input.int(defval = 50, title = "3rd Moving Average Length", minval = 1)useMaFilter = input.bool(title = "Use 3rd Moving Average for Filtering?", defval = true,⋯             buying when price is showing strength or trading with the longer term trend.")-trailMaInput = input(defval="2nd Moving Average", options=["1st Moving Average", "2nd Moving Average"], title = "Trailing Stop")+trailMaInput = input.string(defval="2nd Moving Average", options=["1st Moving Average", "2nd Moving Average"], title = "Trailing Stop")// MA Calculations⋯             This allows the user to ensure they are not buying something that is too extended and instead focus on names that are consolidating more.")-atrPerc = input(defval = 100, title = "% of Daily ATR Value", minval = 1)+atrPerc = input.int(defval = 100, title = "% of Daily ATR Value", minval = 1)atrValue = request.security(syminfo.tickerid, "D", ta.atr(14))*atrPerc*.01⋯// (STRATEGY ONLY) Comment out for Study-strategy.entry("Long", strategy.long, stop = buyLevel, when = buyConditions)+if buyConditions+    strategy.entry("Long", strategy.long, stop = buyLevel)strategy.exit("Exit Long", from_entry = "Long", stop=stopLevel[1])if (low[1] > trailMa)-    strategy.close("Long", when = sellSignal)+    if sellSignal+        strategy.close("Long")// if (low[1] > trailMa)⋯

Does it run in Pine Script v6?

Yes

Same 25 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// (If the difference between the breakout point and your stop level is below a certain % of ATR, it could possibly find those consolidating periods.)-//@version=5+//@version=6strategy("Qullamaggie Breakout", overlay=true, initial_capital=10000, currency='USD', ⋯

Settings

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

SettingDefaultType and rangeFeeds
Backtest Start Datetimestamp("01 Jan 2019 06:00 +0000")timebuyConditions
Backtest End Datetimestamp("01 Jan 2100 00:00 +0000")timebuyConditions
Lookback Period for Swing HighLookback period for defining the breakout level.3int · min 1pvtLenL pvtLenR
Lookback Bars for Stop LevelInitial stop placement is the lowest low this many bars back. Allows for tighter stop placement than referencing swing lows.3int · min 1lowDefine
Timeframe of Moving AveragesAllows you to set a different time frame for the moving averages. The default behavior is to identify good tightening setups on a larger timeframe (like daily) and enter the trade on a breakout occuring on a smaller timeframe, using the moving averages of the larger timeframe to trail your stop.Dtimeframe (written input.resolution)ma1 ma2 ma3
Moving Average TypeSMAstring · options ["EMA", "SMA"]ma1 ma2 ma3 line 33
1st Moving Average Length10int · min 1ma1
2nd Moving Average Length20int · min 1ma2
3rd Moving Average Length50int · min 1ma3
Use 3rd Moving Average for Filtering?Signals will be ignored when price is under this slowest moving average. The intent is to keep you out of bear periods and only buying when price is showing strength or trading with the longer term trend.trueboolbuyConditions
Trailing Stop2nd Moving Averagestring · options ["1st Moving Average", "2nd Moving Average"]trailMa
Use ATR for Filtering?Signals will be ignored if the distance between support and resistance is larger than a user-defined percentage of Daily ATR. This allows the user to ensure they are not buying something that is too extended and instead focus on names that are consolidating more.falseboolbuyConditions
% of Daily ATR Value100int · min 1atrValue

What it calculates

  • ATR (atr, ta.atr in v5)14atrValue · line 47
  • Pivothigh (pivothigh, ta.pivothigh in v5)high, pvtLenL, pvtLenRpvthi_ · line 53
  • Pivotlow (pivotlow, ta.pivotlow in v5)low, pvtLenL, pvtLenRpvtlo_ · line 54
  • Valuewhen (valuewhen, ta.valuewhen in v5)pvtlo_, low[pvtLenR], 0stopLevelCalc · line 74
  • Valuewhen (valuewhen, ta.valuewhen in v5)pvthi_, high[pvtLenR], 0buyLevel · line 75
  • Crossunder (crossunder, ta.crossunder in v5)close, trailMasellSignal · line 86
  • Lowest (lowest, ta.lowest in v5)low, Lookback Bars for Stop Level (3)lowDefine · line 91

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.

high · low · closehigh · low · closeprice dataatrPerc% of Daily ATR Valuesetting · 100highhighprice datalowlowprice dataclosecloseprice datalbStopLookback Bars for Stop …setting · 3htfTimeframe of Moving Ave…setting · DmaTypeMoving Average Typesetting · SMAma1Length1st Moving Average Leng…setting · 10ma2Length2nd Moving Average Leng…setting · 20ma3Length3rd Moving Average Leng…setting · 50lbLookback Period for Swi…setting · 3timetimeprice dataStartBacktest Start Datesetting · timestamp("01 Jan 2…FinishBacktest End Datesetting · timestamp("01 Jan 2…trailMaInputTrailing Stopsetting · 2nd Moving AverageatrValueATR→ atrValuepvthi_Pivothigh→ pvthi_pvtlo_Pivotlow→ pvtlo_stopLevelCalcValuewhen→ stopLevelCalcbuyLevelValuewhen→ buyLevelsellSignalCrossunder→ sellSignallowDefineLowest→ lowDefinema1ma1valuema2ma2valuema3ma3valuepvtLenL, pvtLenRpvtLenL · pvtLenR2 valuespvthipvthivaluepvtlopvtlovaluepvthispvthisvaluepvtlospvtlosvaluestopLevelstopLevelvaluebuyConditionsbuyConditionsvaluetrailMatrailMavalueinPositioninPositionvaluebuyPricebuyPricevaluecounthicounthiconditioncountlocountloconditionbuySignalbuySignalconditionhipc, lopcColourhipc · lopcentry:LongOpen Longstrategy.entryexit:Exit Longexit Exit Longstrategy.exitclose:LongClose Longstrategy.closeplot:37MA1plotplot:38MA2plotplot:39MA3plotplot:69Top Levelsplotplot:71Top Levels 2plotplot:76Current Breakout Levelplotplot:96Current Stop Levelplotplot:97Historical Stop Levelsplot

Order rules

OrderFires whenBy defaultLine
Open Long longbuyConditionsOn100
Exit Exit Long stopevery barOn101
Close LongsellSignalOn103

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.

7/7trades 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 data4 security call(s), none with lookahead on.
  • 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+61.3%+102.5%2536%1.9320.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.8%+5.5%1916%0.9617.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+98.8%+9.8%1942%1.9920.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+6.5%+8.4%1520%1.3613.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−19.1%+16.7%2438%0.7841.4%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+26.0%+21.5%1233%2.449.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−57.3%+148.3%3123%0.3165.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+15.3%+17.1%825%2.718.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 market933%−$443.74
Sideways market1233%$3,355.80
Falling market450%$3,238.99

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

How bad could the drawdown be?

31.4%

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

0%36%
All 25 trades
SideEntryExitBarsP&L
long16 Mar 2024 69,499.8016 Mar 2024 68,555.000−$155.66
long17 Mar 2024 65,300.6017 Mar 2024 65,300.600−$19.67
long8 Apr 2024 71,769.5012 Apr 2024 67,447.804−$610.05
long15 May 2024 65,500.0012 Jun 2024 67,314.2028$236.31
long19 Jul 2024 63,987.9024 Jul 2024 65,777.005$244.83
long25 Jul 2024 65,376.0025 Jul 2024 65,376.000−$19.37
long27 Jul 2024 68,474.601 Aug 2024 64,628.005−$561.82
long23 Aug 2024 62,745.1027 Aug 2024 58,783.504−$592.55
long17 Sep 2024 60,625.002 Oct 2024 60,804.9015$8.21
long14 Oct 2024 64,478.2019 Dec 2024 99,205.0066$4,568.01
long6 Jan 2025 99,963.708 Jan 2025 96,954.602−$419.67
long17 Jan 2025 102,724.002 Feb 2025 96,500.0016−$792.03
long21 Apr 2025 86,496.4030 May 2025 105,590.0039$2,594.86
long9 Jun 2025 106,795.0013 Jun 2025 105,672.004−$180.90
long2 Jul 2025 108,952.001 Aug 2025 115,764.0030$863.71
long11 Aug 2025 119,800.0018 Aug 2025 116,299.007−$472.55
long18 Sep 2025 117,429.0022 Sep 2025 115,100.004−$320.16
long1 Oct 2025 117,900.0010 Oct 2025 111,561.009−$799.91
long2 Jan 2026 90,406.1025 Jan 2026 87,263.5023−$497.93
long16 Mar 2026 74,050.0019 Mar 2026 70,317.003−$683.87
long6 Apr 2026 69,310.0018 May 2026 77,457.7042$1,428.81
long14 Jul 2026 64,692.8025 Jul 2026 64,140.0011−$145.46
long9 Aug 2026 65,409.6010 Aug 2026 64,166.001−$286.75
long19 Aug 2026 65,474.5015 Sep 2026 76,046.6027$2,130.43
long18 Sep 2026 79,890.008 Oct 2026 83,321.8020$634.22

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
Qullamaggie Breakout this page—v4 strategy+61.3%2520.2%
Trendlines Strategy by tweakerIDlowest valuewhen atr pivothigh pivotlowv4 strategy+69.0%416.7%
The Only EURUSD Trading Strategy You Need - Kaspricci by Kaspricciatr pivothigh pivotlowv5 strategyNo trades on this market
Alert(), alertcondition() or strategy alerts- by Peter_Opivothigh pivotlow valuewhenv4 strategy+7,640,000.0%191919.9%
Quantitative Trend Strategy- Uptrend long by CheatCode1pivothigh pivotlow valuewhenv5 strategy+5.9%2832.8%
Moving Stop-Loss mechanism + alerts to MT4-MT5 by Peter_Opivothigh pivotlow valuewhenv5 strategy−9,857,600.0%1914,436.8%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 24 msWith a workaround 1,000 bars in 95 msNot measured
PineTSNo v5 and v6 only—Not 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. 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/// © millerrh// The intent of this strategy is to buy breakouts with a tight stop on smaller timeframes in the direction of the longer term trend.// Then use a trailing stop of a close below either the 10 MA or 20 MA (user choice) on that larger timeframe as the position // moves in your favor (i.e. whenever position price rises above the MA).// Option of using daily ATR as a measure of finding contracting ranges and ensuring a decent risk/reward.// (If the difference between the breakout point and your stop level is below a certain % of ATR, it could possibly find those consolidating periods.)//@version=4strategy("Qullamaggie Breakout", overlay=true, initial_capital=10000, currency='USD',    default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)   // === BACKTEST RANGE ===Start = input(defval = timestamp("01 Jan 2019 06:00 +0000"), title = "Backtest Start Date", type = input.time)Finish = input(defval = timestamp("01 Jan 2100 00:00 +0000"), title = "Backtest End Date", type = input.time)// Inputslb = input(defval = 3, title = "Lookback Period for Swing High", minval = 1,   tooltip = "Lookback period for defining the breakout level.")lbStop = input(defval = 3, title = "Lookback Bars for Stop Level", minval = 1,   tooltip = "Initial stop placement is the lowest low this many bars back. Allows for tighter stop placement than referencing swing lows.")  htf = input(defval="D", title="Timeframe of Moving Averages", type=input.resolution,  tooltip = "Allows you to set a different time frame for the moving averages. The default behavior is to identify good tightening setups on a larger timeframe  (like daily) and enter the trade on a breakout occuring on a smaller timeframe, using the moving averages of the larger timeframe to trail your stop.")maType = input(defval="SMA", options=["EMA", "SMA"], title = "Moving Average Type")ma1Length = input(defval = 10, title = "1st Moving Average Length", minval = 1)ma2Length = input(defval = 20, title = "2nd Moving Average Length", minval = 1)ma3Length = input(defval = 50, title = "3rd Moving Average Length", minval = 1)useMaFilter = input(title = "Use 3rd Moving Average for Filtering?", type = input.bool, defval = true,  tooltip = "Signals will be ignored when price is under this slowest moving average.  The intent is to keep you out of bear periods and only             buying when price is showing strength or trading with the longer term trend.")trailMaInput = input(defval="2nd Moving Average", options=["1st Moving Average", "2nd Moving Average"], title = "Trailing Stop")// MA Calculationsma(maType, src, length) =>    maType == "EMA" ? ema(src, length) : sma(src, length) //Ternary Operator (if maType equals EMA, then do ema calc, else do sma calc)ma1 = security(syminfo.tickerid, htf, ma(maType, close, ma1Length))ma2 = security(syminfo.tickerid, htf, ma(maType, close, ma2Length))ma3 = security(syminfo.tickerid, htf, ma(maType, close, ma3Length))plot(ma1, color=color.purple, style=plot.style_line, title="MA1", linewidth=2, transp = 60)plot(ma2, color=color.yellow, style=plot.style_line, title="MA2", linewidth=2, transp = 60)plot(ma3, color=color.white, style=plot.style_line, title="MA3", linewidth=2, transp = 60)// === USE ATR FOR FILTERING ===// The idea here is that you want to buy in a consolodating range for best risk/reward. So here you can compare the current distance between // support/resistance vs.the ATR and make sure you aren't buying at a point that is too extended from normal.useAtrFilter = input(title = "Use ATR for Filtering?", type = input.bool, defval = false,  tooltip = "Signals will be ignored if the distance between support and resistance is larger than a user-defined percentage of Daily ATR.              This allows the user to ensure they are not buying something that is too extended and instead focus on names that are consolidating more.")atrPerc = input(defval = 100, title = "% of Daily ATR Value", minval = 1)atrValue = security(syminfo.tickerid, "D", atr(14))*atrPerc*.01// === PLOT SWING HIGH/LOW AND MOST RECENT LOW TO USE AS STOP LOSS EXIT POINT ===// Change these values to adjust the look back and look forward periods for your swing high/low calculationspvtLenL = lbpvtLenR = lb// Get High and Low Pivot Pointspvthi_ = pivothigh(high, pvtLenL, pvtLenR)pvtlo_ = pivotlow(low, pvtLenL, pvtLenR)// Force Pivot completion before plotting.Shunt = 1 //Wait for close before printing pivot? 1 for true 0 for flasemaxLvlLen = 0 //Maximum Extension Lengthpvthi = pvthi_[Shunt]pvtlo = pvtlo_[Shunt]// Count How many candles for current Pivot Level, If new reset.counthi = barssince(not na(pvthi))countlo = barssince(not na(pvtlo)) pvthis = fixnan(pvthi)pvtlos = fixnan(pvtlo)hipc = change(pvthis) != 0 ? na : color.maroonlopc = change(pvtlos) != 0 ? na : color.green// Display Pivot linesplot((maxLvlLen == 0 or counthi < maxLvlLen) ? pvthis : na, color=hipc, transp=0, linewidth=1, offset=-pvtLenR-Shunt, title="Top Levels")// plot((maxLvlLen == 0 or countlo < maxLvlLen) ? pvtlos : na, color=lopc, transp=0, linewidth=1, offset=-pvtLenR-Shunt, title="Bottom Levels")plot((maxLvlLen == 0 or counthi < maxLvlLen) ? pvthis : na, color=hipc, transp=0, linewidth=1, offset=0, title="Top Levels 2")// plot((maxLvlLen == 0 or countlo < maxLvlLen) ? pvtlos : na, color=lopc, transp=0, linewidth=1, offset=0, title="Bottom Levels 2")// BUY CONDITIONSstopLevelCalc = valuewhen(pvtlo_, low[pvtLenR], 0) //Stop Level at Swing LowbuyLevel = valuewhen(pvthi_, high[pvtLenR], 0) //Buy level at Swing Highplot(buyLevel, style=plot.style_line, color=color.blue, title = "Current Breakout Level", show_last=1, linewidth=1, transp=50, trackprice=true)// Conditions for entry and exitstopLevel = float(na) // Define stop level here as "na" so that I can reference it in the inPosition   // variable and the ATR calculation before the stopLevel is actually defined.buyConditions = (useMaFilter ? buyLevel > ma3 : true) and  (useAtrFilter ? (buyLevel - stopLevel[1]) < atrValue : true) and  time > Start and time < Finish// buySignal = high > buyLevel and buyConditionsbuySignal = crossover(high, buyLevel) and buyConditionstrailMa = trailMaInput == "1st Moving Average" ? ma1 : ma2sellSignal = crossunder(close, trailMa)// sellSignal = security(syminfo.tickerid, htf, close < trailMa) and security(syminfo.tickerid, htf, close[1] < trailMa)// STOP AND PRICE LEVELSinPosition = bool(na)inPosition := buySignal[1] ? true : sellSignal[1] ? false : low <= stopLevel[1] ? false : inPosition[1]lowDefine = lowest(low, lbStop)stopLevel := inPosition ? stopLevel[1] : lowDefine// plot(stopLevel)buyPrice = buyLevelbuyPrice := inPosition ? buyPrice[1] : buyLevelplot(stopLevel, style=plot.style_line, color=color.orange, title = "Current Stop Level", show_last=1, linewidth=1, transp=50, trackprice=true)plot(inPosition ? stopLevel : na, style=plot.style_circles, color=color.orange, title = "Historical Stop Levels", transp=50, trackprice=false)// plot(buyPrice, style=plot.style_line, color=color.blue, linewidth=1, transp=50, trackprice=true)// (STRATEGY ONLY) Comment out for Studystrategy.entry("Long", strategy.long, stop = buyLevel, when = buyConditions)strategy.exit("Exit Long", from_entry = "Long", stop=stopLevel[1])if (low[1] > trailMa)    strategy.close("Long", when = sellSignal)// if (low[1] > trailMa)//     strategy.exit("Exit Long", from_entry = "Long", stop=trailMa) //to get this to work right, I need to reference highest highs instead of swing highs    //because it can have me buy right back in after selling if the stop level is above the last registered swing high point.