TradingView
JollyWizard
2022年6月17日午後6時35分

Singular and Cumulative Volume Delta (SVD+CVD) 

Bitcoin / U. S. DollarKraken

詳細

This a Volume Delta indicator with Cumulative Volume Delta.

I have been studying Volume Delta and CVD trading strategies and indicator styles.

This implementation was developed to test a basic trailing window / oscillator approach.

Script has been republished as public and searchable.

Changelog from private era follows.

  • Jun 9 (2022)
    Release Notes:
    Added option to use EMA/SMA based cumulation. This will not scale well with singular data, so default view is still SUM.
  • Jun 9 (2022)
    Release Notes:
    Outdated comment correction.
  • Jun 9 (2022)
    Release Notes:
    Added default option to normalilze visual scale of MA cumulation types. The averaging creates a singular value sized results, instead of a range-sums. This multiples that candle result by the range length to get a range-sum sized result.
    Added option to scale the cumulation size relative to the volume size. 1-to-1 scaling creates singular deltas that can be hard to see with all options on. This allows you to beef them up for visual or weighting purposes.
  • Jun 15 (2022)
    Release Notes: * Added break even level for current delta. Tells where current delta must land for cumulative delta to stay flat.
    * Added comparison of historical cumulative levels to current level. The historical levels are the initial values going into current accumulation window.
    * Changed title of indicator to be more generic, clear, and searchable.
  • Jun 15 (2022)
    Release Notes: * Added option to have the cumulation cutoff line AFTER or OVER the end of the cumulation window. This change is to ensure the indicator clearly documents it's behavior and avoids confusion on this / last cumulation window semantics.
  • * Bugfix: Initial levels were pulled from cumulation line which was AFTER end of window. This has been changed to the initial values INSIDE the cumulation window.
  • * Code cleanup.
    June 17th (2022)
    Release Notes: Marked as beta because TV confirmed they no longer allow private scripts to be changed to public. (Despite lingering documentation that says otherwise.
  • June 17th (2022)
    Re-published as public.
コメント
djmad
very nice presentation of the volume. top
kishanhadiyal9
thanks sir.
wonderful indicator.. better than tradingview cvd..
one request please add manual reset time frame for delta.
like tradingview cvd indicator reset settings.
JollyWizard
@kishanhadiyal9, I've considered this while looking at the similarities with relative volume, but don't fully follow how it would mix with this code yet. My next steps are to bring in some algebraic filters I developed, and then I want to look at making a library that will work as a general case for other cumulation indicators. I feel that if I can figure out the library nuance, that other options, like your request, will flow more naturally.

Probably slow coming, but I will bear your request to heart.

Thanks for the feedback.
kishanhadiyal9
@JollyWizard, thanks sir.
kishanhadiyal
@kishanhadiyal9, dear sir how can we change buy-sell cumulative lines to ankit sir's cloud wave style with volume avarage..? like ankit sir used
55e190098c844c95a1eaf9efed6081
Hello . Thanks for this indicator.
I am creating an indicator based on on balance volume. On balance volume anchored daily , weekly , monthly ,yearly.
Here I want to fix the calculation time period of indicator as minutes.
. In my indicator on balance volume anchored daily , weekly monthly and yearly. (Like vwap)
I want to show one minute on balance volume in 5 minute 15 minute daily weekly and monthly chart.
But as chart time changes the obv calculation value also changed . How to fix this obv calculation value to 1 minute. What ever time period we are setting the chart , I want to see the 1 minute on balance volume.
If we set 5 minute chart . I want to see sum of current 1 minute candles sum (5 , 1 minute candles). Setting 15 minute , I want to see sum current 1 minute candles sum.(15 , 1 minute candles) same for all other time frames.
For example if we set 5 minute chart.
And previous 5 minute obv is 25.
previous obv is 25 . So as first 1 minute candle formed with volume 2 . And close >open. Then add 2 with 25 . That is 25+2 = 27. Show this as 5 minute obv.
If second 1 minute candle formed , right now current obv = 27. If second candle volume is 3 and close>open . Then volume 3 is positive so 5 minute obv is 27+3 =30.
3rd candle volume 4 and close <open , the. Volume 4 is negative and current 5minute obv is 30-4 = 26.
5th 1 minute volume 7 ,and open =close.
So current 5 minute obv = 26+0= 26
5ht candle volume 2 , close>open ,
Current 5 minute obv = 26+2 = 28.
Continue this
Same for 15 minute 1 hour and all other time frame.
I coded it as follows.

indicator(title = "On Balance Volume Multi time " , overlay = false)

var a = 0.0
var b = 0.0
var c = 0.0
var d = 0.0

a := ta.change(time("D"))
b := ta.change(time("W"))
c := ta.change(time("M"))
d := ta.change(time("Y"))
src1 = request.security(syminfo.tickerid , "1", close)
src2 = request.security(syminfo.tickerid , "1" , open)
src3 = request.security(syminfo.tickerid , "1" , volume
a := (src1>src2) ? a+src3 : (src1<src2) ? a -src3 : 0
b := (src1>src2) ? b+src3 : (src1<src2) ? b-src3 : 0
c := (src1>src2) ? c+src3 : (src1<src2) ? c-src3 : 0
d := (src1>src2) ? d+src3 : (src1<src2)? d-src3 : 0

Plot(a , title = "D Line" , color = color.blue)
Plot(b , title = "W Line" , color = color.green)
Plot(c , title = "M Line " , color = color.yellow)
Plot(d , title = "Y Line" , color = color.orange)

Can you help me to code this .
JollyWizard
@55e190098c844c95a1eaf9efed6081, `request.security()` is not the correct function for lower TFs, the correct function is `request.security_lower_tf()`

Per this link:
tradingview.com/pine-script-docs/en/v5/concepts/Other_timeframes_and_data.html

```
However if you are on a 60 minutes chart and want to use the data from the 1 minute bars, you would need to specifically use the new request.security_lower_tf() function. If you were to use the request.security() function in our example you would actually only get the final minute bar for the last hour since barmerge.lookahead_off is the default. If you were to use barmerge.lookahead_on then you would get the first minute bar instead.
```

So that explains why you are experience changed results, you are only ever getting a single 1m candle.

Your code would not compile for me. There is no 1Y timeframe in version=5, and the capitalization of plot is wrong. There is no version, and your `a:=...` code is adding time delta to volume numbers, so all of that had to be reworked.

This is the code I developed from your example. I notice that the long time frames do no play nice with TVs limited data history on the assets in my watchlist. Your results may vary.

// Request: Anchored On Balance Volume // By Jolly Wizard // Adapted from code provided by another member looking for help. //@version=5 indicator(title = "On Balance Volume Multi time " , overlay = false) var a = 0.0 var b = 0.0 var c = 0.0 var d = 0.0 [open_1m, close_1m, volume_1m] = request.security_lower_tf(syminfo.tickerid , "1", [open, close, volume]) obv_1m = array.new_float(0,0) size_1m = array.size(volume_1m) if size_1m > 0 for i = 0 to (size_1m - 1) directional_multiplier_1m = array.get(close_1m, i) > array.get(open_1m, i) ? 1 : -1 _obv_1m = directional_multiplier_1m * array.get(volume_1m, i) array.unshift(obv_1m, _obv_1m) obv = array.sum(obv_1m) a := obv + (ta.change(time("D")) ? 0 : a) b := obv + (ta.change(time("W")) ? 0 : b) c := obv + (ta.change(time("M")) ? 0 : c) d := obv + (ta.change(time("12M")) ? 0 : d) plot(a , title = "D Line" , color = color.blue, style=plot.style_stepline) plot(b , title = "W Line" , color = color.green, style=plot.style_stepline) plot(c , title = "M Line " , color = color.yellow, style=plot.style_stepline) plot(d , title = "Y Line" , color = color.orange, style=plot.style_stepline) hline(0.0, "Zero Line", linestyle=hline.style_dotted)
55e190098c844c95a1eaf9efed6081
@JollyWizard, Hello . Thanks very much for the reply. I am not familiar with pinescript. I am learning coding from other people's indicators , people like you. So this reply help me a lot.
You are the only person reply to my comment. Thanks a lot.
詳細