Arief Quant Lab

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.

Basis: lime above, grey below Bands at 2 × ATR Last close

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

InputDefaultWhat it changes
Basis length50How slowly the centre line follows price
ATR length14The volatility window for band width
Band multiplier2.0How 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.

  1. Copy the code above.
  2. In TradingView, open a chart and click Pine Editor at the bottom.
  3. Paste the code, then click Add to chart.
  4. 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.