Pine Script v5 · Strategy
Slight Swing Momentum Strategy.
A Pine Script v5 strategy built on SMA (close, 60), Highest (volume, 60) and Crossover (volume, highestVol[1]). It has 4 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. It has no settings.
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 Slight Swing Momentum Strategy. repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 2 of 2 trades.
- How did Slight Swing Momentum Strategy. do on BTCUSDT 1D with default settings?
- +3.12%
- From 26 Jan 2024 to 21 Oct 2026, over 7 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Slight Swing Momentum Strategy. 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: 7 before, 5 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does Slight Swing Momentum Strategy. use a stop loss?
- Yes
- strategy.exit sets a stop on line 44.
- Does Slight Swing Momentum Strategy. run in Zeal Terminal?
- Yes
- It compiles in 13 ms and runs 1,000 bars in 38 ms, in the browser.
BTCUSDT · 1D · default settings
- Shape
- Shape
- EMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +3.12%
- $31,175.40
- Buy and hold
- +102.5%
- same period
- Closed trades
- 7
- 6 won · 1 lost
- Profitable
- 85.7%
- of closed trades
- Profit factor
- 7.74
- gross profit ÷ gross loss
- Max drawdown
- 0.60%
- −$6,003.23
One run with the author's default settings, $1,000,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.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
The script declares no settings.
What it calculates
- SMAclose, 60
ma60 · line 8 - Highestvolume, 60
highestVol · line 14 - Crossovervolume, highestVol[1]
A3 · line 15 - EMAclose, 5
ema5 · line 17 - Crossover / SMAB1, ta.sma(B1, 9)
XG · line 21 - SMAclose, 50
weeklyMa · line 23 - EMAclose, 5
ema · line 50
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 Buy long | (buyCondition) | On | 34 |
| Close Buy | (sellCondition) | On | 37 |
| Exit Long Stop Loss stop | inPosition | On | 44 |
| Exit Long Take Profit limit | inPosition | On | 45 |
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 | +3.1% | +102.5% | 7 | 86% | 7.74 | 0.6% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.7% | +5.5% | 1 | 100% | — | 0.1% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.0% | +9.8% | 22 | 41% | 1.12 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 1 | 100% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.0% | +16.7% | 28 | 25% | 0.95 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 2 | 50% | 5.88 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.1% | +148.3% | 15 | 7% | 0.02 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 3 | 100% | $21,321.90 |
| Sideways market | 4 | 75% | $9,853.57 |
| Falling market | 0 | — | $0.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
0.5%
The 95th percentile of the worst drawdown when the same 7 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 0.5% to 0.5%; the tick is what actually happened, 0.5%. Order luck alone moves it this much.
All 7 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 16 May 2024 66,206.50 | 30 May 2024 67,652.40 | 14 | $1,445.90 |
| long | 24 Aug 2024 64,037.20 | 28 Aug 2024 59,415.00 | 4 | −$4,622.24 |
| long | 7 Nov 2024 75,572.00 | 26 Nov 2024 93,010.00 | 19 | $17,438.00 |
| long | 23 Apr 2025 93,443.00 | 5 May 2025 94,277.60 | 12 | $834.62 |
| long | 9 May 2025 103,262.00 | 29 May 2025 107,782.00 | 20 | $4,520.17 |
| long | 20 Aug 2026 69,334.80 | 9 Sep 2026 78,455.80 | 20 | $9,121.02 |
| long | 19 Sep 2026 80,883.90 | 8 Oct 2026 83,321.80 | 19 | $2,437.95 |
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 |
|---|---|---|---|---|---|
| Slight Swing Momentum Strategy. this page | — | v5 strategy | +3.1% | 7 | 0.6% |
| Davin's 10-200MA Pullback on SPY Strategy v2.0 by Gold_D_Roger | sma ema highest | v5 strategy | +6.5% | 32 | 4.8% |
| Forex bot full strategy with risk management by exlux99 | highest ema sma | v4 strategy | −26.4% | 11 | 38.9% |
| LowFinder_PyraMider_V2 by A3Sh | ema sma highest | v5 strategy | +1.9% | 15 | 0.8% |
| MACD Long Strat by TheGrindToday | ema sma | v4 strategy | +24.0% | 79 | 20.1% |
| Stock trending strategy by exlux99 | ema sma | v4 strategy | +35.3% | 21 | 14.7% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
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: 7 before, 5 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.
⋯// © fzj20020403-//@version=5+//@version=6strategy("Slight Swing Momentum Strategy.", overlay=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 13 ms | Yes 1,000 bars in 38 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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/// © fzj20020403//@version=5strategy("Slight Swing Momentum Strategy.", overlay=true)// Position Status Definitionvar inPosition = false// Moving Average Definitionma60 = ta.sma(close, 60)// A1 Condition DefinitionA1 = high / close < 1.03 and open / low < 1.03 and high / close[1] > 1.06// A2 Condition DefinitionA2 = close / open > 1.05 or close / close[1] > 1.05// A3 Condition DefinitionhighestVol = ta.highest(volume, 60)A3 = ta.crossover(volume, highestVol[1])// B1 Condition Definitionema5 = ta.ema(close, 5)B1 = close / ema5// XG Condition DefinitionA1andA2 = (A1 and A2) and (A1[1] and A2[1])XG = ta.crossover(B1, ta.sma(B1, 9))// Weekly Trend Factor DefinitionweeklyMa = ta.sma(close, 50)weeklySlope = (weeklyMa - weeklyMa[4]) / 4 > 0// Buy Signal using XG ConditionbuySignal = A1 and close > ma60 or A2 and A3 and XG and close > ma60 and weeklySlope // Sell Signal ConditionsellSignal = close < ta.ema(close, 10)// Buy and Sell ConditionsbuyCondition = buySignal and not inPositionsellCondition = sellSignal and inPosition// Execute Buy and Sell Operationsif (buyCondition) strategy.entry("Buy", strategy.long) inPosition := trueif (sellCondition) strategy.close("Buy") inPosition := false// Stop Loss and Take Profit LevelsstopLoss = strategy.position_avg_price * 0.5takeProfit = strategy.position_avg_price * 1.30// Apply Stop Loss and Take Profit Levelsif inPosition strategy.exit("Long Stop Loss", "Buy", stop=stopLoss) strategy.exit("Long Take Profit", "Buy", limit=takeProfit)// Plot Buy and Sell Signal Shapesplotshape(buyCondition, style=shape.arrowdown, location=location.belowbar, color=color.green, size=size.small)plotshape(sellCondition, style=shape.arrowup, location=location.abovebar, color=color.red, size=size.small)// EMA Variable Definitionema = ta.ema(close, 5)// Plot Indicator Lineplot(ema, color=color.green, title="EMA")