OPEN-SOURCE SCRIPT
CAPEX

//version=6
indicator("美光 CapEx 噴發追蹤器", overlay=true)
// --- 輸入設定 ---
threshold = input.float(20.0, title="CapEx 噴發閾值 (%)", minval=1.0)
lookback = input.int(4, title="對比前幾季", minval=1)
// --- 取得財務數據 (資本支出 - 季度) ---
// 使用 request.financial 抓取美光的資本支出 (Capital Expenditures)
capex = request.financial("NASDAQ:MU", "CAPITAL_EXPENDITURES", "FQ")
// --- 計算變動率 ---
// 因為財務數據在圖表上是階梯狀的,我們取當前有效值
current_capex = nz(capex)
prev_capex = nz(capex[lookback])
// 計算增長率 (注意:capex 在財報是負數,所以我們取絕對值來計算)
capex_growth = (math.abs(current_capex) - math.abs(prev_capex)) / math.abs(prev_capex) * 100
// --- 判斷噴發條件 ---
is_surge = capex_growth >= threshold
// --- 繪製視覺效果 ---
// 當 CapEx 噴發時,背景顯示紅色 (代表擴產警訊)
bgcolor(is_surge ? color.new(color.red, 85) : na, title="CapEx 噴發區間")
// 在圖表下方標註文字
plotshape(is_surge, style=shape.labelup, location=location.bottom, color=color.red, text="CapEx 激增", textcolor=color.white, size=size.small)
// --- 儀表板 (選用) ---
var table tb = table.new(position.top_right, 2, 2, bgcolor=color.new(color.black, 70), border_width=1)
if barstate.islast
table.cell(tb, 0, 0, "本季 CapEx:", text_color=color.white)
table.cell(tb, 1, 0, str.tostring(current_capex / 1e9, "#.##") + " B", text_color=color.red)
table.cell(tb, 0, 1, "較上季增長:", text_color=color.white)
table.cell(tb, 1, 1, str.tostring(capex_growth, "#.##") + "%", text_color=is_surge ? color.red : color.green)
indicator("美光 CapEx 噴發追蹤器", overlay=true)
// --- 輸入設定 ---
threshold = input.float(20.0, title="CapEx 噴發閾值 (%)", minval=1.0)
lookback = input.int(4, title="對比前幾季", minval=1)
// --- 取得財務數據 (資本支出 - 季度) ---
// 使用 request.financial 抓取美光的資本支出 (Capital Expenditures)
capex = request.financial("NASDAQ:MU", "CAPITAL_EXPENDITURES", "FQ")
// --- 計算變動率 ---
// 因為財務數據在圖表上是階梯狀的,我們取當前有效值
current_capex = nz(capex)
prev_capex = nz(capex[lookback])
// 計算增長率 (注意:capex 在財報是負數,所以我們取絕對值來計算)
capex_growth = (math.abs(current_capex) - math.abs(prev_capex)) / math.abs(prev_capex) * 100
// --- 判斷噴發條件 ---
is_surge = capex_growth >= threshold
// --- 繪製視覺效果 ---
// 當 CapEx 噴發時,背景顯示紅色 (代表擴產警訊)
bgcolor(is_surge ? color.new(color.red, 85) : na, title="CapEx 噴發區間")
// 在圖表下方標註文字
plotshape(is_surge, style=shape.labelup, location=location.bottom, color=color.red, text="CapEx 激增", textcolor=color.white, size=size.small)
// --- 儀表板 (選用) ---
var table tb = table.new(position.top_right, 2, 2, bgcolor=color.new(color.black, 70), border_width=1)
if barstate.islast
table.cell(tb, 0, 0, "本季 CapEx:", text_color=color.white)
table.cell(tb, 1, 0, str.tostring(current_capex / 1e9, "#.##") + " B", text_color=color.red)
table.cell(tb, 0, 1, "較上季增長:", text_color=color.white)
table.cell(tb, 1, 1, str.tostring(capex_growth, "#.##") + "%", text_color=is_surge ? color.red : color.green)
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.