OPEN-SOURCE SCRIPT

cephxs + fadi / HTF PSP

8 835
HTF PSP - PRECISION SWING POINTS
Detect divergence-based Precision Swing Points (PSPs) across multiple higher timeframes with automatic correlated asset detection.


WHAT'S NEW (vs Original HTF Candles)

This indicator builds on fadizeidan's excellent ICT HTF Candles foundation with significant new functionality, depending on who you ask of course:

  • PSP Divergence Detection: Automatically identifies Precision Swing Points where price diverges from correlated assets—the original has no divergence analysis
  • Auto Asset Correlation: Uses AssetCorrelationUtils library to detect and pair correlated assets (ES↔NQ↔DXY, BTC↔ETH, Gold↔Silver, etc.)—no manual setup required
  • Multi-Asset Comparison: Tracks up to 3 correlated assets simultaneously with divergence relationships between all pairs
  • Dynamic Asset Reordering: When you switch charts, the indicator automatically reorders assets so your chart is always primary
  • Inverse Correlation Support: Properly handles inversely correlated assets like DXY (bullish DXY = bearish signal for risk assets)
  • HTF Sweep Detection: New sweep line feature highlights when HTF candles take out previous highs/lows and close back inside. One of my followers asked me for this, there you go anon.
  • 🔧 Streamlined to 3 HTFs: Focused design with 3 HTF slots (vs 6) for cleaner charts and better performance


The original remains excellent for pure HTF candle visualization. This version adds institutional flow analysis through divergence detection.

WHAT IT DOES

This indicator displays Higher Timeframe (HTF) candles to the right of your chart and highlights Precision Swing Points—pivots where price diverges from correlated assets. When ES makes a new high but NQ doesn't follow, or gold pushes higher while DXY fails to confirm, you're looking at institutional repositioning.

PSPs mark these moments on your HTF candles, giving you a clean visual signal for potential reversals.

HOW IT WORKS

Divergence Detection
The indicator compares price action between your chart and up to two correlated assets. A divergence occurs when one asset makes a directional move (bullish/bearish candle) while a correlated asset moves the opposite direction.

Three divergence relationships are tracked:
  • Primary vs Secondary (e.g., ES vs NQ)
  • Primary vs Tertiary (e.g., ES vs DXY)
  • Secondary vs Tertiary (e.g., NQ vs DXY)


PSP Confirmation
A candle is marked as a PSP when:
  1. A divergence exists between correlated assets
  2. A swing pivot forms (high > previous high AND high > next high, or vice versa for lows)


This dual confirmation filters noise and highlights only meaningful institutional activity.

Automatic Asset Detection
In Auto mode, the indicator uses the AssetCorrelationUtils library to detect your chart's asset class and automatically select the most relevant correlated pairs:

  • Indices: ES ↔ NQ ↔ DXY, YM ↔ ES ↔ NQ
  • Forex: EURUSD ↔ DXY ↔ GBPUSD, USDJPY ↔ DXY ↔ US10Y
  • Crypto: BTC ↔ ETH ↔ DXY
  • Metals: Gold ↔ Silver ↔ DXY
  • Energy: CL (Oil) ↔ NG ↔ DXY


HTF Sweep Detection
Sweeps are detected when an HTF candle (C2) takes out the high or low of the previous candle (C1) and then closes back inside. This marks liquidity grabs on the higher timeframe.

HOW TO USE

  1. Enable HTF timeframes: Select 1-3 higher timeframes relevant to your trading style (e.g., 30m, 90m, 4H for intraday traders)
  2. Watch for PSP candles: When a candle body color changes to the divergence color, a PSP has formed
  3. Note the direction: Bullish divergence (your asset bullish while correlated asset bearish) suggests upside; bearish divergence suggests downside
  4. Combine with LTF structure: Use PSPs as bias, then look for entry on lower timeframes (CHoCH, FVG, etc.)
  5. Sweeps confirm liquidity: A sweep followed by a PSP is a strong reversal signal


INPUTS

HTF Selection
  • HTF 1/2/3: Enable/disable each HTF slot with timeframe and candle count
  • Custom Daily Open: Use Midnight, 8:30, or 9:30 ET as daily candle open


Styling
  • Body/Border/Wick Colors: Customize bullish and bearish candle appearance
  • Padding/Buffer/HTF Buffer: Control spacing between candles and timeframe groups


Labels
  • HTF Label: Show timeframe name above/below candles
  • Remaining Time: Countdown to candle close
  • Label Position: Top, Bottom, or Both
  • Label Alignment: Align across timeframes or follow individual candles
  • Interval Value: Show interval details on candles


Imbalance
  • Fair Value Gap: Highlight FVGs on HTF candles
  • Volume Imbalance: Highlight VIs on HTF candles
  • HTF Sweeps: Show sweep lines when C2 takes out C1's high/low


Trace
  • Trace Lines: Draw lines from HTF candle OHLC levels back to chart price
  • Anchor: Anchor to first or last timeframe


PSP Divergence Detection
  • Precise Mode: Only highlight pivots on current asset (stricter confirmation)
  • Divergence Body Colors: Custom colors for bullish/bearish divergence candles


Asset Selection
  • Correlation Preset: Auto (library-detected) or Manual
  • Manual Assets 1/2/3: Specify custom correlated assets
  • Invert Asset 3: Flip the bullish/bearish interpretation for inverse correlations (e.g., DXY)


KEY FEATURES

  • Multi-HTF Display: Up to 3 higher timeframes displayed simultaneously
  • Auto Asset Detection: Automatically finds relevant correlated assets for your chart
  • Dynamic Reordering: When you switch charts, assets reorder so the chart is always primary
  • Inverse Correlation Support: Properly handles DXY and other inversely correlated assets
  • HTF Sweep Detection: Highlights liquidity grabs on higher timeframes
  • FVG/VI Detection: Fair Value Gaps and Volume Imbalances on HTF candles
  • Remaining Time Counter: Know exactly when the next HTF candle closes


BEST PRACTICES

  • Use PSPs as directional bias, not direct entries—wait for LTF confirmation
  • A PSP at a key level (previous day high, weekly open) carries more weight
  • Multiple PSPs across different HTFs pointing the same direction = stronger signal
  • Sweeps that fail to hold (sweep + PSP) often mark significant reversals
  • In Auto mode, trust the library's asset selection—it's been tuned for common correlations


DISCLAIMER
This indicator is for educational purposes only and does not constitute financial advice. Divergences and PSPs do not guarantee reversals—always use proper risk management and confirm signals with your own analysis. Past performance does not guarantee future results.


CREDITS
Original HTF candle plotting concept by @fadizeidan. PSP divergence detection and asset correlation logic by cephxs & fstarcapital. Uses the AssetCorrelationUtils library by fstarcapital.

Open Sourced For all.
Enjoy.

Made with ❤️ by cephxs + fadi

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.