OPEN-SOURCE SCRIPT
Aggiornato

M2SL/DXY vs Crypto

165
//version=5
indicator("M2SL/DXY vs Crypto", shorttitle="M2SL/DXY", timeframe="", timeframe_gaps=true)

// 定义 SMA 的周期
sma_length = input.int(20, title="SMA Length", minval=1) // 默认改为20,如果确实需要原始值,可以改回1

// 获取数据
// 注意:M2SL 通常是周度或月度数据。在日线图等低周期图表上,它会保持不变直到新数据发布。
m2sl_raw = request.security("FRED:M2SL", timeframe.period, close)
dxy_raw = request.security("TVC:DXY", timeframe.period, close)

// 计算 SMA (如果 sma_length > 1)
m2sl_sma = ta.sma(m2sl_raw, sma_length)
dxy_sma = ta.sma(dxy_raw, sma_length)

// 计算比率
// 使用平滑后的数据进行比率计算
ratio = m2sl_sma / dxy_sma
// 或者,先计算比率,再平滑比率 (这是另一种方法,结果会不同)
// ratio_raw = m2sl_raw / dxy_raw
// ratio_smoothed = ta.sma(ratio_raw, sma_length)


// 绘制结果
// 解释 offset: 正数向右(未来)平移,负数向左(过去)平移
// offset = 77 是一个非常大的向前平移,请确认是否需要。如果不需要,设为 0 或注释掉。
plot_offset = input.int(0, title="Plot Offset", tooltip="Positive shifts plot to the right (future), negative to the left (past). 77 is a large forward shift.")

plot(ratio, title="M2SL/DXY Ratio", color=color.new(color.blue, 0), linewidth=2, offset=plot_offset)

// 如果你想看到 M2SL 和 DXY 的原始值或SMA值进行调试或比较,可以取消注释下面的行
// plot(m2sl_sma, "M2SL SMA", color.orange)
// plot(dxy_sma, "DXY SMA", color.green)
Note di rilascio
dxy

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.