Zeal Terminal Open in Zeal Terminal

Pine Script v3 · Strategy

Legacy

Buy the Dips (by Coinrule)

A Pine Script v3 strategy with no technical-analysis calculation. It has 2 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 30% of equity and pays 0.1% commission. 11 settings; defaults include From Month 1, From Day 10 and From Year 2020.

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 Buy the Dips (by Coinrule) repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 28 of 28 trades.
How did Buy the Dips (by Coinrule) do on BTCUSDT 1D with default settings?
+10.13%
From 26 Jan 2024 to 21 Oct 2026, over 105 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Buy the Dips (by Coinrule) be converted to Pine Script v5?
No
The automatic step from v3 to v4 changes the results, so no v4 download is offered; the edits are shown below.
Does Buy the Dips (by Coinrule) use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Buy the Dips (by Coinrule) run in Zeal Terminal?
Yes
It compiles in 11 ms and runs 1,000 bars in 38 ms, in the browser.

BTCUSDT · 1D · default settings

  • 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 (11)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,101$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. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 24) so the engine trades the way the script says.
Net profit
+10.13%
$101.35
Buy and hold
+102.5%
same period
Closed trades
105
56 won · 49 lost
Profitable
53.3%
of closed trades
Profit factor
1.17
gross profit ÷ gross loss
Max drawdown
8.08%
−$87.45

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

    “Show Date Range” is declared but never read.

  • Check

    No stop loss

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

  • Note

    3 settings have no label

    In the settings dialog dip (line 23), Stop_loss (line 26), Take_profit (line 27) show 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.

  • Note

    Uses an argument v6 removed

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

Upgrade and export

Written in Pine Script v3. The upgrade to v5 takes 2 steps, 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.

  • 2 strategy calls use the when = argument (line 24, 30). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v3 → v4

Differs

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

  • Line 3: //@version=3 → //@version=4
⋯// © Coinrule-//@version=3+//@version=4strategy(shorttitle='Buy the Dips',title='Buy the Dips (by Coinrule)', overlay=true, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)⋯

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 24: long = true → direction = strategy.long
⋯// © Coinrule-//@version=4+//@version=5strategy(shorttitle='Buy the Dips',title='Buy the Dips (by Coinrule)', overlay=true, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)⋯dip= -(input(2))-strategy.entry(id="long", long = true, when = overall< dip and window()) +strategy.entry(id="long", direction = strategy.long, when = overall< dip and window()) //Exit⋯

Clean v5

Verified

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

  • Line 6: input() → input.int()
  • 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()
7 more edits
  • Line 12: input() → input.bool()
  • Line 16: input() → input.int()
  • Line 23: input() → input.int()
  • Line 24: when = overall< dip and window() → if block
  • Line 26: input() → input.int()
  • Line 27: input() → input.int()
  • Line 30: when = close < longStopPrice or close > longTakeProfit and window() → if block
⋯//Backtest dates-fromMonth = input(defval = 1,  title = "From Month")     +fromMonth = input.int(defval = 1,  title = "From Month")     -fromDay   = input(defval = 10,    title = "From Day")       +fromDay   = input.int(defval = 10,    title = "From Day")       -fromYear  = input(defval = 2020, title = "From Year")       +fromYear  = input.int(defval = 2020, title = "From Year")       -thruMonth = input(defval = 1,    title = "Thru Month")     +thruMonth = input.int(defval = 1,    title = "Thru Month")     -thruDay   = input(defval = 1,    title = "Thru Day")     +thruDay   = input.int(defval = 1,    title = "Thru Day")     -thruYear  = input(defval = 2112, title = "Thru Year")       +thruYear  = input.int(defval = 2112, title = "Thru Year")       -showDate  = input(defval = true, title = "Show Date Range")+showDate  = input.bool(defval = true, title = "Show Date Range")start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)        // backtest start window⋯window()  => time >= start and time <= finish ? true : false       // create function "within window of time"-inp_lkb = input(1, title='Lookback Period')+inp_lkb = input.int(1, title='Lookback Period') ⋯//Entry-dip= -(input(2))+dip= -(input.int(2))-strategy.entry(id="long", direction = strategy.long, when = overall< dip and window()) +if overall< dip and window()+    strategy.entry(id="long", direction = strategy.long) //Exit-Stop_loss= ((input (2))/100)+Stop_loss= ((input.int (2))/100)-Take_profit= ((input (2))/100)+Take_profit= ((input.int (2))/100)longStopPrice  = strategy.position_avg_price * (1 - Stop_loss)longTakeProfit = strategy.position_avg_price * (1 + Take_profit)-strategy.close("long", when = close < longStopPrice or close > longTakeProfit and window())+if close < longStopPrice or close > longTakeProfit and window()+    strategy.close("long")

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

⋯// © Coinrule-//@version=5+//@version=6strategy(shorttitle='Buy the Dips',title='Buy the Dips (by Coinrule)', overlay=true, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_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
From Month1intstart
From Day10intstart
From Year2020intstart
Thru Month1intfinish
Thru Day1intfinish
Thru Year2112intfinish
Show Date Rangetrueboolunused
Lookback Period1intoverall
Dip (no label in the script)2intentry long
Stop loss (no label in the script)2intlongStopPrice
Take profit (no label in the script)2intlongTakeProfit

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.

fromYearFrom Yearsetting · 2020fromMonthFrom Monthsetting · 1fromDayFrom Daysetting · 10thruYearThru Yearsetting · 2112thruMonthThru Monthsetting · 1thruDayThru Daysetting · 1closecloseprice datainp_lkbLookback Periodsetting · 1Stop_lossStop losssetting · 2Take_profitTake profitsetting · 2dipDipsetting · 2startstartvaluefinishfinishvalueoverall_changeoverall_changevalueoveralloverallvaluelongStopPricelongStopPricevaluelongTakeProfitlongTakeProfitvalueentry:longOpen longstrategy.entryclose:longClose longstrategy.close

Order rules

OrderFires whenBy defaultLine
Open long longoverall< dip and window()On24
Close longclose < longStopPrice or close > longTakeProfit and window()On30

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.

28/28trades 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 calc_on_every_tick. 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+10.1%+102.5%10553%1.178.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.7%+5.5%1060%1.212.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+17.1%+9.8%16057%1.1515.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+3.0%+8.4%2665%1.334.3%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−33.1%+16.7%17943%0.7337.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−6.1%+21.5%2941%0.617.9%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.9%+148.3%10851%1.0113.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.1%+17.1%1354%0.994.3%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 market3256%$74.31
Sideways market4652%−$45.99
Falling market2752%$73.02

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

How bad could the drawdown be?

15.4%

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

0%18%
All 105 trades
SideEntryExitBarsP&L
long1 Mar 2024 61,131.002 Mar 2024 62,387.901$5.56
long6 Mar 2024 63,724.007 Mar 2024 66,074.001$10.51
long15 Mar 2024 71,388.9016 Mar 2024 69,499.801−$8.67
long17 Mar 2024 65,300.6018 Mar 2024 68,393.501$13.70
long20 Mar 2024 61,937.4021 Mar 2024 67,840.501$28.55
long22 Mar 2024 65,501.3023 Mar 2024 63,796.601−$8.82
long2 Apr 2024 69,649.803 Apr 2024 65,464.001−$19.37
long10 Apr 2024 69,146.0011 Apr 2024 70,631.101$5.96
long13 Apr 2024 67,116.5014 Apr 2024 63,924.501−$15.26
long16 Apr 2024 63,420.0018 Apr 2024 61,277.402−$10.86
long25 Apr 2024 64,289.601 May 2024 60,672.006−$17.49
long2 May 2024 58,365.004 May 2024 62,882.002$22.23
long11 May 2024 60,800.0014 May 2024 62,940.103$10.01
long15 May 2024 61,577.5016 May 2024 66,206.501$22.28
long8 Jun 2024 69,355.6012 Jun 2024 67,314.204−$9.78
long14 Jun 2024 66,773.0019 Jun 2024 65,175.305−$7.99
long25 Jun 2024 60,293.3026 Jun 2024 61,806.001$7.06
long29 Jun 2024 60,427.801 Jul 2024 62,772.002$11.33
long4 Jul 2024 60,208.605 Jul 2024 57,050.001−$16.96
long8 Jul 2024 55,857.8010 Jul 2024 58,050.002$11.41
long24 Jul 2024 65,936.0027 Jul 2024 67,908.003$8.64
long30 Jul 2024 66,784.701 Aug 2024 64,628.002−$10.71
long3 Aug 2024 61,498.305 Aug 2024 58,161.002−$17.39
long6 Aug 2024 54,018.807 Aug 2024 56,022.001$10.66
long12 Aug 2024 58,712.6014 Aug 2024 60,587.202$9.19
long15 Aug 2024 58,683.4022 Aug 2024 61,156.007$12.43
long27 Aug 2024 62,834.0028 Aug 2024 59,415.001−$17.69
long2 Sep 2024 57,301.803 Sep 2024 59,132.101$9.23
long4 Sep 2024 57,487.706 Sep 2024 56,180.002−$7.70
long7 Sep 2024 53,963.0010 Sep 2024 57,042.003$17.00
long1 Oct 2024 63,327.602 Oct 2024 60,804.901−$13.13
long10 Oct 2024 60,636.0012 Oct 2024 62,540.002$9.11
long22 Oct 2024 67,377.5029 Oct 2024 69,962.207$11.37
long1 Nov 2024 70,292.004 Nov 2024 68,776.003−$7.45
long15 Nov 2024 87,325.6016 Nov 2024 91,032.101$12.69
long26 Nov 2024 93,010.0028 Nov 2024 95,863.102$9.11
long10 Dec 2024 97,276.5012 Dec 2024 101,125.002$12.03
long19 Dec 2024 100,204.0020 Dec 2024 97,461.901−$9.51
long23 Dec 2024 95,186.3025 Dec 2024 98,663.602$11.09
long27 Dec 2024 95,791.6030 Dec 2024 93,738.203−$7.60
long8 Jan 2025 96,954.6010 Jan 2025 92,552.502−$15.27
long20 Jan 2025 101,332.0022 Jan 2025 106,144.002$14.44
long23 Jan 2025 103,707.0029 Jan 2025 101,336.006−$8.00
long1 Feb 2025 102,430.003 Feb 2025 97,700.602−$15.39
long5 Feb 2025 97,763.1012 Feb 2025 95,778.207−$7.02
long22 Feb 2025 96,182.0025 Feb 2025 91,552.903−$15.68
long26 Feb 2025 88,680.4027 Feb 2025 84,250.101−$16.01
long4 Mar 2025 86,221.206 Mar 2025 90,606.002$14.81
long8 Mar 2025 86,801.7010 Mar 2025 80,734.502−$22.12
long11 Mar 2025 78,595.9012 Mar 2025 82,933.001$16.01
long14 Mar 2025 81,115.8015 Mar 2025 83,983.201$10.20
long17 Mar 2025 82,574.5020 Mar 2025 86,845.903$15.36
long21 Mar 2025 84,223.4024 Mar 2025 86,082.503$6.29
long29 Mar 2025 84,424.4030 Mar 2025 82,648.501−$7.27
long3 Apr 2025 82,516.307 Apr 2025 78,430.004−$16.14
long9 Apr 2025 76,322.4010 Apr 2025 82,615.201$24.81
long11 Apr 2025 79,607.3012 Apr 2025 83,423.801$14.51
long24 May 2025 107,318.0031 May 2025 103,985.007−$10.58
long6 Jun 2025 101,509.007 Jun 2025 104,288.001$8.05
long13 Jun 2025 105,672.0021 Jun 2025 103,298.008−$7.81
long2 Aug 2025 113,298.008 Aug 2025 117,472.006$11.05
long15 Aug 2025 118,295.0020 Aug 2025 112,873.005−$15.33
long26 Aug 2025 110,112.0029 Aug 2025 112,567.003$6.41
long30 Aug 2025 108,377.003 Sep 2025 111,240.004$7.76
long23 Sep 2025 112,651.0026 Sep 2025 108,994.003−$11.03
long8 Oct 2025 121,333.0011 Oct 2025 112,774.003−$22.98
long16 Oct 2025 110,763.0017 Oct 2025 108,194.001−$7.81
long22 Oct 2025 108,298.0025 Oct 2025 111,005.003$7.07
long30 Oct 2025 110,021.004 Nov 2025 106,583.005−$10.30
long5 Nov 2025 101,497.006 Nov 2025 103,885.001$6.60
long7 Nov 2025 101,346.0010 Nov 2025 104,723.003$9.66
long12 Nov 2025 103,059.0014 Nov 2025 99,692.002−$10.80
long15 Nov 2025 94,594.0018 Nov 2025 92,215.103−$8.37
long21 Nov 2025 86,637.2023 Nov 2025 84,739.802−$7.31
long2 Dec 2025 86,286.003 Dec 2025 91,277.901$16.95
long6 Dec 2025 89,330.0010 Dec 2025 92,678.804$10.95
long13 Dec 2025 90,268.4015 Dec 2025 88,172.202−$7.87
long8 Jan 2026 91,364.2014 Jan 2026 95,414.006$13.10
long21 Jan 2026 88,427.7030 Jan 2026 84,650.209−$14.02
long1 Feb 2026 78,741.102 Feb 2026 76,968.201−$7.58
long4 Feb 2026 75,770.205 Feb 2026 73,165.801−$11.16
long6 Feb 2026 62,909.907 Feb 2026 70,580.301$36.41
long12 Feb 2026 67,082.5014 Feb 2026 68,854.002$7.68
long18 Feb 2026 67,503.5024 Feb 2026 64,656.006−$14.00
long28 Feb 2026 65,872.103 Mar 2026 68,830.103$13.41
long6 Mar 2026 70,891.007 Mar 2026 68,114.001−$13.04
long19 Mar 2026 71,246.6022 Mar 2026 68,918.103−$10.85
long27 Mar 2026 68,820.3028 Mar 2026 66,407.301−$11.47
long13 Apr 2026 70,741.6014 Apr 2026 74,418.001$15.29
long20 Apr 2026 73,801.8021 Apr 2026 75,841.001$7.96
long16 May 2026 79,113.2018 May 2026 77,457.702−$7.18
long23 May 2026 75,539.5025 May 2026 77,065.002$5.65
long2 Jun 2026 71,408.903 Jun 2026 66,760.801−$20.97
long4 Jun 2026 64,142.806 Jun 2026 61,056.502−$15.35
long10 Jun 2026 61,730.0012 Jun 2026 63,626.002$8.66
long19 Jun 2026 62,958.0021 Jun 2026 64,298.002$5.87
long24 Jun 2026 62,734.6025 Jun 2026 61,078.001−$8.69
long26 Jun 2026 59,794.603 Jul 2026 61,560.007$8.35
long14 Jul 2026 62,334.5015 Jul 2026 65,044.001$12.68
long28 Jul 2026 63,755.9020 Aug 2026 69,334.8023$26.48
long29 Aug 2026 77,845.904 Sep 2026 81,270.406$13.34
long11 Sep 2026 76,568.7015 Sep 2026 78,189.204$6.16
long16 Sep 2026 75,644.5019 Sep 2026 80,883.903$21.76
long24 Sep 2026 84,397.605 Oct 2026 86,530.0011$7.68
long8 Oct 2026 83,321.8017 Oct 2026 81,615.909−$7.47

Similar scripts

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

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 11 msWith a workaround 1,000 bars in 38 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 24) so the engine trades the way the script says.

“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/// © Coinrule//@version=3strategy(shorttitle='Buy the Dips',title='Buy the Dips (by Coinrule)', overlay=true, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)//Backtest datesfromMonth = input(defval = 1,  title = "From Month")     fromDay   = input(defval = 10,    title = "From Day")       fromYear  = input(defval = 2020, title = "From Year")       thruMonth = input(defval = 1,    title = "Thru Month")     thruDay   = input(defval = 1,    title = "Thru Day")     thruYear  = input(defval = 2112, title = "Thru Year")       showDate  = input(defval = true, title = "Show Date Range")start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)        // backtest start windowfinish    = timestamp(thruYear, thruMonth, thruDay, 23, 59)        // backtest finish windowwindow()  => time >= start and time <= finish ? true : false       // create function "within window of time"inp_lkb = input(1, title='Lookback Period') perc_change(lkb) =>    overall_change = ((close[0] - close[lkb]) / close[lkb]) * 100// Call the function    overall = perc_change(inp_lkb)//Entrydip= -(input(2))strategy.entry(id="long", long = true, when = overall< dip and window()) //ExitStop_loss= ((input (2))/100)Take_profit= ((input (2))/100)longStopPrice  = strategy.position_avg_price * (1 - Stop_loss)longTakeProfit = strategy.position_avg_price * (1 + Take_profit)strategy.close("long", when = close < longStopPrice or close > longTakeProfit and window())