Pine Script v5 · Strategy
Volume Difference Delta Cycle Oscillator
A Pine Script v5 strategy built on Change (src), CUM and PVT. It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. 19 settings; defaults include Start Date 1, Start Month 1 and Start Year 2010.
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 Volume Difference Delta Cycle Oscillator repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Volume Difference Delta Cycle Oscillator do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
- Does Volume Difference Delta Cycle Oscillator run in Pine Script v6?
- Not tested
- Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download.
- Does Volume Difference Delta Cycle Oscillator use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Volume Difference Delta Cycle Oscillator run in Zeal Terminal?
- Yes
- It compiles in 25 ms and runs 1,000 bars in 57 ms, in the browser.
BTCUSDT · 1D · default settings
- HLine
- HLine
- Histogram
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
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.
-
Likely bug
ta.ema(normalize(result, -1, 1), 20) ignores the settings line 40
Line 40 hard-codes 20 where line 44 uses “Volume Bands Length”. Changing those settings moves one band but not this one.
ta.ema(normalize(result, -1, 1), 20)ta.ema(normalize(result, -1, 1), length) -
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
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
2 settings have no label
In the settings dialog oversold (line 61), overbought (line 62) 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 75, 77, 79, 81. 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 |
|---|---|---|---|
| Start Date | 1 | int · min 1 · max 31 | inDateRange |
| Start Month | 1 | int · min 1 · max 12 | inDateRange |
| Start Year | 2010 | int · min 1800 · max 2100 | inDateRange |
| End Date | 31 | int · min 1 · max 31 | inDateRange |
| End Month | 12 | int · min 1 · max 12 | inDateRange |
| End Year | 2021 | int · min 1800 · max 2100 | inDateRange |
| Long Stop Loss % | 2.0 | float | l_stop_level |
| Long Take Profit % | 4.0 | float | l_take_level |
| Short Stop Loss % | 2.0 | float | s_stop_level |
| Short Take Profit % | 4.0 | float | s_take_level |
| Volume Bands Length | 20 | int · min 1 | basis dev |
| Volume Bands StdDev | 2.0 | float · min 0.001 · max 50 | dev |
| Bollinger Bands Length | 20 | int · min 1 | basis1 dev1 |
| Bollinger Bands StdDev | 2.0 | float · min 0.001 · max 50 | dev1 |
| Hist Smoothing Factor #1 | 2 | int | short long histColor Histogram |
| Hist Smoothing Factor #2 | 2 | int | short long histColor Histogram |
| Hist Smoothing Factor #3 | 2 | int | short long histColor Histogram |
| Oversold (no label in the script) | -.1 | float | long hline |
| Overbought (no label in the script) | .4 | float | short hline |
What it calculates
- Changesrc
change_src · line 36 - CUMchange_src > 0 ? volume : change_src < 0 ? -volume : 0 * volume
i_obv · line 37 - PVT
i_pvt · line 38 - Changei_obv - i_pvt
result · line 39 - EMAnormalize(result, -1, 1), 20
nresult · line 40 - EMAnresult, Volume Bands Length (20)
basis · line 44 - Stdevnresult, Volume Bands Length (20)
dev · line 45 - SMAsrc2, Bollinger Bands Length (20)
basis1 · line 53 - Stdevsrc2, Bollinger Bands Length (20)
dev1 · line 54
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 | longhist < oversold | On | 75 |
| Close | shorthist > overbought | On | 77 |
| Open short short | shorthist > overbought | On | 79 |
| Close | longhist < oversold | On | 81 |
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.
- 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 | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 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.
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 |
|---|---|---|---|---|---|
| Volume Difference Delta Cycle Oscillator this page | — | v5 strategy | 0.0% | 0 | 0.0% |
| BB+RSI+OBV by atakhadivi | cum sma stdev | v4 strategy | +52.5% | 71 | 29.3% |
| Volume Weighted Bollinger Bands Strategy by Ankit_1618 | ema sma stdev | v4 strategy | +10.0% | 15 | 27.5% |
| BB21_MA200_Strategy by mohanee | ema sma stdev | v4 strategy | No trades on this market | ||
| Super Breakout day trading by beststockalert | stdev sma ema | v4 strategy | No trades on this market | ||
| Super Auto Breakout Day Trade Volatile stocks by beststockalert | stdev sma ema | v4 strategy | −6.1% | 51 | 29.1% |
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 75, 77, 79, 81). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 9 settings use the untyped input() (line 26, 27, 30, 31, 59, 59, 59, 61, 62). 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.
Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 26: input() → input.float()
- Line 27: input() → input.float()
- Line 30: input() → input.float()
- Line 31: input() → input.float()
- Line 59: input() → input.int()
- Line 59: input() → input.int()
7 more edits
- Line 59: input() → input.int()
- Line 61: input() → input.float()
- Line 62: input() → input.float()
- Line 75: when = long → if block
- Line 77: when = short → if block
- Line 79: when = short → if block
- Line 81: when = long → if block
⋯// Stop loss & Take Profit Section -l_sl_inp = input(2.0, title='Long Stop Loss %') / 100+l_sl_inp = input.float(2.0, title='Long Stop Loss %') / 100-l_tp_inp = input(4.0, title='Long Take Profit %') / 100+l_tp_inp = input.float(4.0, title='Long Take Profit %') / 100l_stop_level = strategy.position_avg_price * (1 - l_sl_inp)l_take_level = strategy.position_avg_price * (1 + l_tp_inp)-s_sl_inp = input(2.0, title='Short Stop Loss %') / 100+s_sl_inp = input.float(2.0, title='Short Stop Loss %') / 100-s_tp_inp = input(4.0, title='Short Take Profit %') / 100+s_tp_inp = input.float(4.0, title='Short Take Profit %') / 100s_stop_level = strategy.position_avg_price * (1 + s_sl_inp)⋯/// Final Output Line-hist = ta.ema(ta.ema(ta.ema(bbr1 - bbr, input(2, title='Hist Smoothing Factor #1')), input(2, title='Hist Smoothing Factor #2')), input(2, title='Hist Smoothing Factor #3'))+hist = ta.ema(ta.ema(ta.ema(bbr1 - bbr, input.int(2, title='Hist Smoothing Factor #1')), input.int(2, title='Hist Smoothing Factor #2')), input.int(2, title='Hist Smoothing Factor #3'))/// Overbought / Oversold Line Creation-oversold = input(-.1)+oversold = input.float(-.1)-overbought = input(.4)+overbought = input.float(.4)hline(oversold, linewidth=2, color=color.new(#81c784, 62))⋯if inDateRange- strategy.entry('long', strategy.long, when=long, stop=l_stop_level, limit=l_take_level)+ if long+ strategy.entry('long', strategy.long, stop=l_stop_level, limit=l_take_level)if inDateRange and strategy.position_size > 0- strategy.close_all(when=short)+ if short+ strategy.close_all()if inDateRange- strategy.entry('short', strategy.short, when=short, stop=s_stop_level, limit=s_take_level)+ if short+ strategy.entry('short', strategy.short, stop=s_stop_level, limit=s_take_level)if inDateRange and strategy.position_size < 0- strategy.close_all(when=long)+ if long+ strategy.close_all()Does it run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © tathal and special thanks to oakwhiz for his porting of my custom volume indicator-//@version=5+//@version=6strategy('Volume Difference Delta Cycle Oscillator', 'VDDC Osc', default_qty_type=strategy.percent_of_equity, default_qty_value=100, max_bars_back=5000)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 25 ms | Yes 1,000 bars in 57 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/// © tathal and special thanks to oakwhiz for his porting of my custom volume indicator//@version=5strategy('Volume Difference Delta Cycle Oscillator', 'VDDC Osc', default_qty_type=strategy.percent_of_equity, default_qty_value=100, max_bars_back=5000)startDate = input.int(title='Start Date', defval=1, minval=1, maxval=31)startMonth = input.int(title='Start Month', defval=1, minval=1, maxval=12)startYear = input.int(title='Start Year', defval=2010, minval=1800, maxval=2100)endDate = input.int(title='End Date', defval=31, minval=1, maxval=31)endMonth = input.int(title='End Month', defval=12, minval=1, maxval=12)endYear = input.int(title='End Year', defval=2021, minval=1800, maxval=2100)// Normalize Functionnormalize(_src, _min, _max) => // Normalizes series with unknown min/max using historical min/max. // _src : series to rescale. // _min, _min: min/max values of rescaled series. var _historicMin = 10e10 var _historicMax = -10e10 _historicMin := math.min(nz(_src, _historicMin), _historicMin) _historicMax := math.max(nz(_src, _historicMax), _historicMax) _min + (_max - _min) * (_src - _historicMin) / math.max(_historicMax - _historicMin, 10e-10)// STEP 2:// Look if the close time of the current bar// falls inside the date rangeinDateRange = time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0) and time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0)// Stop loss & Take Profit Section l_sl_inp = input(2.0, title='Long Stop Loss %') / 100l_tp_inp = input(4.0, title='Long Take Profit %') / 100l_stop_level = strategy.position_avg_price * (1 - l_sl_inp)l_take_level = strategy.position_avg_price * (1 + l_tp_inp)s_sl_inp = input(2.0, title='Short Stop Loss %') / 100s_tp_inp = input(4.0, title='Short Take Profit %') / 100s_stop_level = strategy.position_avg_price * (1 + s_sl_inp)s_take_level = strategy.position_avg_price * (1 - s_tp_inp)src = close// Volume Differnce Indicator Deltafloat change_src = ta.change(src)float i_obv = ta.cum(change_src > 0 ? volume : change_src < 0 ? -volume : 0 * volume)float i_pvt = ta.pvtfloat result = ta.change(i_obv - i_pvt)float nresult = ta.ema(normalize(result, -1, 1), 20)// Volume Differnce Indicator Delta %Blength = input.int(20, minval=1, title='Volume Bands Length')mult = input.float(2.0, minval=0.001, maxval=50, title='Volume Bands StdDev')basis = ta.ema(nresult, length)dev = mult * ta.stdev(nresult, length)upper = basis + devlower = basis - devbbr = (nresult - lower) / (upper - lower)// Normal %B, Based on closel1 = input.int(20, minval=1, title='Bollinger Bands Length')src2 = closemult1 = input.float(2.0, minval=0.001, maxval=50, title='Bollinger Bands StdDev')basis1 = ta.sma(src2, l1)dev1 = mult1 * ta.stdev(src2, l1)upper1 = basis1 + dev1lower1 = basis1 - dev1bbr1 = (src - lower1) / (upper1 - lower1)/// Final Output Linehist = ta.ema(ta.ema(ta.ema(bbr1 - bbr, input(2, title='Hist Smoothing Factor #1')), input(2, title='Hist Smoothing Factor #2')), input(2, title='Hist Smoothing Factor #3'))/// Overbought / Oversold Line Creationoversold = input(-.1)overbought = input(.4)hline(oversold, linewidth=2, color=color.new(#81c784, 62))hline(overbought, linewidth=2, color=color.new(#c2185b, 38))/// Long & Short Conditionsshort = hist > overboughtlong = hist < oversold/// Colors & PlottinghistColor = hist >= 0 ? hist[1] < hist ? #26A69A : #B2DFDB : hist[1] < hist ? #FFCDD2 : #EF5350plot(hist, title='Histogram', style=plot.style_columns, color=color.new(histColor, 0))CrossBgColor = long ? color.new(#81c784, 62) : short ? color.new(#c2185b, 38) : nabgcolor(color.new(CrossBgColor, 90))/// Strategy Methodologyif inDateRange strategy.entry('long', strategy.long, when=long, stop=l_stop_level, limit=l_take_level)if inDateRange and strategy.position_size > 0 strategy.close_all(when=short)if inDateRange strategy.entry('short', strategy.short, when=short, stop=s_stop_level, limit=s_take_level)if inDateRange and strategy.position_size < 0 strategy.close_all(when=long)