OPEN-SOURCE SCRIPT
AQR Momentum Factor [JOAT]

AQR MOMENTUM FACTOR [JOAT]
A tribute to AQR Capital Management's seminal momentum-factor research — including Asness's classic "Value and Momentum Everywhere" framework. The script estimates cross-horizon momentum by ranking returns across five independent look-back horizons (default 1, 5, 20, 60, 120 bars — including the AQR-canonical 12-1 month equivalent), volatility-adjusting the result, and producing a composite momentum score in [−1, +1] that fires Buy / Sell labels when the score crosses configurable thresholds.

Why cross-horizon ranking
A single momentum lookback is fragile. AQR's published research (Asness, Moskowitz, Pedersen, and others) shows that momentum is best estimated by agreement across horizons — when short-, medium-, and long-term momentum all point the same way, the signal is much more reliable than any single horizon alone. The script encodes that directly:
The output is bounded in [−1, +1] and represents how unusual current momentum is relative to its own recent history, averaged across timeframes.
Volatility adjustment (optional but on by default)
The composite is divided by a volatility Z-score over a configurable window (default 60 bars), clamped at a Z cap (default 2.5) to avoid division-by-zero blow-ups. This dampens signals during high-volatility regimes — which is what AQR's "low-vol momentum" research finds is the genuinely tradeable component of the factor.
When vol-adjustment is off, the score is raw cross-horizon momentum. When it is on, the score is risk-adjusted momentum, which is the institutional read.
Signal engine
A configurable Min Bars Between Same-Side Signals (default 5) prevents clustering. A confirm-on-close toggle (default ON) ensures non-repaint signals.
Bar colouring — strict 2-hue discipline
The chart bars are coloured by the sign of the composite, with saturation proportional to magnitude. The "Bar Color Saturation Floor" input controls how aggressively the colour fades when momentum is weak — at 0 the bars are always full colour; at 1 they fade toward background when momentum is weak. The defaults (0.65) produce a clean institutional read where strong-momentum bars stand out and weak-momentum bars merge into the background.
A hidden composite-line plot (toggleable) opens a [−1, +1] pane below the chart for users who want to see the score itself, or feed it to Data Window / webhook automation.

Visual system
A locked Golden Blaze palette: gold bull / oxblood bear / off-white neutral on a dark-slate ground — the classic AQR institutional aesthetic. Strict 3-hue discipline + bg.
Dashboard
Monospaced table positionable to any of nine corners. Surfaces:
Alerts
Four alert conditions, each independently controllable:
How to read it
Three reads, in order of conviction:
Suggested settings
Defaults (horizons 1/5/20/60/120, rank window 252, vol window 60, vol Z cap 2.5, ±0.70 thresholds, ±0.90 extreme) are tuned for daily charts on broad indices — the timeframes where momentum factor exposures are statistically most meaningful. For lower timeframes drop all horizons proportionally (1/5/15/30/60) and the rank window to 200. For weekly+ keep defaults; momentum on weekly is the canonical factor.
Originality / what's reused
The momentum factor is published academic finance — Jegadeesh & Titman 1993, Asness 1994, AQR's "Value and Momentum Everywhere" 2013. The 252-bar / one-year ranking window is the classical institutional convention. The implementation here — the five-horizon configurable engine, the ta.percentrank-based ranking pipeline, the [−1, +1] linear remap, the volatility-Z adjustment with clamp, the saturation-floored bar-colouring with strict 2-hue discipline, the horizon-disagreement alert logic, and the AQR Golden Blaze palette — is JOAT-original. No third-party code reused. The script is a tribute to AQR's published methodology, not a direct replication of any proprietary AQR model.
Open source
Published open-source under the default Mozilla Public License 2.0. The horizon pipeline, the ranking engine, the vol-adjustment routine, the signal engine, and the dashboard are isolated modules. Forks welcome with credit.
Limitations
The 252-bar ranking window assumes a daily chart for the "trading year" interpretation; on lower timeframes the window represents a different real-world horizon. The momentum factor is well-documented historically but, like all factor exposures, it can underperform for extended periods — the dashboard's horizon-agreement count is the script's own early warning when the factor is breaking down. Vol-adjustment is on by default because it is statistically supported; turn it off only for research.
—
-made with passion by jackofalltrades
A tribute to AQR Capital Management's seminal momentum-factor research — including Asness's classic "Value and Momentum Everywhere" framework. The script estimates cross-horizon momentum by ranking returns across five independent look-back horizons (default 1, 5, 20, 60, 120 bars — including the AQR-canonical 12-1 month equivalent), volatility-adjusting the result, and producing a composite momentum score in [−1, +1] that fires Buy / Sell labels when the score crosses configurable thresholds.
Why cross-horizon ranking
A single momentum lookback is fragile. AQR's published research (Asness, Moskowitz, Pedersen, and others) shows that momentum is best estimated by agreement across horizons — when short-, medium-, and long-term momentum all point the same way, the signal is much more reliable than any single horizon alone. The script encodes that directly:
- Five horizons — 1 / 5 / 20 / 60 / 120 bars by default (configurable independently).
- At each horizon the return is percentile-ranked against its own trailing 252-bar (trading year) distribution.
- The five percentile ranks are mapped from [0, 100] to [−1, +1] (50% → 0; 100% → +1; 0% → −1).
- The composite is the average of the five mapped ranks.
The output is bounded in [−1, +1] and represents how unusual current momentum is relative to its own recent history, averaged across timeframes.
Volatility adjustment (optional but on by default)
The composite is divided by a volatility Z-score over a configurable window (default 60 bars), clamped at a Z cap (default 2.5) to avoid division-by-zero blow-ups. This dampens signals during high-volatility regimes — which is what AQR's "low-vol momentum" research finds is the genuinely tradeable component of the factor.
When vol-adjustment is off, the score is raw cross-horizon momentum. When it is on, the score is risk-adjusted momentum, which is the institutional read.
Signal engine
- BUY — composite > buy threshold (default +0.70 → top ~15% across horizons).
- SELL — composite < sell threshold (default −0.70).
- Extreme High / Low alerts — composite > +0.90 / < −0.90. The script's strongest reads.
A configurable Min Bars Between Same-Side Signals (default 5) prevents clustering. A confirm-on-close toggle (default ON) ensures non-repaint signals.
Bar colouring — strict 2-hue discipline
The chart bars are coloured by the sign of the composite, with saturation proportional to magnitude. The "Bar Color Saturation Floor" input controls how aggressively the colour fades when momentum is weak — at 0 the bars are always full colour; at 1 they fade toward background when momentum is weak. The defaults (0.65) produce a clean institutional read where strong-momentum bars stand out and weak-momentum bars merge into the background.
A hidden composite-line plot (toggleable) opens a [−1, +1] pane below the chart for users who want to see the score itself, or feed it to Data Window / webhook automation.
Visual system
- Buy / Sell labels on threshold crosses (configurable size).
- Bar colouring by signed momentum with saturation floor.
- Hidden composite line (toggleable, pane).
- Light regime background (off by default) — very subtle bgcolor sampled from bull/bear.
A locked Golden Blaze palette: gold bull / oxblood bear / off-white neutral on a dark-slate ground — the classic AQR institutional aesthetic. Strict 3-hue discipline + bg.
Dashboard
Monospaced table positionable to any of nine corners. Surfaces:
- Composite score with signed value.
- Per-horizon percentile ranks (h1 / h2 / h3 / h4 / h5).
- Horizon agreement count (how many horizons agree with the composite sign).
- Volatility Z value and adjustment factor in use.
- Last signal direction with bars-ago.
- Configuration: rank window, vol window, thresholds.
Alerts
Four alert conditions, each independently controllable:
- BUY (composite crosses above buy threshold)
- SELL (composite crosses below sell threshold)
- Extreme Score (|composite| crosses extreme high or low)
- Horizon Disagreement (off by default) — fires when horizons split (~half above 50%, half below). Useful as a "no edge" warning.
How to read it
Three reads, in order of conviction:
- Extreme score with full horizon agreement — the highest-conviction read. All five horizons agree, the score is in the top 10% / bottom 10% of its own distribution, and vol-adjustment has not damped it. This is the institutional setup.
- Buy / Sell with vol-adjustment active in a low-vol regime — the "low-vol momentum" setup AQR's research identifies as the strongest factor exposure. Pair with a directional execution tool.
- Horizon disagreement alert — stand-aside signal. Some horizons say bull, some say bear; there is no momentum factor exposure available. Wait for agreement to return.
Suggested settings
Defaults (horizons 1/5/20/60/120, rank window 252, vol window 60, vol Z cap 2.5, ±0.70 thresholds, ±0.90 extreme) are tuned for daily charts on broad indices — the timeframes where momentum factor exposures are statistically most meaningful. For lower timeframes drop all horizons proportionally (1/5/15/30/60) and the rank window to 200. For weekly+ keep defaults; momentum on weekly is the canonical factor.
Originality / what's reused
The momentum factor is published academic finance — Jegadeesh & Titman 1993, Asness 1994, AQR's "Value and Momentum Everywhere" 2013. The 252-bar / one-year ranking window is the classical institutional convention. The implementation here — the five-horizon configurable engine, the ta.percentrank-based ranking pipeline, the [−1, +1] linear remap, the volatility-Z adjustment with clamp, the saturation-floored bar-colouring with strict 2-hue discipline, the horizon-disagreement alert logic, and the AQR Golden Blaze palette — is JOAT-original. No third-party code reused. The script is a tribute to AQR's published methodology, not a direct replication of any proprietary AQR model.
Open source
Published open-source under the default Mozilla Public License 2.0. The horizon pipeline, the ranking engine, the vol-adjustment routine, the signal engine, and the dashboard are isolated modules. Forks welcome with credit.
Limitations
The 252-bar ranking window assumes a daily chart for the "trading year" interpretation; on lower timeframes the window represents a different real-world horizon. The momentum factor is well-documented historically but, like all factor exposures, it can underperform for extended periods — the dashboard's horizon-agreement count is the script's own early warning when the factor is breaking down. Vol-adjustment is on by default because it is statistically supported; turn it off only for research.
—
-made with passion by jackofalltrades
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.