PLEASE ADD VOLUME DELTA AND SESSION VOLUME PROFILE.
Hello
Please add the volume delta indicator(The indicator scans lower timeframe data to approximate up and down volume used in the delta calculation. By default, the timeframe is chosen automatically. These inputs override this with a custom timeframe) found in tradingview. The following is the pinescript code:
//@version=5
indicator("Volume Delta", format=format.volume)
lowerTimeframeTooltip = "The indicator scans lower timeframe data to approximate up and down volume used in the delta calculation. By default, the timeframe is chosen automatically. These inputs override this with a custom timeframe.
\n\nHigher timeframes provide more historical data, but the data will be less precise."
useCustomTimeframeInput = input.bool(false, "Use custom timeframe", tooltip = lowerTimeframeTooltip)
lowerTimeframeInput = input.timeframe("1", "Timeframe")
upAndDownVolume() =>
posVol = 0.0
negVol = 0.0
var isBuyVolume = true
switch
close > open => isBuyVolume := true
close < open => isBuyVolume := false
close > close[1] => isBuyVolume := true
close < close[1] => isBuyVolume := false
if isBuyVolume
posVol += volume
else
negVol -= volume
posVol + negVol
var lowerTimeframe = switch
useCustomTimeframeInput => lowerTimeframeInput
timeframe.isseconds => "1S"
timeframe.isintraday => "1"
timeframe.isdaily => "5"
=> "60"
diffVolArray = request.security_lower_tf(syminfo.tickerid, lowerTimeframe, upAndDownVolume())
getHighLow(arr) =>
float cumVolume = na
float maxVolume = na
float minVolume = na
for item in arr
cumVolume := nz(cumVolume) + item
maxVolume := math.max(nz(maxVolume), cumVolume)
minVolume := math.min(nz(minVolume), cumVolume)
[maxVolume, minVolume, cumVolume]
[maxVolume, minVolume, lastVolume] = getHighLow(diffVolArray)
openVolume = not na(lastVolume) ? 0.0 : na
col = lastVolume > 0 ? color.teal : color.red
hline(0)
plotcandle(openVolume, maxVolume, minVolume, lastVolume, "Volume Delta", color = col, bordercolor = col, wickcolor = col)
var cumVol = 0.
cumVol += nz(volume)
if barstate.islast and cumVol == 0
runtime.error("The data vendor doesn't provide volume data for this symbol.")
The following is the calculations for the volume session profile:



This request was merged into another request
Comments2
Vishwanath Narasimmal
Aug 15, 2024
Since we are subscribing to live data, this can be plotted precisely like in Ninja trader/Sierra chart ect. Please enable this indicator.
Brian Arenson
Aug 6, 2024
+1 for cumulative delta