OPEN-SOURCE SCRIPT
CCI TIME COUNT

//version=6
indicator("CCI Multi‑TF", overlay=true)
// === Inputs ===
// CCI Inputs
cciLength = input.int(20, "CCI Length", minval=1)
src = input.source(hlc3, "Source")
// Timeframes
timeframes = array.from("1", "3", "5", "10", "15", "30", "60", "1D", "1W")
labels = array.from("1m", "3m", "5m", "10m", "15m", "30m", "60m", "Daily", "Weekly")
// === Table Settings ===
tblPos = input.string('Top Right', 'Table Position', options = ['Top Left', 'Top Right', 'Bottom Left', 'Bottom Right', 'Middle Left', 'Middle Right'], group = 'Table Settings')
i_textSize = input.string('Small', 'Text Size', options = ['Tiny', 'Small', 'Normal', 'Large'], group = 'Table Settings')
textSize = i_textSize == 'Small' ? size.small : i_textSize == 'Normal' ? size.normal : i_textSize == 'Large' ? size.large : size.tiny
textColor = color.white
// Resolve table position
var pos = switch tblPos
'Top Left' => position.top_left
'Top Right' => position.top_right
'Bottom Left' => position.bottom_left
'Bottom Right' => position.bottom_right
'Middle Left' => position.middle_left
'Middle Right' => position.middle_right
=> position.top_right
// === Custom CCI Function ===
customCCI(source, length) =>
sma = ta.sma(source, length)
dev = ta.dev(source, length)
(source - sma) / (0.015 * dev)
// === CCI Values for All Timeframes ===
var float[] cciVals = array.new_float(array.size(timeframes))
for i = 0 to array.size(timeframes) - 1
tf = array.get(timeframes, i)
cciVal = request.security(syminfo.tickerid, tf, customCCI(src, cciLength))
array.set(cciVals, i, cciVal)
// === Countdown Timers ===
var string[] countdowns = array.new_string(array.size(timeframes))
for i = 0 to array.size(timeframes) - 1
tf = array.get(timeframes, i)
closeTime = request.security(syminfo.tickerid, tf, time_close)
sec_left = barstate.isrealtime and not na(closeTime) ? math.max(0, (closeTime - timenow) / 1000) : na
min_left = sec_left >= 0 ? math.floor(sec_left / 60) : na
sec_mod = sec_left >= 0 ? math.floor(sec_left % 60) : na
timer_text = barstate.isrealtime and not na(sec_left) ? str.format("{0,number,00}:{1,number,00}", min_left, sec_mod) : "–"
array.set(countdowns, i, timer_text)
// === Build Table ===
if barstate.islast
rows = array.size(timeframes) + 1
var table t = table.new(pos, 3, rows, frame_color=color.rgb(252, 250, 250), border_color=color.rgb(243, 243, 243))
// Headers
table.cell(t, 0, 0, "Timeframe", text_color=textColor, bgcolor=color.rgb(238, 240, 242), text_size=textSize)
table.cell(t, 1, 0, "CCI (" + str.tostring(cciLength) + ")", text_color=textColor, bgcolor=color.rgb(239, 243, 246), text_size=textSize)
table.cell(t, 2, 0, "Time to Close", text_color=textColor, bgcolor=color.rgb(239, 244, 248), text_size=textSize)
// Data Rows
for i = 0 to array.size(timeframes) - 1
row = i + 1
label = array.get(labels, i)
cciVal = array.get(cciVals, i)
countdown = array.get(countdowns, i)
// Color CCI: Green if < -100, Red if > 100
cciColor = cciVal < -100 ? color.green : cciVal > 100 ? color.red : color.rgb(236, 237, 240)
// Background warning if <60 seconds to close
tf = array.get(timeframes, i)
closeTime = request.security(syminfo.tickerid, tf, time_close)
sec_left = barstate.isrealtime and not na(closeTime) ? math.max(0, (closeTime - timenow) / 1000) : na
countdownBg = sec_left < 60 ? color.rgb(255, 220, 220, 90) : na
// Table cells
table.cell(t, 0, row, label, text_color=color.rgb(239, 240, 244), text_size=textSize)
table.cell(t, 1, row, str.tostring(cciVal, "#.##"), text_color=cciColor, text_size=textSize)
table.cell(t, 2, row, countdown, text_color=color.rgb(232, 235, 243), bgcolor=countdownBg, text_size=textSize)
indicator("CCI Multi‑TF", overlay=true)
// === Inputs ===
// CCI Inputs
cciLength = input.int(20, "CCI Length", minval=1)
src = input.source(hlc3, "Source")
// Timeframes
timeframes = array.from("1", "3", "5", "10", "15", "30", "60", "1D", "1W")
labels = array.from("1m", "3m", "5m", "10m", "15m", "30m", "60m", "Daily", "Weekly")
// === Table Settings ===
tblPos = input.string('Top Right', 'Table Position', options = ['Top Left', 'Top Right', 'Bottom Left', 'Bottom Right', 'Middle Left', 'Middle Right'], group = 'Table Settings')
i_textSize = input.string('Small', 'Text Size', options = ['Tiny', 'Small', 'Normal', 'Large'], group = 'Table Settings')
textSize = i_textSize == 'Small' ? size.small : i_textSize == 'Normal' ? size.normal : i_textSize == 'Large' ? size.large : size.tiny
textColor = color.white
// Resolve table position
var pos = switch tblPos
'Top Left' => position.top_left
'Top Right' => position.top_right
'Bottom Left' => position.bottom_left
'Bottom Right' => position.bottom_right
'Middle Left' => position.middle_left
'Middle Right' => position.middle_right
=> position.top_right
// === Custom CCI Function ===
customCCI(source, length) =>
sma = ta.sma(source, length)
dev = ta.dev(source, length)
(source - sma) / (0.015 * dev)
// === CCI Values for All Timeframes ===
var float[] cciVals = array.new_float(array.size(timeframes))
for i = 0 to array.size(timeframes) - 1
tf = array.get(timeframes, i)
cciVal = request.security(syminfo.tickerid, tf, customCCI(src, cciLength))
array.set(cciVals, i, cciVal)
// === Countdown Timers ===
var string[] countdowns = array.new_string(array.size(timeframes))
for i = 0 to array.size(timeframes) - 1
tf = array.get(timeframes, i)
closeTime = request.security(syminfo.tickerid, tf, time_close)
sec_left = barstate.isrealtime and not na(closeTime) ? math.max(0, (closeTime - timenow) / 1000) : na
min_left = sec_left >= 0 ? math.floor(sec_left / 60) : na
sec_mod = sec_left >= 0 ? math.floor(sec_left % 60) : na
timer_text = barstate.isrealtime and not na(sec_left) ? str.format("{0,number,00}:{1,number,00}", min_left, sec_mod) : "–"
array.set(countdowns, i, timer_text)
// === Build Table ===
if barstate.islast
rows = array.size(timeframes) + 1
var table t = table.new(pos, 3, rows, frame_color=color.rgb(252, 250, 250), border_color=color.rgb(243, 243, 243))
// Headers
table.cell(t, 0, 0, "Timeframe", text_color=textColor, bgcolor=color.rgb(238, 240, 242), text_size=textSize)
table.cell(t, 1, 0, "CCI (" + str.tostring(cciLength) + ")", text_color=textColor, bgcolor=color.rgb(239, 243, 246), text_size=textSize)
table.cell(t, 2, 0, "Time to Close", text_color=textColor, bgcolor=color.rgb(239, 244, 248), text_size=textSize)
// Data Rows
for i = 0 to array.size(timeframes) - 1
row = i + 1
label = array.get(labels, i)
cciVal = array.get(cciVals, i)
countdown = array.get(countdowns, i)
// Color CCI: Green if < -100, Red if > 100
cciColor = cciVal < -100 ? color.green : cciVal > 100 ? color.red : color.rgb(236, 237, 240)
// Background warning if <60 seconds to close
tf = array.get(timeframes, i)
closeTime = request.security(syminfo.tickerid, tf, time_close)
sec_left = barstate.isrealtime and not na(closeTime) ? math.max(0, (closeTime - timenow) / 1000) : na
countdownBg = sec_left < 60 ? color.rgb(255, 220, 220, 90) : na
// Table cells
table.cell(t, 0, row, label, text_color=color.rgb(239, 240, 244), text_size=textSize)
table.cell(t, 1, row, str.tostring(cciVal, "#.##"), text_color=cciColor, text_size=textSize)
table.cell(t, 2, row, countdown, text_color=color.rgb(232, 235, 243), bgcolor=countdownBg, text_size=textSize)
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.