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="賣出信號")

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.