PSI SQUARE • case study • algorithmic trading

TradingView Cross-Asset Divergence Detection Indicator

A custom TradingView Pine Script indicator that monitors two user-selected symbols simultaneously, detects bullish and bearish divergence in real time, and automatically marks signals on the chart — with configurable comparison modes, timeframe selection, and sensitivity controls.

TradingViewPine ScriptDivergenceMulti-SymbolCorrelation
THE CHALLENGE

The challenge

Identifying divergence between correlated instruments manually requires monitoring multiple chart windows simultaneously — a slow, inconsistent process where signals are frequently missed because the comparison happens by eye across separate charts rather than automatically on a single view.

Key Project Constraints & Requirements

Dual Symbol Synchronous Ingestion

Simultaneously ingests and normalizes two distinct instruments (e.g. DXY vs EURUSD, ES vs NQ) on a single chart.

Bullish & Bearish Divergence Logic

Automates detection of regular and hidden divergences across corresponding structural swing highs and lows.

Multi-Mode Comparison Engine

Provides configurable comparison modes including direct price ratio, spread differentials, and normalized oscillators.

Custom Timeframe & Sensitivity

Allows traders to select independent resolution lookups and fine-tune divergence sensitivity thresholds.

Non-Repainting Pine Script v5 Engine

Engineered with strict bar confirmation to ensure visual markers and alert conditions are 100% reliable for live execution.

THE SOLUTION

The solution

A custom TradingView Pine Script indicator monitoring two user-selected symbols simultaneously and detecting bullish and bearish divergence conditions based on configurable comparison logic. When divergence is identified, the indicator automatically marks the signal on the chart with clear visual cues distinguishing bullish and bearish conditions. Multiple comparison modes, flexible timeframe selection, and sensitivity settings provide precise control across different instrument pairs and market conditions.

Multi-Asset Core

Cross-Symbol Normalization Engine

Uses secure multi-security data fetching with strict lookahead protection to sample secondary symbols without time-shift bias or repaint.

Swing Logic

Dynamic Swing Detection Module

Identifies structural peaks and troughs across both instruments simultaneously, calculating real-time slope differentials.

Comparison Modes

Configurable Comparison Modes

Supports price-to-price correlation, relative strength divergence, and oscillator overlays with user-defined sensitivity thresholds.

Visuals & Alerts

Visual Marking & Alert Core

Plots color-coded divergence lines and markers directly on chart candles, with instant webhook-compatible alert triggers.

THE ARCHITECTURE

Technical architecture

A breakdown of the multi-symbol data pipeline, comparison algorithms, and visual framework engineered for this Pine Script v5 indicator.

Platform
TradingView
Language
Pine Script v5
Symbols monitored
2 (user-selected)
Detection
Bullish and bearish divergence, real-time
Comparison modes
Multiple configurable modes
Timeframe
Flexible — user-selectable
Sensitivity
Configurable divergence threshold
VERIFIED OUTCOME

Verified outcome

Automated multi-asset correlation monitoring and real-time divergence visual feedback.

Real-time
Automated detection
Divergence detected and marked automatically
2 symbols
Single chart view
Monitored simultaneously from one chart
Configurable
Adaptive sensitivity
Sensitivity and comparison mode per pair

Instant Multi-Symbol Analysis & Clear Chart Signals

Divergence signals between two instruments are identified and marked on the chart automatically in real time — eliminating manual cross-chart comparison. Configurable sensitivity allows tuning for different instrument pairs and timeframes.

GET IN TOUCH

Ready to build your TradingView indicator?

Whether you need custom cross-asset divergence detection, multi-symbol correlation engines, or automated Pine Script signal alerts — tell us what you're building. We'll scope it, design it and deliver it to production standard.

Or email info@psi-square.net · Phone +44 (0) 20 3872 7195 · We reply within 24 hours · NDA available on request