OPEN-SOURCE SCRIPT

Enhanced Ultimate Gold Trading Indicator

please make changes in scrip make it version 6
Sure! Let's update the script to Pine Script version 5 and make the necessary refinements for trading XAU/USD. I'll keep the buy and sell signals as specified.

Enhanced Ultimate Gold Trading Indicator (Pine Script v5)
pinescript
//version=5
indicator("Enhanced Ultimate Gold Trading Indicator", shorttitle="EUGTI", overlay=true)

// Define MACD settings
macdShort = 12
macdLong = 26
macdSignal = 9

// Calculate MACD
[macdLine, signalLine, _] = ta.macd(close, macdShort, macdLong, macdSignal)

// Calculate EMAs
ema50 = ta.ema(close, 50)
ema100 = ta.ema(close, 100)

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

// Calculate Bollinger Bands
bbBasis = ta.sma(close, 20)
bbUpper = bbBasis + 2 * ta.stdev(close, 20)
bbLower = bbBasis - 2 * ta.stdev(close, 20)

// Calculate VWAP
vwap = ta.vwap(close)

// Volume Profile calculations
vp = volume * close

// Additional Indicator: ATR (Average True Range) for volatility
atr = ta.atr(14)

// Buy signal: MACD line crosses above signal line, 50-day EMA crosses above 100-day EMA, RSI is below 30, price is at or near the lower Bollinger Band, price is above VWAP, and ATR is increasing
buySignal = ta.crossover(macdLine, signalLine) and ta.crossover(ema50, ema100) and rsi < 30 and close <= bbLower and close > vwap and atr > ta.atr(14)[1]

// Sell signal: MACD line crosses below signal line, 50-day EMA crosses below 100-day EMA, RSI is above 70, price is at or near the upper Bollinger Band, price is below VWAP, and ATR is increasing
sellSignal = ta.crossunder(macdLine, signalLine) and ta.crossunder(ema50, ema100) and rsi > 70 and close >= bbUpper and close < vwap and atr > ta.atr(14)[1]

// Plot MACD lines
plot(macdLine, color=color.blue, title="MACD Line")
plot(signalLine, color=color.orange, title="Signal Line")

// Plot EMAs
plot(ema50, color=color.green, title="50-Day EMA")
plot(ema100, color=color.red, title="100-Day EMA")

// Plot Bollinger Bands
plot(bbBasis, color=color.purple, title="BB Basis")
plot(bbUpper, color=color.purple, title="BB Upper")
plot(bbLower, color=color.purple, title="BB Lower")

// Plot VWAP
plot(vwap, color=color.yellow, title="VWAP")

// Plot Buy and Sell signals
plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")
Explanation:
MACD Calculation: The MACD line is the difference between the 12-period EMA and the 26-period EMA, with a 9-period EMA signal line.

Exponential Moving Averages (EMA): The 50-day and 100-day EMAs identify long-term trends.

RSI: Identifies overbought and oversold conditions for better entry and exit timing.

Bollinger Bands: Indicate price extremes and volatility.

VWAP: Shows the average price weighted by volume, providing additional confirmation.

Average True Range (ATR): Measures market volatility. Increasing ATR indicates higher volatility, which can confirm strong price movements.

Buy Signal: Triggered when the MACD line crosses above the signal line, the 50-day EMA crosses above the 100-day EMA, the RSI is below 30 (oversold), the price is at or near the lower Bollinger Band, the price is above VWAP, and the ATR is increasing.

Sell Signal: Triggered when the MACD line crosses below the signal line, the 50-day EMA crosses below the 100-day EMA, the RSI is above 70 (overbought), the price is at or near the upper Bollinger Band, the price is below VWAP, and the ATR is increasing.

How to Use:
Buy Signal: Consider entering a long position (buying gold) when you see a green "Buy" signal.

Sell Signal: Consider exiting a long position or entering a short position (selling gold) when you see a red "Sell" signal.

إخلاء المسؤولية