PROTECTED SOURCE SCRIPT
Dollar Real Value Composite (CPI + REER + Gold)

//version=5
indicator("Dollar Real Value Composite (CPI + REER + Gold)", overlay=false, max_lines_count=500)
//=== 1. 데이터 로딩 ===//
reer = request.security("FRED:RBUSBIS", timeframe.period, close) // 실질 실효환율[web:130]
gold = request.security("OANDA:XAUUSD", timeframe.period, close) // 금 가격[web:129]
cpi = request.security("FRED:CPIAUCSL", "M", close) // CPI는 월간이므로 월봉으로 호출[web:109]
// 월간 CPI를 현 타임프레임으로 FWD-fill
cpi_tf = request.security("FRED:CPIAUCSL", timeframe.period, close)
//=== 2. 기준 시점 설정 (첫 유효 데이터) ===//
var float reer0 = na
var float gold0 = na
var float cpi0 = na
if na(reer0) and not na(reer)
reer0 := reer
if na(gold0) and not na(gold)
gold0 := gold
if na(cpi0) and not na(cpi_tf)
cpi0 := cpi_tf
//=== 3. 각 축의 로그 변화 (달러 약세 방향) ===//
// CPI ↑ => 달러 실질 구매력 ↓
cpi_idx = cpi0 > 0 and cpi_tf > 0 ? math.log(cpi_tf / cpi0) : na
// REER ↑ => 달러 강세이므로 부호 반대로
reer_idx = reer0 > 0 and reer > 0 ? -math.log(reer / reer0) : na
// Gold ↑ => 금 1온스를 사려면 더 많은 달러 => 달러 실질 ↓
gold_idx = gold0 > 0 and gold > 0 ? math.log(gold / gold0) : na
//=== 4. 표준화 (rolling 5년, 대략 60개월 = 260거래일 근사) ===//
length = input.int(260, "Std lookback bars (~5y)")
f_z(src) =>
ma = ta.sma(src, length)
sd = ta.stdev(src, length)
sd != 0 ? (src - ma) / sd : 0.0
z_cpi = f_z(cpi_idx)
z_reer = f_z(reer_idx)
z_gold = f_z(gold_idx)
//=== 5. 가중치 설정 ===//
w_cpi = input.float(0.4, "Weight CPI")
w_reer = input.float(0.3, "Weight REER")
w_gold = input.float(0.3, "Weight Gold")
composite = w_cpi * z_cpi + w_reer * z_reer + w_gold * z_gold
//=== 6. 플로팅 ===//
plot(composite, color=color.new(color.white, 0), title="Dollar Real Value Composite")
h0 = hline(0, "Zero line", color=color.new(color.gray, 60))
indicator("Dollar Real Value Composite (CPI + REER + Gold)", overlay=false, max_lines_count=500)
//=== 1. 데이터 로딩 ===//
reer = request.security("FRED:RBUSBIS", timeframe.period, close) // 실질 실효환율[web:130]
gold = request.security("OANDA:XAUUSD", timeframe.period, close) // 금 가격[web:129]
cpi = request.security("FRED:CPIAUCSL", "M", close) // CPI는 월간이므로 월봉으로 호출[web:109]
// 월간 CPI를 현 타임프레임으로 FWD-fill
cpi_tf = request.security("FRED:CPIAUCSL", timeframe.period, close)
//=== 2. 기준 시점 설정 (첫 유효 데이터) ===//
var float reer0 = na
var float gold0 = na
var float cpi0 = na
if na(reer0) and not na(reer)
reer0 := reer
if na(gold0) and not na(gold)
gold0 := gold
if na(cpi0) and not na(cpi_tf)
cpi0 := cpi_tf
//=== 3. 각 축의 로그 변화 (달러 약세 방향) ===//
// CPI ↑ => 달러 실질 구매력 ↓
cpi_idx = cpi0 > 0 and cpi_tf > 0 ? math.log(cpi_tf / cpi0) : na
// REER ↑ => 달러 강세이므로 부호 반대로
reer_idx = reer0 > 0 and reer > 0 ? -math.log(reer / reer0) : na
// Gold ↑ => 금 1온스를 사려면 더 많은 달러 => 달러 실질 ↓
gold_idx = gold0 > 0 and gold > 0 ? math.log(gold / gold0) : na
//=== 4. 표준화 (rolling 5년, 대략 60개월 = 260거래일 근사) ===//
length = input.int(260, "Std lookback bars (~5y)")
f_z(src) =>
ma = ta.sma(src, length)
sd = ta.stdev(src, length)
sd != 0 ? (src - ma) / sd : 0.0
z_cpi = f_z(cpi_idx)
z_reer = f_z(reer_idx)
z_gold = f_z(gold_idx)
//=== 5. 가중치 설정 ===//
w_cpi = input.float(0.4, "Weight CPI")
w_reer = input.float(0.3, "Weight REER")
w_gold = input.float(0.3, "Weight Gold")
composite = w_cpi * z_cpi + w_reer * z_reer + w_gold * z_gold
//=== 6. 플로팅 ===//
plot(composite, color=color.new(color.white, 0), title="Dollar Real Value Composite")
h0 = hline(0, "Zero line", color=color.new(color.gray, 60))
Script protégé
Ce script est publié en source fermée. Cependant, vous pouvez l'utiliser librement et sans aucune restriction – pour en savoir plus, cliquez ici.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script protégé
Ce script est publié en source fermée. Cependant, vous pouvez l'utiliser librement et sans aucune restriction – pour en savoir plus, cliquez ici.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.