Pine Script v5 · Strategy
JS-TechTrading- VWAP Momentum_Pullback Strategy
A Pine Script v5 strategy built on RSI (close, 14), SMA (close, 7) and Crossover (ma, ta.vwap). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays no commission. 17 settings; defaults include Stop-Loss (SL) % 3, Take-Profit (TP) % 7 and Stop-Loss (SL) % 50.
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 JS-TechTrading- VWAP Momentum_Pullback Strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
- How did JS-TechTrading- VWAP Momentum_Pullback Strategy do on BTCUSDT 1D with default settings?
- +23.90%
- From 26 Jan 2024 to 21 Oct 2026, over 22 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does JS-TechTrading- VWAP Momentum_Pullback 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: 22 before, 19 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 JS-TechTrading- VWAP Momentum_Pullback Strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 56, 61.
- Does JS-TechTrading- VWAP Momentum_Pullback Strategy run in Zeal Terminal?
- Yes
- It compiles in 27 ms and runs 1,000 bars in 65 ms, in the browser.
BTCUSDT · 1D · default settings
- Long SL Level
- Long TP Level
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +23.90%
- $23,902.30
- Buy and hold
- +102.5%
- same period
- Closed trades
- 22
- 9 won · 13 lost
- Profitable
- 40.9%
- of closed trades
- Profit factor
- 1.54
- gross profit ÷ gross loss
- Max drawdown
- 13.64%
- −$17,181.60
One run with the author's default settings, $100,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.
-
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 55, 57, 60, 62. The upgraded version below moves each call inside an if block.
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 |
|---|---|---|---|
| SL/TP for Long-Strategy | |||
| Activate Long-Strategy | true | bool | entry Long exit Long SL/TP close Long Long SL Level Long TP Level Short SL Level Short TP Level line 54 |
| Stop-Loss (SL) % | 3 | float · min 0 | long_stoploss_percentage long_stoploss_price |
| Take-Profit (TP) % | 7 | float · min 0 | long_takeprofit_percentage long_takeprofit_price |
| SL/TP for Short-Strategy | |||
| Activate Short-Strategie | false | bool | entry Short exit Short SL/TP close Short Long SL Level Long TP Level Short SL Level Short TP Level line 59 |
| Stop-Loss (SL) % | 50 | float · min 0 | short_stoploss_percentage short_stoploss_price |
| Take-Profit (TP) % | 50 | float · min 0 | short_takeprofit_percentage short_takeprofit_price |
| Time-Period for Back-Testing | |||
| Start Day | 1 | int · min 1 · max 31 | in_date_range |
| until Day | 1 | int · min 1 · max 31 | in_date_range |
| Start Month | 10 | int · min 1 · max 12 | in_date_range |
| until Month | 1 | int · min 1 · max 12 | in_date_range |
| Start Year | 2022 | int · min 1800 · max 3000 | in_date_range |
| until Year | 2077 | int · min 1800 · max 3000 | in_date_range |
| RSI | |||
| Oversold Level | 40 | int · min 1 | was_over_sold |
| Overbought Level | 70 | int · min 1 | was_over_bought |
| RSI Length | 14 | int · min 1 | rsi |
| VWAP | |||
| SMA source | close | source | ma |
| SMA interval | 7 | int · min 0 · max 999 · step 1 | ma |
What it calculates
- RSIclose, RSI Length (14)
rsi · line 40 - SMASMA source (close), SMA interval (7)
ma · line 44 - Crossoverma, ta.vwap
crossover_bull · line 49 - Crossunderma, ta.vwap
crossover_bear · 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 Long long | buy_signalwas_over_sold and crossover_bull | On | 55 |
| Exit Long SL/TP stop and limit | buy_signal and in_date_range and enable_long_strategy == true | On | 56 |
| Close Long | sell_signalwas_over_bought and crossover_bear | On | 57 |
| Open Short short | sell_signalwas_over_bought and crossover_bear | On | 60 |
| Exit Short SL/TP stop and limit | sell_signal and in_date_range and enable_short_strategy == true | On | 61 |
| Close Short | buy_signalwas_over_sold and crossover_bull | On | 62 |
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.9% | +102.5% | 22 | 41% | 1.54 | 13.6% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −6.7% | +5.5% | 12 | 25% | 0.74 | 13.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +41.4% | +9.8% | 37 | 41% | 1.52 | 17.1% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −14.8% | +8.4% | 15 | 20% | 0.55 | 20.6% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +3.6% | +16.7% | 31 | 32% | 1.05 | 32.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −29.5% | +21.5% | 18 | 11% | 0.27 | 30.6% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +36.4% | +148.3% | 22 | 45% | 1.92 | 14.7% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +17.8% | +17.1% | 14 | 43% | 1.63 | 13.7% | 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 | 67% | $11,163.20 |
| Sideways market | 8 | 50% | $16,721.20 |
| Falling market | 11 | 27% | −$3,981.99 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
21.1%
The 95th percentile of the worst drawdown when the same 22 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 8.7% to 21.1%; the tick is what actually happened, 11.5%. Order luck alone moves it this much.
All 22 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 26 Apr 2024 64,498.30 | 27 Apr 2024 62,563.40 | 1 | −$3,000.02 |
| long | 9 May 2024 61,193.00 | 15 May 2024 65,476.60 | 6 | $6,790.01 |
| long | 4 Jul 2024 60,208.60 | 4 Jul 2024 58,402.30 | 0 | −$3,113.70 |
| long | 15 Aug 2024 58,683.40 | 15 Aug 2024 56,922.90 | 0 | −$3,020.30 |
| long | 17 Sep 2024 58,214.00 | 19 Sep 2024 62,289.00 | 2 | $6,835.92 |
| long | 5 Mar 2025 87,282.00 | 9 Mar 2025 84,677.90 | 4 | −$3,117.52 |
| long | 19 Mar 2025 82,715.00 | 24 Mar 2025 88,601.30 | 5 | $7,214.07 |
| long | 7 Apr 2025 78,430.00 | 7 Apr 2025 76,077.10 | 0 | −$3,257.65 |
| long | 2 Jul 2025 105,681.00 | 10 Jul 2025 113,079.00 | 8 | $7,373.16 |
| long | 23 Oct 2025 107,567.00 | 26 Oct 2025 115,097.00 | 3 | $7,889.29 |
| long | 30 Oct 2025 110,021.00 | 30 Oct 2025 106,721.00 | 0 | −$3,617.80 |
| long | 13 Nov 2025 101,654.00 | 13 Nov 2025 98,604.70 | 0 | −$3,509.27 |
| long | 2 Dec 2025 86,286.00 | 3 Dec 2025 92,326.00 | 1 | $7,942.64 |
| long | 6 Dec 2025 89,330.00 | 15 Dec 2025 86,650.10 | 9 | −$3,642.28 |
| long | 25 Dec 2025 87,669.40 | 5 Jan 2026 93,806.30 | 11 | $8,243.67 |
| long | 30 Jan 2026 84,650.20 | 30 Jan 2026 82,110.60 | 0 | −$3,780.31 |
| long | 18 Feb 2026 67,503.50 | 23 Feb 2026 65,478.40 | 5 | −$3,666.90 |
| long | 24 Feb 2026 64,656.00 | 24 Feb 2026 62,716.30 | 0 | −$3,556.91 |
| long | 28 Feb 2026 65,872.10 | 28 Feb 2026 63,895.90 | 0 | −$3,450.19 |
| long | 8 Mar 2026 67,262.90 | 13 Mar 2026 71,971.30 | 5 | $7,808.92 |
| long | 19 Jun 2026 62,958.00 | 24 Jun 2026 61,076.00 | 5 | −$3,568.24 |
| long | 9 Jul 2026 62,290.00 | 21 Jul 2026 66,650.30 | 12 | $8,105.76 |
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 |
|---|---|---|---|---|---|
| JS-TechTrading- VWAP Momentum_Pullback Strategy this page | — | v5 strategy | +23.9% | 22 | 13.6% |
| SRJ RSI Outperformer Strategy by Sapt_Jash | rsi sma | v5 strategy | +0.6% | 8 | 2.4% |
| RSI SMA Crossover Strategy by reees | rsi sma | v5 strategy | +39.8% | 42 | 30.8% |
| Short In Downtrend Below MA100 (Coinrule) by Coinrule | sma rsi | v4 strategy | −34.5% | 99 | 45.4% |
| Simple RSI and SMA Long and Short (by Coinrule) by Coinrule | rsi sma | v5 strategy | −3.0% | 2 | 17.7% |
| Maximized Moving Average Crossing (by Coinrule) by Coinrule | sma rsi | v4 strategy | −6.6% | 9 | 13.3% |
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.
- 4 strategy calls use the when = argument (line 55, 57, 60, 62). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 1 setting uses the untyped input() (line 42). It still compiles in v6; input.int, input.float or input.source state the type.
- No v6-only features. v6 is not needed to run this script.
Same 22 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 42: input() → input.source()
- Line 55: when = buy_signal → if block
- Line 57: when = sell_signal → if block
- Line 60: when = sell_signal → if block
- Line 62: when = buy_signal → if block
⋯// VWAP-maSource = input(title='SMA source', defval=close,group = "VWAP")+maSource = input.source(title='SMA source', defval=close,group = "VWAP")maInterval = input.int(title='SMA interval', minval=0, maxval=999, step=1, defval=7,group = "VWAP")⋯if buy_signal and in_date_range and enable_long_strategy == true- strategy.entry('Long', strategy.long, when=buy_signal, alert_message='Open Long Position')+ if buy_signal+ strategy.entry('Long', strategy.long, alert_message='Open Long Position') strategy.exit('Long SL/TP', from_entry='Long', loss=long_stoploss_percentage, profit=long_takeprofit_percentage, alert_message='Your SL/TP-Limit for the Long-Strategy has been activated.')- strategy.close('Long', when=sell_signal, alert_message='Close Long Position')+ if sell_signal+ strategy.close('Long', alert_message='Close Long Position')// Short Strategyif sell_signal and in_date_range and enable_short_strategy == true- strategy.entry('Short', strategy.short, when=sell_signal, alert_message='Open Short Position')+ if sell_signal+ strategy.entry('Short', strategy.short, alert_message='Open Short Position') strategy.exit('Short SL/TP', from_entry='Short', loss=short_stoploss_percentage, profit=short_takeprofit_percentage, alert_message='Your SL/TP-Limit for the Short-Strategy has been activated.')- strategy.close('Short', when=buy_signal, alert_message='Close Short Position')+ if buy_signal+ strategy.close('Short', alert_message='Close Short Position')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: 22 before, 19 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.
-//@version=5+//@version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 27 ms | With a workaround 1,000 bars in 65 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“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.
//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © JS-TechTrading 2023strategy(title='JS-TechTrading: VWAP Momentum_Pullback Strategy', initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, currency='USD', overlay=true)//// Stoploss and Take Profit Parameters// Enable Long Strategyenable_long_strategy = input.bool(true, title='Activate Long-Strategy', group='SL/TP for Long-Strategy', inline='1')long_stoploss_value = input.float(defval=3, title='Stop-Loss (SL) %', minval=0, group='SL/TP for Long-Strategy', inline='2')long_stoploss_percentage = close * (long_stoploss_value / 100) / syminfo.minticklong_takeprofit_value = input.float(defval=7, title='Take-Profit (TP) %', minval=0, group='SL/TP for Long-Strategy', inline='2')long_takeprofit_percentage = close * (long_takeprofit_value / 100) / syminfo.mintick// Enable Short Strategyenable_short_strategy = input.bool(false, title='Activate Short-Strategie', group='SL/TP for Short-Strategy', inline='3')short_stoploss_value = input.float(defval=50, title='Stop-Loss (SL) %', minval=0, group='SL/TP for Short-Strategy', inline='4')short_stoploss_percentage = close * (short_stoploss_value / 100) / syminfo.mintickshort_takeprofit_value = input.float(defval=50, title='Take-Profit (TP) %', minval=0, group='SL/TP for Short-Strategy', inline='4')short_takeprofit_percentage = close * (short_takeprofit_value / 100) / syminfo.mintick// Plot Stoploss & Take Profit Levelslong_stoploss_price = strategy.position_avg_price * (1 - long_stoploss_value / 100)long_takeprofit_price = strategy.position_avg_price * (1 + long_takeprofit_value / 100)short_stoploss_price = strategy.position_avg_price * (1 + short_stoploss_value / 100)short_takeprofit_price = strategy.position_avg_price * (1 - short_takeprofit_value / 100)plot(enable_long_strategy and not enable_short_strategy ? long_stoploss_price : na, color=color.new(#ff0000, 0), style=plot.style_linebr, linewidth=2, title='Long SL Level')plot(enable_long_strategy and not enable_short_strategy ? long_takeprofit_price : na, color=color.new(#008000, 0), style=plot.style_linebr, linewidth=2, title='Long TP Level')plot(enable_short_strategy and not enable_long_strategy ? short_stoploss_price : na, color=color.new(#ff0000, 0), style=plot.style_linebr, linewidth=2, title='Short SL Level')plot(enable_short_strategy and not enable_long_strategy ? short_takeprofit_price : na, color=color.new(#008000, 0), style=plot.style_linebr, linewidth=2, title='Short TP Level')// Date Rangestart_date = input.int(title='Start Day', defval=1, minval=1, maxval=31, group='Time-Period for Back-Testing', inline='1')end_date = input.int(title='until Day', defval=1, minval=1, maxval=31, group='Time-Period for Back-Testing', inline='1')start_month = input.int(title='Start Month', defval=10, minval=1, maxval=12, group='Time-Period for Back-Testing', inline='2')end_month = input.int(title='until Month', defval=1, minval=1, maxval=12, group='Time-Period for Back-Testing', inline='2')start_year = input.int(title='Start Year', defval=2022, minval=1800, maxval=3000, group='Time-Period for Back-Testing', inline='3')end_year = input.int(title='until Year', defval=2077, minval=1800, maxval=3000, group='Time-Period for Back-Testing', inline='3')in_date_range = time >= timestamp(syminfo.timezone, start_year, start_month, start_date, 0, 0) and time < timestamp(syminfo.timezone, end_year, end_month, end_date, 0, 0)//// Indicator Inputs// RSIrsi_over_sold = input.int(defval=40, minval=1, title='Oversold Level', group='RSI')rsi_over_bought = input.int(defval=70, minval=1, title='Overbought Level', group='RSI')rsi_length = input.int(defval=14, minval=1, title='RSI Length', group='RSI')rsi = ta.rsi(close, rsi_length)// VWAPmaSource = input(title='SMA source', defval=close,group = "VWAP")maInterval = input.int(title='SMA interval', minval=0, maxval=999, step=1, defval=7,group = "VWAP")ma = ta.sma(maSource, maInterval)//// Strategy// Creating Long and Short Strategywas_over_sold = ta.barssince(rsi <= rsi_over_sold) <= 10was_over_bought = ta.barssince(rsi >= rsi_over_bought) <= 10crossover_bull = ta.crossover(ma, ta.vwap)crossover_bear = ta.crossunder(ma, ta.vwap)buy_signal = was_over_sold and crossover_bullsell_signal = was_over_bought and crossover_bear// Long Strategyif buy_signal and in_date_range and enable_long_strategy == true strategy.entry('Long', strategy.long, when=buy_signal, alert_message='Open Long Position') strategy.exit('Long SL/TP', from_entry='Long', loss=long_stoploss_percentage, profit=long_takeprofit_percentage, alert_message='Your SL/TP-Limit for the Long-Strategy has been activated.') strategy.close('Long', when=sell_signal, alert_message='Close Long Position')// Short Strategyif sell_signal and in_date_range and enable_short_strategy == true strategy.entry('Short', strategy.short, when=sell_signal, alert_message='Open Short Position') strategy.exit('Short SL/TP', from_entry='Short', loss=short_stoploss_percentage, profit=short_takeprofit_percentage, alert_message='Your SL/TP-Limit for the Short-Strategy has been activated.') strategy.close('Short', when=buy_signal, alert_message='Close Short Position')