本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PeterSetups
//@version=6
indicator("XAUUSD PRO GOLD SNIPER", overlay=true, max_labels_count=500)
// INPUTS
emaFastLen = input.int(9, "Fast EMA")
emaSlowLen = input.int(21, "Slow EMA")
emaTrendLen = input.int(200, "Trend EMA")
rsiLen = input.int(14, "RSI Length")
atrLen = input.int(14, "ATR Length")
slMult = input.float(1.5, "Stop Loss ATR")
tpMult = input.float(2.0, "Take Profit ATR")
// INDICATORS
emaFast = ta.ema(close, emaFastLen)
emaSlow = ta.ema(close, emaSlowLen)
emaTrend = ta.ema(close, emaTrendLen)
ema50 = ta.ema(close, 50)
rsi = ta.rsi(close, rsiLen)
atr = ta.atr(atrLen)
// TREND FILTER
bullTrend = close > emaTrend and ema50 > emaTrend
bearTrend = close < emaTrend and ema50 < emaTrend
// SIGNAL CONDITIONS
buySignal = ta.crossover(emaFast, emaSlow) and bullTrend and rsi > 50
sellSignal = ta.crossunder(emaFast, emaSlow) and bearTrend and rsi < 50
// CONFIRMED SIGNALS
buy = buySignal and barstate.isconfirmed
sell = sellSignal and barstate.isconfirmed
// PLOT EMAS
plot(emaFast, "EMA 9", color=color.lime, linewidth=2)
plot(emaSlow, "EMA 21", color=color.orange, linewidth=2)
plot(ema50, "EMA 50", color=color.blue, linewidth=2)
plot(emaTrend, "EMA 200", color=color.red, linewidth=2)
// BUY / SELL LABELS
if buy
label.new(bar_index, low, "BUY 🟢\nSL: " + str.tostring(close - atr * slMult, format.mintick) + "\nTP: " + str.tostring(close + atr * tpMult, format.mintick), style=label.style_label_up, color=color.green, textcolor=color.white)
if sell
label.new(bar_index, high, "SELL 🔴\nSL: " + str.tostring(close + atr * slMult, format.mintick) + "\nTP: " + str.tostring(close - atr * tpMult, format.mintick), style=label.style_label_down, color=color.red, textcolor=color.white)
// ALERTS
alertcondition(buy, "XAUUSD BUY", "Gold BUY Signal")
alertcondition(sell, "XAUUSD SELL", "Gold SELL Signal")