Understand the market. Quantify the edge.
Free, public Pine Script tools for gold. Read the logic, copy the code, and test it on your own charts.
Synthetic data for illustration, not market prices. Hover or drag across the chart to read each bar. The overlay uses the same formulas as the script below.
XAUUSD Quantitative Indicator
An EMA basis with ATR bands drawn around it. The basis is lime when price closes above it and grey when it closes below, so trend side and stretched moves are visible at a glance. Alerts fire when price closes outside either band.
- Built for
- XAUUSD, any symbol works
- Timeframes
- 15 minute to 4 hour
- Pine version
- v6, overlay on the price chart
- Version
- 0.1.0, November 2026
- Access
- Public and free to use
Inputs
| Input | Default | What it changes |
|---|---|---|
| Basis length | 50 | How slowly the centre line follows price |
| ATR length | 14 | The volatility window for band width |
| Band multiplier | 2.0 | How far the bands sit from the basis |
0.1.0First public release.
Source code
Pine Script v6. Paste it into TradingView’s Pine Editor.
//@version=6
// XAUUSD Quantitative Indicator v0.1.0
// EMA basis with ATR bands. Basis colour shows which side of the EMA price is on.
indicator("XAUUSD Quantitative Indicator", shorttitle="AQL XAU", overlay=true)
// Inputs
basisLen = input.int(50, "Basis length", minval=2)
atrLen = input.int(14, "ATR length", minval=1)
mult = input.float(2.0, "Band multiplier", minval=0.1, step=0.1)
// Calculations
basis = ta.ema(close, basisLen)
width = ta.atr(atrLen) * mult
upper = basis + width
lower = basis - width
// Basis is lime above, grey below
basisColor = close > basis ? color.new(#b9f24c, 0) : color.new(#8a97a3, 0)
// Plots
pBasis = plot(basis, "Basis", basisColor, 2)
pUpper = plot(upper, "Upper band", color.new(#b9f24c, 65))
pLower = plot(lower, "Lower band", color.new(#b9f24c, 65))
fill(pUpper, pLower, color.new(#b9f24c, 92), "Band")
// Alerts
alertcondition(ta.crossover(close, upper), "Close above upper band", "Price closed above the upper band")
alertcondition(ta.crossunder(close, lower), "Close below lower band", "Price closed below the lower band")
Add it to TradingView
You need a free TradingView account. No other setup.
- Copy the code above.
- In TradingView, open a chart and click Pine Editor at the bottom.
- Paste the code, then click Add to chart.
- Open XAUUSD and adjust the inputs in the script settings.
About
I’m Arief, an independent developer building Pine Script tools for reading gold. Everything here is public, so you can read the logic, test it yourself, and tell me where it breaks.
- Instagram@username
- Emailyour-email@example.com