OPEN-SOURCE SCRIPT

雙均線交叉交易策略 (適用免費版)

59
//version=5
indicator("雙均線交叉交易策略 (適用免費版)", overlay=true)

// === 設定均線參數 ===
shortLength = input(20, title="短期均線 (EMA20)")
longLength = input(50, title="長期均線 (EMA50)")

// === 計算均線 ===
shortEMA = ta.ema(close, shortLength)
longEMA = ta.ema(close, longLength)

// === 交叉訊號 ===
longCondition = ta.crossover(shortEMA, longEMA) // 黃金交叉 (買入)
shortCondition = ta.crossunder(shortEMA, longEMA) // 死亡交叉 (賣出)

// === 畫出買賣訊號箭頭 ===
plot(shortEMA, title="短期 EMA (20)", color=color.blue, linewidth=2)
plot(longEMA, title="長期 EMA (50)", color=color.red, linewidth=2)

plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="買入信號")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="賣出信號")

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.