Pine Script v3 · Strategy
LegacyScalping Dips On Trend (by Coinrule)
A Pine Script v3 strategy built on SMA (close, 50). 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. 12 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 Scalping Dips On Trend (by Coinrule) repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 11 of 11 trades.
- How did Scalping Dips On Trend (by Coinrule) do on BTCUSDT 1D with default settings?
- +2.56%
- From 26 Jan 2024 to 21 Oct 2026, over 35 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Scalping Dips On Trend (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 Scalping Dips On Trend (by Coinrule) use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Scalping Dips On Trend (by Coinrule) run in Zeal Terminal?
- Yes
- It compiles in 8 ms and runs 1,000 bars in 57 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +2.56%
- $25.64
- Buy and hold
- +102.5%
- same period
- Closed trades
- 35
- 27 won · 8 lost
- Profitable
- 77.1%
- of closed trades
- Profit factor
- 1.08
- gross profit ÷ gross loss
- Max drawdown
- 12.39%
- −$134.53
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 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 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.
- Upgrading to v5 renames sma → ta.sma.
- 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.
v3 → v4
DiffersTrades differ: 35 before, 35 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=3 → //@version=4
⋯// © Coinrule-//@version=3+//@version=4strategy(shorttitle='Scalping Dips On Trend',title='Scalping Dips On Trend (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 35 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: sma → ta.sma
- Line 27: long = true → direction = strategy.long
⋯// © Coinrule-//@version=4+//@version=5strategy(shorttitle='Scalping Dips On Trend',title='Scalping Dips On Trend (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)⋯MA=input(50, title='Moving Average')-MAsignal = sma(close, MA)+MAsignal = ta.sma(close, MA)//Entrydip= -(input(2))-strategy.entry(id="long", long = true, when = overall< dip and MAsignal > close and window()) +strategy.entry(id="long", direction = strategy.long, when = overall< dip and MAsignal > close and window()) //Exit⋯Clean v5
VerifiedSame 35 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()
8 more edits
- Line 12: input() → input.bool()
- Line 16: input() → input.int()
- Line 23: input() → input.int()
- Line 26: input() → input.int()
- Line 27: when = overall< dip and MAsignal > close 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(1, title='Lookback Period')+inp_lkb = input.int(1, title='Lookback Period') ⋯//MA inputs and calculations-MA=input(50, title='Moving Average')+MA=input.int(50, title='Moving Average')MAsignal = ta.sma(close, MA)//Entry-dip= -(input(2))+dip= -(input.int(2))-strategy.entry(id="long", direction = strategy.long, when = overall< dip and MAsignal > close and window()) +if overall< dip and MAsignal > close and window()+ strategy.entry(id="long", direction = strategy.long) //Exit-Stop_loss= ((input (10))/100)+Stop_loss= ((input.int (10))/100)-Take_profit= ((input (3))/100)+Take_profit= ((input.int (3))/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 35 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='Scalping Dips On Trend',title='Scalping Dips On Trend (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 Period | 1 | int | overall |
| Moving Average | 50 | int | MAsignal |
| Dip (no label in the script) | 2 | int | entry long |
| Stop loss (no label in the script) | 10 | int | longStopPrice |
| Take profit (no label in the script) | 3 | int | longTakeProfit |
What it calculates
- SMA (
sma,ta.smain v5)close, Moving Average (50)MAsignal · 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open long long | overall< dip and MAsignal > close 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 | +2.6% | +102.5% | 35 | 77% | 1.08 | 12.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.5% | +5.5% | 5 | 80% | 1.16 | 3.3% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −6.8% | +9.8% | 60 | 68% | 0.91 | 17.9% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +1.8% | +8.4% | 11 | 73% | 1.18 | 7.6% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +25.0% | +16.7% | 78 | 76% | 1.29 | 13.7% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −3.4% | +21.5% | 9 | 67% | 0.67 | 6.9% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −12.8% | +148.3% | 35 | 69% | 0.71 | 18.2% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +2.9% | +17.1% | 7 | 86% | 1.91 | 3.6% | 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 | 5 | 80% | $1.97 |
| Sideways market | 17 | 71% | −$41.48 |
| Falling market | 13 | 85% | $65.15 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
16.9%
The 95th percentile of the worst drawdown when the same 35 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 7.6% to 16.9%; the tick is what actually happened, 11.4%. Order luck alone moves it this much.
All 35 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 14 Apr 2024 63,924.50 | 23 Apr 2024 66,819.30 | 9 | $12.97 |
| long | 25 Apr 2024 64,289.60 | 18 May 2024 67,024.00 | 23 | $12.30 |
| long | 25 Jun 2024 60,293.30 | 1 Jul 2024 62,772.00 | 6 | $12.02 |
| long | 4 Jul 2024 60,208.60 | 16 Jul 2024 64,724.10 | 12 | $22.69 |
| long | 3 Aug 2024 61,498.30 | 6 Aug 2024 54,018.80 | 3 | −$39.27 |
| long | 12 Aug 2024 58,712.60 | 14 Aug 2024 60,587.20 | 2 | $9.15 |
| long | 15 Aug 2024 58,683.40 | 22 Aug 2024 61,156.00 | 7 | $12.39 |
| long | 28 Aug 2024 59,415.00 | 19 Sep 2024 61,760.00 | 22 | $11.70 |
| long | 10 Oct 2024 60,636.00 | 12 Oct 2024 62,540.00 | 2 | $9.29 |
| long | 8 Jan 2025 96,954.60 | 16 Jan 2025 100,497.00 | 8 | $11.01 |
| long | 3 Feb 2025 97,700.60 | 4 Feb 2025 101,329.00 | 1 | $11.31 |
| long | 5 Feb 2025 97,763.10 | 27 Feb 2025 84,250.10 | 22 | −$45.62 |
| long | 4 Mar 2025 86,221.20 | 6 Mar 2025 90,606.00 | 2 | $15.23 |
| long | 8 Mar 2025 86,801.70 | 9 Apr 2025 76,322.40 | 32 | −$38.81 |
| long | 11 Apr 2025 79,607.30 | 12 Apr 2025 83,423.80 | 1 | $13.99 |
| long | 20 Aug 2025 112,873.00 | 23 Aug 2025 116,936.00 | 3 | $10.50 |
| long | 26 Aug 2025 110,112.00 | 11 Sep 2025 113,960.00 | 16 | $10.28 |
| long | 23 Sep 2025 112,651.00 | 2 Oct 2025 118,595.00 | 9 | $15.99 |
| long | 11 Oct 2025 112,774.00 | 7 Nov 2025 101,346.00 | 27 | −$33.05 |
| long | 12 Nov 2025 103,059.00 | 18 Nov 2025 92,215.10 | 6 | −$33.23 |
| long | 21 Nov 2025 86,637.20 | 27 Nov 2025 90,484.00 | 6 | $12.72 |
| long | 2 Dec 2025 86,286.00 | 3 Dec 2025 91,277.90 | 1 | $16.97 |
| long | 6 Dec 2025 89,330.00 | 10 Dec 2025 92,678.80 | 4 | $10.96 |
| long | 13 Dec 2025 90,268.40 | 6 Jan 2026 93,859.70 | 24 | $11.79 |
| long | 21 Jan 2026 88,427.70 | 1 Feb 2026 78,741.10 | 11 | −$35.21 |
| long | 2 Feb 2026 76,968.20 | 6 Feb 2026 62,909.90 | 4 | −$56.34 |
| long | 12 Feb 2026 67,082.50 | 15 Feb 2026 69,822.90 | 3 | $11.20 |
| long | 18 Feb 2026 67,503.50 | 5 Mar 2026 72,666.80 | 15 | $21.72 |
| long | 6 Mar 2026 70,891.00 | 17 Mar 2026 74,884.70 | 11 | $16.20 |
| long | 22 Mar 2026 68,918.10 | 26 Mar 2026 71,336.50 | 4 | $10.02 |
| long | 27 Mar 2026 68,820.30 | 8 Apr 2026 71,924.20 | 12 | $13.19 |
| long | 23 May 2026 75,539.50 | 3 Jun 2026 66,760.80 | 11 | −$36.64 |
| long | 4 Jun 2026 64,142.80 | 16 Jun 2026 66,328.70 | 12 | $9.59 |
| long | 19 Jun 2026 62,958.00 | 15 Jul 2026 65,044.00 | 26 | $9.40 |
| long | 1 Aug 2026 62,887.90 | 8 Aug 2026 64,923.20 | 7 | $9.25 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Scalping Dips On Trend (by Coinrule) this page | — | v3 strategy | +2.6% | 35 | 12.4% |
| Follow the Crypto Shorts by xtradernet | sma | v4 strategy | No trades on this market | ||
| buy down and sell high trend 200 sma and ma cross by willi130503 | sma | v4 strategy | No trades on this market | ||
| Mayer Multiple Strategy by xtradernet | sma | v4 strategy | No trades on this market | ||
| Moving Average Cross Strategy early Closing by Geduldtrader | sma | v4 strategy | +73.8% | 20 | 151.5% |
| MFI Simple Strategy by OztheWoz | sma | v5 strategy | −0.2% | 28 | 3.2% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 8 ms | With a workaround 1,000 bars in 57 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=3strategy(shorttitle='Scalping Dips On Trend',title='Scalping Dips On Trend (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)//MA inputs and calculationsMA=input(50, title='Moving Average')MAsignal = sma(close, MA)//Entrydip= -(input(2))strategy.entry(id="long", long = true, when = overall< dip and MAsignal > close and window()) //ExitStop_loss= ((input (10))/100)Take_profit= ((input (3))/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())