Qwes2.5

Qwes2.5

//@version=5
indicator("Gold XAU/USD Buy/Sell Indicator", overlay=true)

// Input Parameters
short_ma_length = input.int(9, title="Short MA Length")
long_ma_length = input.int(21, title="Long MA Length")
rsi_length = input.int(14, title="RSI Length")
overbought_level = input.int(70, title="Overbought Level")
oversold_level = input.int(30, title="Oversold Level")

// Calculate Moving Averages
short_ma = ta.sma(close, short_ma_length)
long_ma = ta.sma(close, long_ma_length)

// Calculate RSI
rsi = ta.rsi(close, rsi_length)

// Generate Buy/Sell Signals
buy_signal = ta.crossover(short_ma, long_ma) and rsi < oversold_level
sell_signal = ta.crossunder(short_ma, long_ma) and rsi > overbought_level

// Plot Moving Averages
plot(short_ma, color=color.blue, title="Short MA")
plot(long_ma, color=color.red, title="Long MA")

// Plot Buy/Sell Signals
plotshape(series=buy_signal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sell_signal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// Alerts
alertcondition(buy_signal, title="Buy Alert", message="Buy Signal Generated!")
alertcondition(sell_signal, title="Sell Alert", message="Sell Signal Generated!")

Read More

Share:

Latest News