Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

longWickStrategy

A Pine Script v4 strategy with no technical-analysis calculation. It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 0.1% of equity and pays no commission. 7 settings; defaults include Backtest Start Year 2020, Backtest Start Month 01 and Backtest Start Day 01.

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 longWickStrategy repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did longWickStrategy do on BTCUSDT 1D with default settings?
−0.01%
From 26 Jan 2024 to 21 Oct 2026, over 37 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can longWickStrategy be converted to Pine Script v5?
No
The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
Does longWickStrategy use a stop loss?
Yes
strategy.exit sets a stop on line 38, 39.
Does longWickStrategy run in Zeal Terminal?
Yes
It compiles in 14 ms and runs 1,000 bars in 43 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • 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 (7)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$99,992$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
−0.01%
−$7.90
Buy and hold
+102.5%
same period
Closed trades
37
15 won · 22 lost
Profitable
40.5%
of closed trades
Profit factor
0.82
gross profit ÷ gross loss
Max drawdown
0.02%
−$20.24

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

  • Note

    Uses an argument v6 removed

    when = on line 32, 33. The upgraded version below moves each call inside an if block.

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 max → math.max, atr → ta.atr, abs → math.abs.
  • 2 strategy calls use the when = argument (line 32, 33). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Differs

Trades differ: 37 before, 37 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 24: max → math.max
  • Line 27: atr → ta.atr
  • Line 45: abs → math.abs
  • Line 47: abs → math.abs
⋯// © ondrej17-//@version=4+//@version=5strategy("longWickstrategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=0.1)⋯upperWick = (open > close) ? high-open : high-close-wickLength = max(lowerWick,upperWick)+wickLength = math.max(lowerWick,upperWick)candleLength = high-lowwickToCandleRatio = wickLength / candleLength-entryFilterCandleLength = candleLength > 0.75*atr(48)+entryFilterCandleLength = candleLength > 0.75*ta.atr(48)// Entries and Exits⋯plot(shortTP, color=color.green, style=plot.style_linebr, linewidth=2)-plotLongCondition = longCondition ? high+abs(open-close) : na+plotLongCondition = longCondition ? high+math.abs(open-close) : naplot(plotLongCondition, style=plot.style_circles, linewidth=4, color=color.green)-plotShortCondition = shortCondition ? high+abs(open-close) : na+plotShortCondition = shortCondition ? high+math.abs(open-close) : naplot(plotShortCondition, style=plot.style_circles, linewidth=4, color=color.red)

Clean v5

Verified

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

  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
  • Line 12: input() → input.int()
3 more edits
  • Line 13: input() → input.float()
  • Line 32: when = longCondition → if block
  • Line 33: when = shortCondition → if block
⋯// Inputs-st_yr_inp = input(defval=2020, title='Backtest Start Year')+st_yr_inp = input.int(defval=2020, title='Backtest Start Year')-st_mn_inp = input(defval=01, title='Backtest Start Month')+st_mn_inp = input.int(defval=01, title='Backtest Start Month')-st_dy_inp = input(defval=01, title='Backtest Start Day')+st_dy_inp = input.int(defval=01, title='Backtest Start Day')-en_yr_inp = input(defval=2025, title='Backtest End Year')+en_yr_inp = input.int(defval=2025, title='Backtest End Year')-en_mn_inp = input(defval=01, title='Backtest End Month')+en_mn_inp = input.int(defval=01, title='Backtest End Month')-en_dy_inp = input(defval=01, title='Backtest End Day')+en_dy_inp = input.int(defval=01, title='Backtest End Day')-sltp_inp = input(defval=0.8, title='N - % offset for N*SL and (2N)*TP')/100+sltp_inp = input.float(defval=0.8, title='N - % offset for N*SL and (2N)*TP')/100 ⋯shortCondition = entryFilterCandleLength and wickToCandleRatio > 0.5 and lowerWick < upperWick and canTrade and strategy.position_size == 0-strategy.entry("pendingLong", strategy.long, limit=low+wickLength/2, when = longCondition)+if longCondition+    strategy.entry("pendingLong", strategy.long, limit=low+wickLength/2)-strategy.entry("pendingShort", strategy.short, limit=high-wickLength/2, when = shortCondition)+if shortCondition+    strategy.entry("pendingShort", strategy.short, limit=high-wickLength/2)longStop = strategy.position_size > 0 ? strategy.position_avg_price*(1-sltp_inp) : na⋯

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

⋯// © ondrej17-//@version=5+//@version=6strategy("longWickstrategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=0.1)⋯

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 Year2020intstart
Backtest Start Month01intstart
Backtest Start Day01intstart
Backtest End Year2025intend
Backtest End Month01intend
Backtest End Day01intend
N - % offset for N*SL and (2N)*TP0.8floatlongStop longTP shortStop shortTP

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

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.

st_yr_inpBacktest Start Yearsetting · 2020st_mn_inpBacktest Start Monthsetting · 01st_dy_inpBacktest Start Daysetting · 01en_yr_inpBacktest End Yearsetting · 2025en_mn_inpBacktest End Monthsetting · 01en_dy_inpBacktest End Daysetting · 01lowlowprice dataclosecloseprice dataopenopenprice datahighhighprice datasltp_inpN - % offset for N*SL a…setting · 0.8timetimeprice datastartstartvalueendendvaluelowerWicklowerWickvalueupperWickupperWickvaluewickLengthwickLengthvaluecandleLengthcandleLengthvaluewickToCandleRatiowickToCandleRatiovaluelongStop, longTP, shortStop, shortTPlongStop · longTP +24 valuesplotLongConditionplotLongConditionvalueplotShortConditionplotShortConditionvaluelongConditionlongConditionconditionshortConditionshortConditionconditioncanTradecanTradeconditionentryFilterCandleLengthentryFilterCandleLengthconditionentry:pendingLongOpen pendingLongstrategy.entryentry:pendingShortOpen pendingShortstrategy.entryexit:longSLTPexit longSLTPstrategy.exitexit:shortSLTPexit shortSLTPstrategy.exitplot:41plotplotplot:42plotplotplot:43plotplotplot:44plotplotplot:46plotplotplot:48plotplot

Order rules

OrderFires whenBy defaultLine
Open pendingLong longlongConditionentryFilterCandleLength and wickToCandleRatio > 0.5 and lowerWick > upperWick and canTrade and strategy.position_size == 0On32
Open pendingShort shortshortConditionentryFilterCandleLength and wickToCandleRatio > 0.5 and lowerWick < upperWick and canTrade and strategy.position_size == 0On33
Exit longSLTP stop and limitevery barOn38
Exit shortSLTP stop and limitevery barOn39

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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−0.0%+102.5%3741%0.820.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.0%+9.8%3842%0.860.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%3540%0.640.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%3738%1.090.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.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 market1735%−$0.93
Sideways market1747%−$7.28
Falling market333%$0.31

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

How bad could the drawdown be?

0.0%

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

0%1%
All 37 trades
SideEntryExitBarsP&L
long15 Mar 2024 69,972.0016 Mar 2024 69,412.201−$0.80
short24 Mar 2024 64,994.5025 Mar 2024 67,210.001−$3.41
short27 Mar 2024 70,774.6028 Mar 2024 69,470.001$1.84
long12 Apr 2024 66,886.6013 Apr 2024 66,351.501−$0.80
long17 Apr 2024 62,510.0018 Apr 2024 61,277.401−$1.97
long26 Apr 2024 63,541.8027 Apr 2024 63,033.401−$0.80
long30 Apr 2024 62,442.101 May 2024 60,672.001−$2.83
short15 May 2024 64,756.0016 May 2024 66,206.501−$2.24
long28 May 2024 67,284.9029 May 2024 68,398.401$1.65
short3 Jun 2024 70,062.004 Jun 2024 68,809.901$1.79
long18 Jun 2024 65,817.2019 Jun 2024 65,175.301−$0.98
long8 Jul 2024 55,057.409 Jul 2024 56,714.601$3.01
short11 Jul 2024 58,760.0012 Jul 2024 57,339.901$2.42
long18 Jul 2024 63,548.7019 Jul 2024 64,565.401$1.60
long23 Jul 2024 67,046.0024 Jul 2024 65,936.001−$1.66
short26 Jul 2024 66,519.0027 Jul 2024 67,908.001−$2.09
short29 Jul 2024 68,654.0030 Jul 2024 66,784.701$2.72
long1 Aug 2024 64,416.302 Aug 2024 65,447.001$1.60
short8 Aug 2024 56,879.009 Aug 2024 61,686.001−$8.45
long11 Aug 2024 60,186.5012 Aug 2024 58,712.601−$2.45
short21 Aug 2024 60,419.3022 Aug 2024 61,156.001−$1.22
long1 Sep 2024 58,412.502 Sep 2024 57,301.801−$1.90
long5 Sep 2024 56,546.906 Sep 2024 56,094.501−$0.80
short13 Sep 2024 60,263.0015 Sep 2024 59,298.802$1.60
short24 Sep 2024 64,162.3025 Sep 2024 64,675.601−$0.80
short4 Oct 2024 61,597.605 Oct 2024 62,090.401−$0.80
short14 Oct 2024 63,649.1015 Oct 2024 66,084.001−$3.82
long25 Oct 2024 65,964.3026 Oct 2024 67,019.801$1.60
long4 Nov 2024 68,127.405 Nov 2024 67,582.301−$0.80
long13 Nov 2024 86,512.0014 Nov 2024 90,375.201$4.46
short19 Nov 2024 91,529.0020 Nov 2024 92,310.801−$0.85
long25 Nov 2024 96,703.6026 Nov 2024 93,010.001−$3.82
long4 Dec 2024 94,709.405 Dec 2024 98,587.301$4.09
long20 Dec 2024 95,424.8021 Dec 2024 97,805.401$2.49
long24 Dec 2024 93,700.7024 Dec 2024 98,673.000$5.04
long24 Dec 2024 93,700.7025 Dec 2024 98,663.601$0.27
short1 Jan 2025 94,913.002 Jan 2025 95,672.301−$0.80

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 14 msYes 1,000 bars in 43 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/// © ondrej17//@version=4strategy("longWickstrategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=0.1) // Inputsst_yr_inp = input(defval=2020, title='Backtest Start Year')st_mn_inp = input(defval=01, title='Backtest Start Month')st_dy_inp = input(defval=01, title='Backtest Start Day')en_yr_inp = input(defval=2025, title='Backtest End Year')en_mn_inp = input(defval=01, title='Backtest End Month')en_dy_inp = input(defval=01, title='Backtest End Day')sltp_inp = input(defval=0.8, title='N - % offset for N*SL and (2N)*TP')/100 // Datesstart = timestamp(st_yr_inp, st_mn_inp, st_dy_inp,00,00)end = timestamp(en_yr_inp, en_mn_inp, en_dy_inp,00,00)canTrade = time >= start and time <= end// Indicators Setup // Strategy CalcuationslowerWick = (open > close) ? close-low : open - lowupperWick = (open > close) ? high-open : high-closewickLength = max(lowerWick,upperWick)candleLength = high-lowwickToCandleRatio = wickLength / candleLengthentryFilterCandleLength = candleLength > 0.75*atr(48)// Entries and Exits longCondition = entryFilterCandleLength and wickToCandleRatio > 0.5 and lowerWick > upperWick and canTrade and strategy.position_size == 0shortCondition = entryFilterCandleLength and wickToCandleRatio > 0.5 and lowerWick < upperWick and canTrade and strategy.position_size == 0strategy.entry("pendingLong", strategy.long, limit=low+wickLength/2, when = longCondition)strategy.entry("pendingShort", strategy.short, limit=high-wickLength/2, when = shortCondition)longStop = strategy.position_size > 0 ? strategy.position_avg_price*(1-sltp_inp) : nalongTP = strategy.position_size > 0 ? strategy.position_avg_price*(1+2*sltp_inp) : nashortStop = strategy.position_size < 0 ? strategy.position_avg_price*(1+sltp_inp) : nashortTP = strategy.position_size < 0 ? strategy.position_avg_price*(1-2*sltp_inp) : nastrategy.exit("longSLTP","pendingLong", stop=longStop, limit = longTP)strategy.exit("shortSLTP","pendingShort", stop=shortStop, limit = shortTP)   plot(longStop, color=color.red, style=plot.style_linebr, linewidth=2)plot(shortStop, color=color.red, style=plot.style_linebr, linewidth=2)plot(longTP, color=color.green, style=plot.style_linebr, linewidth=2)plot(shortTP, color=color.green, style=plot.style_linebr, linewidth=2)plotLongCondition = longCondition ? high+abs(open-close) : naplot(plotLongCondition, style=plot.style_circles, linewidth=4, color=color.green)plotShortCondition = shortCondition ? high+abs(open-close) : naplot(plotShortCondition, style=plot.style_circles, linewidth=4, color=color.red)