OPEN-SOURCE SCRIPT

Cosmic Volume Analyzer [JOAT]

212

Cosmic Volume Analyzer - Astrophysics Edition

Overview
Cosmic Volume Analyzer is an open-source oscillator indicator that applies astrophysics-inspired concepts to volume analysis. It classifies volume into buy/sell categories, calculates volume flow, detects accumulation/distribution phases, identifies climax volume events, and uses gravitational and stellar mass analogies to visualize volume dynamics.

What This Indicator Does
The indicator calculates and displays:

  • Volume Classification - Categorizes each bar as CLIMAX_BUY, CLIMAX_SELL, HIGH_BUY, HIGH_SELL, NORMAL_BUY, or NORMAL_SELL
  • Volume Flow - Percentage showing buy vs sell pressure over a lookback period
  • Buy/Sell Volume - Separated volume based on candle direction
  • Accumulation/Distribution - Phase detection using Money Flow Multiplier
  • Volume Oscillator - Fast vs slow volume EMA comparison
  • Gravitational Pull - Volume-weighted price attraction metric
  • Stellar Mass Index - Volume ratio combined with price momentum
  • Black Hole Detection - Identifies extremely low volume periods (liquidity voids)
  • Supernova Events - Detects extreme volume with extreme price movement
  • Orbital Cycles - Sine-wave based cyclical visualization


How It Works

Volume classification uses volume ratio and candle direction:

Pine Script®
classifyVolume(series float vol, series float close, series float open) => float avgVol = ta.sma(vol, 20) float volRatio = avgVol > 0 ? vol / avgVol : 1.0 if volRatio > 1.5 if close > open classification := "CLIMAX_BUY" else classification := "CLIMAX_SELL" else if volRatio > 1.2 // HIGH_BUY or HIGH_SELL else // NORMAL_BUY or NORMAL_SELL


Volume flow separates buy and sell volume over a period:

Pine Script®
calculateVolumeFlow(series float vol, series float close, simple int period) => float currentBuyVol = close > open ? vol : 0.0 float currentSellVol = close < open ? vol : 0.0 // Accumulate in buffers float flow = (buyVolume - sellVolume) / totalVol * 100


Accumulation/Distribution uses the Money Flow Multiplier:

Pine Script®
float mfm = ((close - low) - (high - close)) / (high - low) float mfv = mfm * vol float adLine = ta.cum(mfv) if adLine > adEMA and ta.rising(adLine, 3) phase := "ACCUMULATION" else if adLine < adEMA and ta.falling(adLine, 3) phase := "DISTRIBUTION"


Gravitational pull uses volume-weighted price distance:

Pine Script®
gravitationalPull(series float vol, series float price, simple int period) => float massCenter = ta.vwma(price, period) float distance = math.abs(price - massCenter) float mass = vol / ta.sma(vol, period) float gravity = distance > 0 ? mass / (distance * distance) : 0.0


Signal Generation
Signals are generated based on volume conditions:
  • Buy Climax: Volume exceeds 2 standard deviations above average on bullish candle
  • Sell Climax: Volume exceeds 2 standard deviations above average on bearish candle
  • Strong Buy Flow: Volume flow exceeds positive threshold (default 45%)
  • Strong Sell Flow: Volume flow exceeds negative threshold (default -45%)
  • Supernova: Volume 3x average AND price change 3x average
  • Black Hole: Volume 2 standard deviations below average


Dashboard Panel (Top-Right)
  • Volume Class - Current volume classification
  • Volume Flow - Buy/sell flow percentage
  • Buy Volume - Accumulated buy volume
  • Sell Volume - Accumulated sell volume
  • A/D Phase - ACCUMULATION/DISTRIBUTION/NEUTRAL
  • Volume Strength - Normalized volume strength
  • Gravity Pull - Current gravitational metric
  • Stellar Mass - Current stellar mass index
  • Cosmic Field - Combined cosmic field strength
  • Black Hole - Detection status and void strength
  • Signal - Current actionable status


Visual Elements
  • Volume Ratio Columns - Colored bars showing normalized volume
  • Volume Flow Line - Main oscillator showing flow direction
  • Flow EMA - Smoothed flow for trend reference
  • Volume Oscillator - Area plot showing fast/slow comparison
  • Gravity Field - Area plot showing gravitational pull
  • Orbital Cycle - Circle plots showing cyclical pattern
  • Stellar Mass Line - Line showing mass index
  • Climax Markers - Fire emoji for buy climax, snowflake for sell climax
  • Supernova Markers - Diamond shapes for extreme events
  • Black Hole Markers - X-cross for liquidity voids
  • A/D Phase Background - Subtle background color based on phase


Input Parameters
  • Volume Period (default: 20) - Period for volume calculations
  • Distribution Levels (default: 5) - Granularity of distribution analysis
  • Flow Threshold (default: 1.5) - Multiplier for flow significance
  • Accumulation Period (default: 14) - Period for A/D calculation
  • Gravitational Analysis (default: true) - Enable gravity metrics
  • Black Hole Detection (default: true) - Enable void detection
  • Stellar Mass Calculation (default: true) - Enable mass index
  • Orbital Cycles (default: true) - Enable cyclical visualization
  • Supernova Detection (default: true) - Enable extreme event detection


snapshot

Suggested Use Cases
  • Identify accumulation phases for potential long entries
  • Watch for distribution phases as potential exit signals
  • Use climax volume as potential exhaustion indicators
  • Monitor volume flow for directional bias
  • Avoid trading during black hole (low liquidity) periods
  • Watch for supernova events as potential trend acceleration


Timeframe Recommendations
Best on 15m to Daily charts. Volume analysis requires sufficient trading activity for meaningful readings.

Limitations
  • Volume data quality varies by exchange and instrument
  • Buy/sell separation is based on candle direction, not actual order flow
  • Astrophysics concepts are analogies, not literal physics
  • A/D phase detection may lag during rapid transitions


Open-Source and Disclaimer
This script is published as open-source under the Mozilla Public License 2.0 for educational purposes. It does not constitute financial advice. Past performance does not guarantee future results. Always use proper risk management.

- Made with passion by officialjackofalltrades

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.