OPEN-SOURCE SCRIPT

XAUUSD/SPX Slope with Bollinger Bands %B

35
The XAUUSD/SPX Slope with Bollinger Bands %B Indicator plots the slope of the XAUUSD (Gold) to SPX (S&P 500) ratio (blue line) using linear regression (default 20 bars) to show Gold’s relative performance against stocks. Bollinger Bands %B (length: 20, StdDev: 2.0) is calculated on the chart’s current symbol (e.g., GLD, BTCUSD) and plotted in yellow, indicating the symbol’s price position within its bands (0 to 1 range). The slope’s zero is aligned with the %B middle band (0.5) for easy comparison. A positive slope (above 0.5) suggests Gold outperforming SPX, while %B above 1 indicates overbought conditions and below 0 indicates oversold for the chart’s symbol. Overbought (1), middle (0.5), and oversold (0) lines, with optional background fills (green for overbought, blue for middle, red for oversold, unchecked by default), aid interpretation. Adjust the slope scale factor for visibility.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.