Pine Script v1 · Strategy
LegacyMulti Time Frame Buy the Dips (by Coinrule)
A Pine Script v1 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. 13 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 Multi Time Frame 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 12 of 12 trades.
- How did Multi Time Frame Buy the Dips (by Coinrule) do on BTCUSDT 1D with default settings?
- −4.17%
- From 26 Jan 2024 to 21 Oct 2026, over 38 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Multi Time Frame Buy the Dips (by Coinrule) be converted to Pine Script v5?
- No
- The automatic step from v1 to v2 changes the results, so no v2 download is offered; the edits are shown below.
- Does Multi Time Frame 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 Multi Time Frame Buy the Dips (by Coinrule) run in Zeal Terminal?
- Yes
- It compiles in 13 ms and runs 1,000 bars in 42 ms, in the browser.
BTCUSDT · 1D · default settings
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −4.17%
- −$41.66
- Buy and hold
- +102.5%
- same period
- Closed trades
- 38
- 17 won · 21 lost
- Profitable
- 44.7%
- of closed trades
- Profit factor
- 0.86
- gross profit ÷ gross loss
- Max drawdown
- 12.75%
- −$133.75
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
4 settings have no label
In the settings dialog dip (line 25), increase (line 26), Stop_loss (line 29), Take_profit (line 30) 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 27, 33. The upgraded version below moves each call inside an if block.
Upgrade and export
Written in Pine Script v1. The upgrade to v5 takes 4 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 27, 33). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v1 → v2
DiffersTrades differ: 38 before, 38 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=1 → //@version=2
⋯// © Coinrule-//@version=1+//@version=2strategy(shorttitle='Multi Time Frame Buy the Dips',title='Multi Time Frame 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)⋯v2 → v3
VerifiedSame 38 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=2 → //@version=3
⋯// © Coinrule-//@version=2+//@version=3strategy(shorttitle='Multi Time Frame Buy the Dips',title='Multi Time Frame 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)⋯v3 → v4
DiffersTrades differ: 38 before, 38 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=3 → //@version=4
⋯// © Coinrule-//@version=3+//@version=4strategy(shorttitle='Multi Time Frame Buy the Dips',title='Multi Time Frame 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
VerifiedSame 38 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 27: long = true → direction = strategy.long
⋯// © Coinrule-//@version=4+//@version=5strategy(shorttitle='Multi Time Frame Buy the Dips',title='Multi Time Frame 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)⋯increase= (input(3))-strategy.entry(id="long", long = true, when = overall > increase and overall_2 < dip and window()) +strategy.entry(id="long", direction = strategy.long, when = overall > increase and overall_2 < dip and window()) //Exit⋯Clean v5
VerifiedSame 38 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()
9 more edits
- Line 12: input() → input.bool()
- Line 16: input() → input.int()
- Line 17: input() → input.int()
- Line 25: input() → input.int()
- Line 26: input() → input.int()
- Line 27: when = overall > increase and overall_2 < dip and window() → if block
- Line 29: input() → input.int()
- Line 30: input() → input.int()
- Line 33: 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(12, title='Lookback Long Period')+inp_lkb = input.int(12, title='Lookback Long Period')-inp_lkb_2 = input(2, title='Lookback Short Period')+inp_lkb_2 = input.int(2, title='Lookback Short Period') ⋯//Entry-dip= -(input(1))+dip= -(input.int(1))-increase= (input(3))+increase= (input.int(3))-strategy.entry(id="long", direction = strategy.long, when = overall > increase and overall_2 < dip and window()) +if overall > increase and overall_2 < dip and window()+ strategy.entry(id="long", direction = strategy.long) //Exit-Stop_loss= ((input (3))/100)+Stop_loss= ((input.int (3))/100)-Take_profit= ((input (4))/100)+Take_profit= ((input.int (4))/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
Same 38 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. The v6 version matches the upgraded v5 version, but the upgrade from the original already changed the results, so 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='Multi Time Frame Buy the Dips',title='Multi Time Frame 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| From Month | 1 | int | start |
| From Day | 10 | int | start |
| From Year | 2020 | int | start |
| Thru Month | 1 | int | finish |
| Thru Day | 1 | int | finish |
| Thru Year | 2112 | int | finish |
| Show Date Range | true | bool | unused |
| Lookback Long Period | 12 | int | overall |
| Lookback Short Period | 2 | int | overall_2 |
| Dip (no label in the script) | 1 | int | entry long |
| Increase (no label in the script) | 3 | int | entry long |
| Stop loss (no label in the script) | 3 | int | longStopPrice |
| Take profit (no label in the script) | 4 | int | longTakeProfit |
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open long long | overall > increase and overall_2 < dip and window() | On | 27 |
| Close long | close < longStopPrice or close > longTakeProfit and window() | On | 33 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −4.2% | +102.5% | 38 | 45% | 0.86 | 12.8% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −1.3% | +5.5% | 6 | 33% | 0.68 | 2.7% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −3.6% | +9.8% | 46 | 43% | 0.92 | 15.3% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +2.0% | +8.4% | 8 | 50% | 1.48 | 2.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −3.2% | +16.7% | 71 | 42% | 0.95 | 16.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.7% | +21.5% | 14 | 43% | 1.09 | 4.3% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −3.8% | +148.3% | 47 | 45% | 0.91 | 13.2% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.1% | +17.1% | 6 | 50% | 1.04 | 2.5% | 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 16 | 44% | −$23.67 |
| Sideways market | 15 | 40% | −$41.59 |
| Falling market | 7 | 57% | $23.60 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
15.0%
The 95th percentile of the worst drawdown when the same 38 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 7.1% to 15.0%; the tick is what actually happened, 12.0%. Order luck alone moves it this much.
All 38 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 23 Feb 2024 51,288.40 | 27 Feb 2024 54,476.50 | 4 | $18.03 |
| long | 7 Mar 2024 66,074.00 | 11 Mar 2024 68,955.90 | 4 | $12.70 |
| long | 16 Mar 2024 69,499.80 | 17 Mar 2024 65,300.60 | 1 | −$19.28 |
| long | 18 Mar 2024 68,393.50 | 20 Mar 2024 61,937.40 | 2 | −$29.22 |
| long | 4 Apr 2024 65,963.30 | 7 Apr 2024 68,896.00 | 3 | $12.50 |
| long | 20 May 2024 66,274.00 | 21 May 2024 71,446.60 | 1 | $22.67 |
| long | 23 May 2024 69,166.60 | 14 Jun 2024 66,773.00 | 22 | −$11.16 |
| long | 19 Jul 2024 63,987.90 | 20 Jul 2024 66,660.00 | 1 | $11.99 |
| long | 24 Jul 2024 65,936.00 | 3 Aug 2024 61,498.30 | 10 | −$21.15 |
| long | 27 Aug 2024 62,834.00 | 28 Aug 2024 59,415.00 | 1 | −$16.86 |
| long | 22 Oct 2024 67,377.50 | 30 Oct 2024 72,736.40 | 8 | $22.78 |
| long | 18 Nov 2024 89,856.00 | 21 Nov 2024 94,286.60 | 3 | $14.22 |
| long | 25 Nov 2024 97,900.10 | 26 Nov 2024 93,010.00 | 1 | −$15.84 |
| long | 27 Nov 2024 91,965.20 | 28 Nov 2024 95,863.10 | 1 | $12.12 |
| long | 20 Jan 2025 101,332.00 | 22 Jan 2025 106,144.00 | 2 | $13.82 |
| long | 24 Jan 2025 103,910.00 | 2 Feb 2025 100,636.00 | 9 | −$10.32 |
| long | 22 Mar 2025 84,088.80 | 25 Mar 2025 87,498.20 | 3 | $11.75 |
| long | 13 May 2025 102,791.00 | 22 May 2025 109,644.00 | 9 | $19.94 |
| long | 24 May 2025 107,318.00 | 31 May 2025 103,985.00 | 7 | −$10.39 |
| long | 12 Jun 2025 108,645.00 | 18 Jun 2025 104,551.00 | 6 | −$12.35 |
| long | 16 Jul 2025 117,758.00 | 2 Aug 2025 113,298.00 | 17 | −$12.26 |
| long | 15 Aug 2025 118,295.00 | 20 Aug 2025 112,873.00 | 5 | −$14.53 |
| long | 21 Sep 2025 115,686.00 | 24 Sep 2025 111,999.00 | 3 | −$10.14 |
| long | 8 Oct 2025 121,333.00 | 11 Oct 2025 112,774.00 | 3 | −$21.50 |
| long | 29 Oct 2025 112,898.00 | 31 Oct 2025 108,323.00 | 2 | −$12.33 |
| long | 14 Dec 2025 90,240.00 | 16 Dec 2025 86,432.10 | 2 | −$12.65 |
| long | 8 Jan 2026 91,364.20 | 14 Jan 2026 95,414.00 | 6 | $11.96 |
| long | 17 Jan 2026 95,550.90 | 20 Jan 2026 92,631.00 | 3 | −$9.31 |
| long | 18 Feb 2026 67,503.50 | 24 Feb 2026 64,656.00 | 6 | −$12.52 |
| long | 8 Mar 2026 67,262.90 | 12 Mar 2026 70,191.90 | 4 | $11.61 |
| long | 19 Mar 2026 71,246.60 | 22 Mar 2026 68,918.10 | 3 | −$9.82 |
| long | 13 Apr 2026 70,741.60 | 14 Apr 2026 74,418.00 | 1 | $13.99 |
| long | 8 May 2026 80,006.00 | 18 May 2026 77,457.70 | 10 | −$9.62 |
| long | 18 Jun 2026 64,509.40 | 25 Jun 2026 61,078.00 | 7 | −$15.53 |
| long | 9 Jul 2026 62,290.00 | 15 Jul 2026 65,044.00 | 6 | $11.68 |
| long | 26 Jul 2026 64,375.00 | 20 Aug 2026 69,334.80 | 25 | $21.03 |
| long | 29 Aug 2026 77,845.90 | 4 Sep 2026 81,270.40 | 6 | $12.03 |
| long | 24 Sep 2026 84,397.60 | 9 Oct 2026 81,754.50 | 15 | −$9.67 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 13 ms | With a workaround 1,000 bars in 42 ms | Not measured |
| PineTS | No 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 27) 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=1strategy(shorttitle='Multi Time Frame Buy the Dips',title='Multi Time Frame 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(12, title='Lookback Long Period')inp_lkb_2 = input(2, title='Lookback Short Period') perc_change(lkb) => overall_change = ((close[0] - close[lkb]) / close[lkb]) * 100// Call the function overall = perc_change(inp_lkb)overall_2 = perc_change(inp_lkb_2)//Entrydip= -(input(1))increase= (input(3))strategy.entry(id="long", long = true, when = overall > increase and overall_2 < dip and window()) //ExitStop_loss= ((input (3))/100)Take_profit= ((input (4))/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())