지표식 부탁 드립니다.
//@version=5
indicator("Cumulative Volume Delta", "CVD", format=format.volume)
anchorInput = input.timeframe("1D", "Anchor period")
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")
autoSwitchInput = input.bool(true, "Auto Switch Feature", tooltip="Turn on to automatically control visibility based on 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)
var cumulLastVolume = 0.0
anchorChange = timeframe.change(anchorInput) or (not na(lastVolume) and na(lastVolume[1]))
cumulOpenVolume = anchorChange ? 0.0 : cumulLastVolume[1]
cumulMaxVolume = cumulOpenVolume + maxVolume
cumulMinVolume = cumulOpenVolume + minVolume
cumulLastVolume := cumulOpenVolume + lastVolume
var float cumVolLine = na
cumVolLine := cumulLastVolume
// Determine if the current timeframe is intraday or daily and above
is_intraday = timeframe.isintraday
// Determine what to plot based on auto switch setting
plotCVD = autoSwitchInput ? is_intraday : true
// Plotting with color change based on value
plot(plotCVD ? cumVolLine : na, title="Cumulative Volume Delta", color=cumVolLine >= 0 ? color.green : color.red, linewidth=2)
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted)
답변 1
예스스탁
예스스탁 답변
2025-07-21 13:39:45
안녕하세요
예스스탁입니다.
문의하신 내용은 답변이 어렵습니다.
타주기를 그리는 내용이 있고 해당식 작성자가 배포하는 함수등이 있어
내용 파악하고 변환하는데 시간이 많이 소모됩니다.
업무상 일정시간 이상 요구되는 내용이 답변이 가능하지 않습니다.
도움을 드리지 못해 죄송합니다.
즐거운 하루되세요
> 사노소이 님이 쓴 글입니다.
> 제목 : 수식 부탁드립니다
> 지표식 부탁 드립니다.
//@version=5
indicator("Cumulative Volume Delta", "CVD", format=format.volume)
anchorInput = input.timeframe("1D", "Anchor period")
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")
autoSwitchInput = input.bool(true, "Auto Switch Feature", tooltip="Turn on to automatically control visibility based on 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)
var cumulLastVolume = 0.0
anchorChange = timeframe.change(anchorInput) or (not na(lastVolume) and na(lastVolume[1]))
cumulOpenVolume = anchorChange ? 0.0 : cumulLastVolume[1]
cumulMaxVolume = cumulOpenVolume + maxVolume
cumulMinVolume = cumulOpenVolume + minVolume
cumulLastVolume := cumulOpenVolume + lastVolume
var float cumVolLine = na
cumVolLine := cumulLastVolume
// Determine if the current timeframe is intraday or daily and above
is_intraday = timeframe.isintraday
// Determine what to plot based on auto switch setting
plotCVD = autoSwitchInput ? is_intraday : true
// Plotting with color change based on value
plot(plotCVD ? cumVolLine : na, title="Cumulative Volume Delta", color=cumVolLine >= 0 ? color.green : color.red, linewidth=2)
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted)