Pine Script v4 · Strategy
Momentum Strategy Idea
A Pine Script v4 strategy built on MOM (close, 5). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade commits 100% of equity and pays 0.075% commission. 5 settings; defaults include Fast Period 5, Slow Period 10 and Stop-loss (%) 5.0.
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 Momentum Strategy Idea repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 49 of 49 trades.
- How did Momentum Strategy Idea do on BTCUSDT 1D with default settings?
- −23.56%
- From 26 Jan 2024 to 21 Oct 2026, over 170 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Momentum Strategy Idea 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 Momentum Strategy Idea use a stop loss?
- Yes
- strategy.exit sets a stop on line 37, 38.
- Does Momentum Strategy Idea run in Zeal Terminal?
- Yes
- It compiles in 10 ms and runs 1,000 bars in 44 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −23.56%
- −$235.59
- Buy and hold
- +102.5%
- same period
- Closed trades
- 170
- 56 won · 114 lost
- Profitable
- 32.9%
- of closed trades
- Profit factor
- 0.91
- gross profit ÷ gross loss
- Max drawdown
- 52.12%
- −$704.88
One run with the author's default settings, $1,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 27, 28, 30, 31. The upgraded version below moves each call inside an if block.
-
Note
Uses transp =, which v5 removed line 47
transp = on line 47. 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 mom → ta.mom.
- 4 strategy calls use the when = argument (line 27, 28, 30, 31). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 170 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 20: mom → ta.mom
- Line 21: mom → ta.mom
- Line 47: transp = 50 → color.new(colors, 50)
⋯// © QuantCT-//@version=4+//@version=5strategy("Momentum Strategy Idea",⋯// ____ Logic-mom_fast = mom(close, fast_period)+mom_fast = ta.mom(close, fast_period)-mom_slow = mom(close, slow_period)+mom_slow = ta.mom(close, slow_period) ⋯mom_slow_plot = plot(mom_slow, color=colors)-fill(mom_fast_plot, mom_slow_plot, color=colors, transp=50)+fill(mom_fast_plot, mom_slow_plot, color=color.new(colors, 50))Same 170 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 14: input() → input.int()
- Line 15: input() → input.int()
- Line 16: input() → input.bool()
- Line 17: input() → input.float()
- Line 18: input() → input.bool()
- Line 27: when = enter_long → if block
3 more edits
- Line 28: when = exit_long → if block
- Line 30: when = enter_short → if block
- Line 31: when = exit_short → if block
⋯// ____ Inputs-fast_period = input(title="Fast Period", defval=5) +fast_period = input.int(title="Fast Period", defval=5) -slow_period = input(title="Slow Period", defval=10)+slow_period = input.int(title="Slow Period", defval=10)-long_only = input(title="Long Only", defval=false)+long_only = input.bool(title="Long Only", defval=false)-slp = input(title="Stop-loss (%)", minval=1.0, maxval=25.0, defval=5.0)+slp = input.float(title="Stop-loss (%)", minval=1.0, maxval=25.0, defval=5.0)-use_sl = input(title="Use Stop-Loss", defval=false)+use_sl = input.bool(title="Use Stop-Loss", defval=false)// ____ Logic⋯exit_short = (mom_slow > 0 or mom_fast > 0)-strategy.entry("Long", strategy.long, when=enter_long)+if enter_long+ strategy.entry("Long", strategy.long)-strategy.close("Long", when=exit_long) +if exit_long+ strategy.close("Long") if (not long_only)- strategy.entry("Short", strategy.short, when=enter_short)+ if enter_short+ strategy.entry("Short", strategy.short)- strategy.close("Short", when=exit_short) + if exit_short+ strategy.close("Short") ⋯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: 170 before, 440 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.
⋯// © QuantCT-//@version=5+//@version=6strategy("Momentum Strategy Idea",⋯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 |
|---|---|---|---|
| Fast Period | 5 | int | mom_fast |
| Slow Period | 10 | int | mom_slow |
| Long Only | false | bool | entry Short close Short line 29 |
| Stop-loss (%) | 5.0 | float · min 1.0 · max 25.0 | sl_long sl_short |
| Use Stop-Loss | false | bool | exit SL exit SL line 36 |
What it calculates
- MOM (
mom,ta.momin v5)close, Fast Period (5)mom_fast · line 20 - MOM (
mom,ta.momin v5)close, Slow Period (10)mom_slow · line 21
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 | enter_long(mom_slow > 0 and mom_fast > 0) | On | 27 |
| Close Long | exit_long(mom_slow < 0 or mom_fast < 0) | On | 28 |
| Open Short short | enter_short(mom_slow < 0 and mom_fast < 0) | On | 30 |
| Close Short | exit_short(mom_slow > 0 or mom_fast > 0) | On | 31 |
| Exit SL stop | (use_sl) | On | 37 |
| Exit SL stop | (use_sl) | On | 38 |
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 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −23.6% | +102.5% | 170 | 33% | 0.91 | 52.1% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −11.1% | +5.5% | 172 | 30% | 0.87 | 21.7% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −20.4% | +9.8% | 179 | 31% | 0.96 | 58.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −3.1% | +8.4% | 187 | 26% | 0.97 | 25.5% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −22.6% | +16.7% | 161 | 42% | 0.94 | 66.9% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +3.7% | +21.5% | 165 | 29% | 1.03 | 26.7% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +3.7% | +148.3% | 163 | 34% | 1.01 | 47.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +5.0% | +17.1% | 157 | 30% | 1.05 | 18.9% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
Settings heatmap
Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (Fast Period 4, Slow Period 14) made +39.6% before 26 Dec 2025 and −9.3% after it, worse than the defaults' −7.4% after. Tuning on the past did not carry forward. 23% of the 48 combinations made money in-sample and 40% out-of-sample.
| Slow Period ↓ · Fast Period → | 3 | 4 | 5 | 6 | 7 | 9 |
|---|---|---|---|---|---|---|
| 5 | +3% | +7% | −21% | −23% | −37% | −8% |
| 6 | −5% | −2% | −23% | −29% | −40% | −11% |
| 7 | −23% | −18% | −37% | −40% | −52% | −28% |
| 9 | +14% | +20% | −8% | −11% | −28% | −1% |
| 10 | +4% | +9% | −16% | −19% | −34% | −6% |
| 12 | −17% | −13% | −34% | −37% | −49% | −27% |
| 14 | +29% | +40% | +4% | +2% | −16% | +17% |
| 17 | −14% | −7% | −31% | −32% | −45% | −21% |
| Slow Period ↓ · Fast Period → | 3 | 4 | 5 | 6 | 7 | 9 |
|---|---|---|---|---|---|---|
| 5 | −16% | −25% | −1% | +7% | −0% | +5% |
| 6 | −9% | −17% | +7% | +12% | +5% | +13% |
| 7 | −14% | −21% | −0% | +5% | −2% | +2% |
| 9 | −14% | −26% | +5% | +13% | +2% | +9% |
| 10 | −26% | −35% | −7% | −1% | −8% | −5% |
| 12 | −15% | −23% | −1% | +4% | −3% | +2% |
| 14 | +5% | −9% | +24% | +33% | +17% | +35% |
| 17 | −26% | −35% | −11% | −7% | −11% | −8% |
Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. 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 | 59 | 29% | −$413.39 |
| Sideways market | 69 | 42% | $385.84 |
| Falling market | 42 | 24% | −$207.47 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
66.4%
The 95th percentile of the worst drawdown when the same 170 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 39.1% to 66.4%; the tick is what actually happened, 51.0%. Order luck alone moves it this much.
The first 150 of 170 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 6 Feb 2024 42,708.70 | 20 Feb 2024 51,774.70 | 14 | $210.46 |
| long | 21 Feb 2024 52,258.80 | 22 Feb 2024 51,849.40 | 1 | −$11.28 |
| short | 25 Feb 2024 51,568.20 | 27 Feb 2024 54,476.50 | 2 | −$69.43 |
| long | 27 Feb 2024 54,476.50 | 17 Mar 2024 65,300.60 | 19 | $222.63 |
| short | 17 Mar 2024 65,300.60 | 18 Mar 2024 68,393.50 | 1 | −$66.13 |
| short | 19 Mar 2024 67,610.00 | 22 Mar 2024 65,501.30 | 3 | $38.19 |
| short | 23 Mar 2024 63,796.60 | 25 Mar 2024 67,210.00 | 2 | −$72.85 |
| long | 26 Mar 2024 69,880.00 | 31 Mar 2024 69,582.20 | 5 | −$7.20 |
| long | 1 Apr 2024 71,280.00 | 3 Apr 2024 65,464.00 | 2 | −$103.25 |
| short | 4 Apr 2024 65,963.30 | 8 Apr 2024 69,360.40 | 4 | −$60.48 |
| long | 9 Apr 2024 71,620.00 | 10 Apr 2024 69,146.00 | 1 | −$38.89 |
| long | 12 Apr 2024 70,006.20 | 13 Apr 2024 67,116.50 | 1 | −$44.50 |
| short | 14 Apr 2024 63,924.50 | 21 Apr 2024 64,940.60 | 7 | −$17.35 |
| long | 24 Apr 2024 66,414.00 | 25 Apr 2024 64,289.60 | 1 | −$32.77 |
| short | 27 Apr 2024 63,770.00 | 28 Apr 2024 63,462.00 | 1 | $3.16 |
| short | 29 Apr 2024 63,118.60 | 30 Apr 2024 63,866.00 | 1 | −$12.68 |
| short | 1 May 2024 60,672.00 | 5 May 2024 63,892.00 | 4 | −$51.17 |
| short | 9 May 2024 61,193.00 | 11 May 2024 60,800.00 | 2 | $4.37 |
| long | 14 May 2024 62,940.10 | 15 May 2024 61,577.50 | 1 | −$20.59 |
| short | 15 May 2024 61,577.50 | 16 May 2024 66,206.50 | 1 | −$66.77 |
| long | 16 May 2024 66,206.50 | 26 May 2024 69,290.60 | 10 | $36.20 |
| long | 28 May 2024 69,436.40 | 30 May 2024 67,652.40 | 2 | −$22.80 |
| short | 31 May 2024 68,352.20 | 4 Jun 2024 68,809.90 | 4 | −$6.69 |
| long | 4 Jun 2024 68,809.90 | 10 Jun 2024 69,648.10 | 6 | $8.65 |
| short | 12 Jun 2024 67,314.20 | 13 Jun 2024 68,264.00 | 1 | −$12.78 |
| short | 14 Jun 2024 66,773.00 | 30 Jun 2024 60,986.70 | 16 | $68.64 |
| short | 4 Jul 2024 60,208.60 | 10 Jul 2024 58,050.00 | 6 | $30.05 |
| short | 12 Jul 2024 57,339.90 | 13 Jul 2024 57,889.10 | 1 | −$10.02 |
| long | 15 Jul 2024 60,797.90 | 25 Jul 2024 65,376.00 | 10 | $65.93 |
| long | 28 Jul 2024 67,896.50 | 31 Jul 2024 66,188.00 | 3 | −$25.58 |
| short | 1 Aug 2024 64,628.00 | 9 Aug 2024 61,686.00 | 8 | $41.16 |
| short | 14 Aug 2024 60,587.20 | 15 Aug 2024 58,683.40 | 1 | $29.21 |
| long | 17 Aug 2024 58,874.60 | 19 Aug 2024 58,427.30 | 2 | −$9.13 |
| short | 19 Aug 2024 58,427.30 | 20 Aug 2024 59,438.50 | 1 | −$18.75 |
| long | 22 Aug 2024 61,156.00 | 28 Aug 2024 59,415.00 | 6 | −$29.25 |
| short | 28 Aug 2024 59,415.00 | 29 Aug 2024 59,034.90 | 1 | $4.65 |
| short | 30 Aug 2024 59,359.00 | 31 Aug 2024 59,124.00 | 1 | $2.34 |
| short | 1 Sep 2024 58,974.00 | 3 Sep 2024 59,132.10 | 2 | −$3.99 |
| short | 4 Sep 2024 57,487.70 | 11 Sep 2024 57,636.00 | 7 | −$3.88 |
| long | 12 Sep 2024 57,338.00 | 13 Sep 2024 58,132.30 | 1 | $11.69 |
| long | 14 Sep 2024 60,498.00 | 26 Sep 2024 63,152.00 | 12 | $40.57 |
| long | 27 Sep 2024 65,174.00 | 2 Oct 2024 60,804.90 | 5 | −$68.41 |
| short | 2 Oct 2024 60,804.90 | 7 Oct 2024 62,819.90 | 5 | −$32.28 |
| short | 10 Oct 2024 60,636.00 | 12 Oct 2024 62,540.00 | 2 | −$29.58 |
| long | 13 Oct 2024 63,206.20 | 22 Oct 2024 67,377.50 | 9 | $55.99 |
| long | 23 Oct 2024 67,426.00 | 24 Oct 2024 66,668.60 | 1 | −$11.77 |
| short | 26 Oct 2024 66,698.30 | 28 Oct 2024 68,021.70 | 2 | −$19.50 |
| long | 28 Oct 2024 68,021.70 | 3 Nov 2024 69,374.70 | 6 | $16.43 |
| long | 7 Nov 2024 75,572.00 | 26 Nov 2024 93,010.00 | 19 | $208.43 |
| long | 1 Dec 2024 96,408.00 | 2 Dec 2024 97,185.20 | 1 | $7.33 |
| short | 3 Dec 2024 95,840.60 | 4 Dec 2024 95,849.70 | 1 | −$1.79 |
| long | 5 Dec 2024 98,587.30 | 10 Dec 2024 97,276.50 | 5 | −$16.62 |
| short | 10 Dec 2024 97,276.50 | 11 Dec 2024 96,593.00 | 1 | $6.13 |
| long | 12 Dec 2024 101,125.00 | 19 Dec 2024 100,204.00 | 7 | −$11.80 |
| short | 19 Dec 2024 100,204.00 | 20 Dec 2024 97,461.90 | 1 | $28.53 |
| short | 22 Dec 2024 97,292.00 | 25 Dec 2024 98,663.60 | 3 | −$17.64 |
| short | 27 Dec 2024 95,791.60 | 29 Dec 2024 95,300.00 | 2 | $4.04 |
| short | 30 Dec 2024 93,738.20 | 2 Jan 2025 94,591.80 | 3 | −$11.85 |
| long | 3 Jan 2025 96,984.80 | 4 Jan 2025 98,174.20 | 1 | $11.88 |
| long | 6 Jan 2025 98,363.60 | 8 Jan 2025 96,954.60 | 2 | −$17.65 |
| short | 10 Jan 2025 92,552.50 | 11 Jan 2025 94,726.10 | 1 | −$27.47 |
| short | 13 Jan 2025 94,545.10 | 15 Jan 2025 96,560.90 | 2 | −$24.46 |
| long | 16 Jan 2025 100,497.00 | 17 Jan 2025 99,987.30 | 1 | −$6.88 |
| long | 18 Jan 2025 104,077.00 | 23 Jan 2025 103,707.00 | 5 | −$5.26 |
| long | 25 Jan 2025 104,871.00 | 27 Jan 2025 102,620.00 | 2 | −$23.74 |
| short | 28 Jan 2025 102,083.00 | 30 Jan 2025 103,733.00 | 2 | −$17.87 |
| short | 1 Feb 2025 102,430.00 | 11 Feb 2025 97,430.80 | 10 | $47.01 |
| short | 12 Feb 2025 95,778.20 | 13 Feb 2025 97,870.00 | 1 | −$24.29 |
| long | 13 Feb 2025 97,870.00 | 14 Feb 2025 96,608.10 | 1 | −$14.62 |
| long | 16 Feb 2025 97,569.70 | 17 Feb 2025 96,118.10 | 1 | −$16.39 |
| short | 18 Feb 2025 95,780.00 | 20 Feb 2025 96,644.40 | 2 | −$10.37 |
| long | 21 Feb 2025 98,305.00 | 23 Feb 2025 96,551.00 | 2 | −$18.84 |
| short | 25 Feb 2025 91,552.90 | 3 Mar 2025 94,270.00 | 6 | −$29.82 |
| short | 8 Mar 2025 86,801.70 | 9 Mar 2025 86,222.50 | 1 | $4.79 |
| long | 9 Mar 2025 86,222.50 | 10 Mar 2025 80,734.50 | 1 | −$60.63 |
| short | 10 Mar 2025 80,734.50 | 15 Mar 2025 83,983.20 | 5 | −$36.37 |
| short | 17 Mar 2025 82,574.50 | 18 Mar 2025 84,010.00 | 1 | −$15.76 |
| long | 20 Mar 2025 86,845.90 | 21 Mar 2025 84,223.40 | 1 | −$25.91 |
| long | 22 Mar 2025 84,088.80 | 23 Mar 2025 83,840.60 | 1 | −$3.52 |
| long | 24 Mar 2025 86,082.50 | 29 Mar 2025 84,424.40 | 5 | −$16.36 |
| short | 30 Mar 2025 82,648.50 | 2 Apr 2025 85,158.40 | 3 | −$24.63 |
| short | 3 Apr 2025 82,516.30 | 4 Apr 2025 83,213.10 | 1 | −$7.44 |
| short | 7 Apr 2025 78,430.00 | 10 Apr 2025 82,615.20 | 3 | −$40.64 |
| short | 11 Apr 2025 79,607.30 | 12 Apr 2025 83,423.80 | 1 | −$34.61 |
| long | 13 Apr 2025 85,276.90 | 18 Apr 2025 84,947.90 | 5 | −$3.56 |
| long | 19 Apr 2025 84,474.70 | 1 May 2025 94,172.00 | 12 | $74.88 |
| long | 2 May 2025 96,489.90 | 16 May 2025 103,764.00 | 14 | $54.36 |
| long | 18 May 2025 103,127.00 | 27 May 2025 109,435.00 | 9 | $47.14 |
| long | 29 May 2025 107,782.00 | 30 May 2025 105,590.00 | 1 | −$18.28 |
| short | 31 May 2025 103,985.00 | 5 Jun 2025 104,697.00 | 5 | −$6.84 |
| short | 6 Jun 2025 101,509.00 | 9 Jun 2025 105,734.00 | 3 | −$35.07 |
| long | 9 Jun 2025 105,734.00 | 13 Jun 2025 105,672.00 | 4 | −$1.63 |
| long | 14 Jun 2025 106,067.00 | 15 Jun 2025 105,415.00 | 1 | −$5.93 |
| short | 18 Jun 2025 104,551.00 | 24 Jun 2025 105,334.00 | 6 | −$6.92 |
| long | 25 Jun 2025 106,083.00 | 1 Jul 2025 107,147.00 | 6 | $6.50 |
| long | 3 Jul 2025 108,850.00 | 5 Jul 2025 107,984.00 | 2 | −$7.27 |
| long | 6 Jul 2025 108,198.00 | 8 Jul 2025 108,263.00 | 2 | −$0.69 |
| long | 10 Jul 2025 111,234.00 | 19 Jul 2025 117,925.00 | 9 | $44.63 |
| short | 22 Jul 2025 117,380.00 | 23 Jul 2025 119,954.00 | 1 | −$18.90 |
| long | 23 Jul 2025 119,954.00 | 24 Jul 2025 118,756.00 | 1 | −$9.05 |
| long | 31 Jul 2025 117,840.00 | 1 Aug 2025 115,764.00 | 1 | −$14.87 |
| short | 1 Aug 2025 115,764.00 | 7 Aug 2025 114,992.00 | 6 | $3.95 |
| long | 11 Aug 2025 119,294.00 | 16 Aug 2025 117,342.00 | 5 | −$13.70 |
| short | 18 Aug 2025 117,405.00 | 25 Aug 2025 113,494.00 | 7 | $24.00 |
| short | 26 Aug 2025 110,112.00 | 4 Sep 2025 111,706.00 | 9 | −$12.43 |
| long | 5 Sep 2025 110,731.00 | 6 Sep 2025 110,660.00 | 1 | −$1.64 |
| short | 8 Sep 2025 111,137.00 | 9 Sep 2025 112,065.00 | 1 | −$7.53 |
| long | 9 Sep 2025 112,065.00 | 22 Sep 2025 115,232.00 | 13 | $20.23 |
| short | 22 Sep 2025 115,232.00 | 29 Sep 2025 112,164.00 | 7 | $19.54 |
| long | 2 Oct 2025 118,595.00 | 10 Oct 2025 121,662.00 | 8 | $19.37 |
| short | 11 Oct 2025 112,774.00 | 22 Oct 2025 108,298.00 | 11 | $31.16 |
| long | 26 Oct 2025 111,646.00 | 30 Oct 2025 110,021.00 | 4 | −$13.58 |
| short | 31 Oct 2025 108,323.00 | 1 Nov 2025 109,608.00 | 1 | −$11.14 |
| short | 4 Nov 2025 106,583.00 | 10 Nov 2025 104,723.00 | 6 | $13.12 |
| short | 13 Nov 2025 101,654.00 | 26 Nov 2025 87,370.00 | 13 | $116.13 |
| long | 1 Dec 2025 90,360.00 | 2 Dec 2025 86,286.00 | 1 | −$44.26 |
| long | 4 Dec 2025 93,429.90 | 6 Dec 2025 89,330.00 | 2 | −$41.11 |
| short | 8 Dec 2025 90,395.30 | 10 Dec 2025 92,678.80 | 2 | −$23.18 |
| long | 10 Dec 2025 92,678.80 | 13 Dec 2025 90,268.40 | 3 | −$23.17 |
| short | 13 Dec 2025 90,268.40 | 21 Dec 2025 88,360.90 | 8 | $16.11 |
| short | 25 Dec 2025 87,669.40 | 26 Dec 2025 87,225.30 | 1 | $2.98 |
| short | 27 Dec 2025 87,369.60 | 28 Dec 2025 87,877.00 | 1 | −$6.13 |
| long | 29 Dec 2025 87,952.70 | 30 Dec 2025 87,237.10 | 1 | −$8.01 |
| short | 30 Dec 2025 87,237.10 | 31 Dec 2025 88,485.50 | 1 | −$13.05 |
| long | 31 Dec 2025 88,485.50 | 1 Jan 2026 87,648.20 | 1 | −$8.89 |
| long | 2 Jan 2026 88,839.10 | 10 Jan 2026 90,641.30 | 8 | $15.06 |
| long | 14 Jan 2026 95,414.00 | 19 Jan 2026 93,673.10 | 5 | −$16.12 |
| short | 21 Jan 2026 88,427.70 | 11 Feb 2026 68,841.30 | 21 | $176.37 |
| short | 12 Feb 2026 67,082.50 | 16 Feb 2026 68,832.60 | 4 | −$26.98 |
| short | 19 Feb 2026 66,461.00 | 22 Feb 2026 67,975.90 | 3 | −$23.11 |
| long | 23 Feb 2026 67,643.40 | 24 Feb 2026 64,656.00 | 1 | −$42.31 |
| short | 24 Feb 2026 64,656.00 | 1 Mar 2026 66,973.30 | 5 | −$33.09 |
| long | 1 Mar 2026 66,973.30 | 2 Mar 2026 65,776.50 | 1 | −$16.50 |
| long | 3 Mar 2026 68,830.10 | 8 Mar 2026 67,262.90 | 5 | −$20.26 |
| short | 8 Mar 2026 67,262.90 | 10 Mar 2026 68,432.20 | 2 | −$15.42 |
| long | 12 Mar 2026 70,191.90 | 15 Mar 2026 71,211.90 | 3 | $10.41 |
| long | 16 Mar 2026 72,815.30 | 20 Mar 2026 69,930.00 | 4 | −$33.29 |
| short | 22 Mar 2026 68,918.10 | 25 Mar 2026 70,556.70 | 3 | −$19.65 |
| short | 27 Mar 2026 68,820.30 | 2 Apr 2026 68,113.90 | 6 | $6.64 |
| long | 2 Apr 2026 68,113.90 | 3 Apr 2026 66,902.00 | 1 | −$14.74 |
| long | 6 Apr 2026 69,034.20 | 13 Apr 2026 70,741.60 | 7 | $17.39 |
| long | 14 Apr 2026 74,418.00 | 20 Apr 2026 73,801.80 | 6 | −$7.49 |
| long | 21 Apr 2026 75,841.00 | 28 Apr 2026 77,371.30 | 7 | $14.17 |
| long | 3 May 2026 78,686.80 | 14 May 2026 79,313.60 | 11 | $4.99 |
| long | 15 May 2026 81,090.00 | 16 May 2026 79,113.20 | 1 | −$20.13 |
| short | 16 May 2026 79,113.20 | 25 May 2026 77,065.00 | 9 | $18.52 |
| short | 26 May 2026 77,322.00 | 11 Jun 2026 61,511.00 | 16 | $157.76 |
| long | 14 Jun 2026 64,458.00 | 19 Jun 2026 62,958.00 | 5 | −$23.13 |
| short | 19 Jun 2026 62,958.00 | 20 Jun 2026 63,543.90 | 1 | −$9.86 |
| short | 22 Jun 2026 63,312.00 | 23 Jun 2026 64,020.00 | 1 | −$11.44 |
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 |
|---|---|---|---|---|---|
| Momentum Strategy Idea this page | — | v4 strategy | −23.6% | 170 | 52.1% |
| Momentum by Zeal Terminal | mom | v5 indicator | indicator | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 10 ms | Yes 1,000 bars in 44 ms | Not measured |
| PineTS | No 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/// © QuantCT//@version=4strategy("Momentum Strategy Idea", shorttitle="Momentum", overlay=false, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=1000, commission_type=strategy.commission.percent, commission_value=0.075)// ____ Inputsfast_period = input(title="Fast Period", defval=5) slow_period = input(title="Slow Period", defval=10)long_only = input(title="Long Only", defval=false)slp = input(title="Stop-loss (%)", minval=1.0, maxval=25.0, defval=5.0)use_sl = input(title="Use Stop-Loss", defval=false)// ____ Logicmom_fast = mom(close, fast_period)mom_slow = mom(close, slow_period) enter_long = (mom_slow > 0 and mom_fast > 0)exit_long = (mom_slow < 0 or mom_fast < 0)enter_short = (mom_slow < 0 and mom_fast < 0)exit_short = (mom_slow > 0 or mom_fast > 0)strategy.entry("Long", strategy.long, when=enter_long)strategy.close("Long", when=exit_long) if (not long_only) strategy.entry("Short", strategy.short, when=enter_short) strategy.close("Short", when=exit_short) // ____ SLsl_long = strategy.position_avg_price * (1- (slp/100))sl_short = strategy.position_avg_price * (1 + (slp/100))if (use_sl) strategy.exit(id="SL", from_entry="Long", stop=sl_long) strategy.exit(id="SL", from_entry="Short", stop=sl_short) // ____ Plotscolors = enter_long ? #27D600 : enter_short ? #E30202 : color.orangemom_fast_plot = plot(mom_fast, color=colors)mom_slow_plot = plot(mom_slow, color=colors)fill(mom_fast_plot, mom_slow_plot, color=colors, transp=50)