OPEN-SOURCE SCRIPT

Rate of Change - ROC | TR

82
🎯 Overview
Rate of Change - ROC | TR is a classic momentum oscillator that measures the percentage change in price over a specified period. Developed by Tiagorocha1989, this enhanced version of the traditional Rate of Change indicator offers dual-mode operation with moving average customization and comprehensive visual features, helping traders identify the speed of price movements, momentum shifts, and potential reversal points with clarity and precision.

🔧 How It Works
The Rate of Change indicator calculates the percentage difference between the current price and the price from a specified number of periods ago. This measurement reveals whether price is accelerating (increasing ROC) or decelerating (decreasing ROC).

Core Calculation Logic:
The indicator calculates ROC using the standard formula:

ROC = [(Current Price - Price n-periods ago) / Price n-periods ago] × 100

Where n is the user-defined Length ROC

The resulting oscillator fluctuates around zero, with:

Positive ROC values indicating that prices are higher than they were n-periods ago (upward momentum)

Negative ROC values indicating that prices are lower than they were n-periods ago (downward momentum)

Zero line representing no net change over the period

The magnitude of the value indicates momentum strength:

Large positive values → Strong upward momentum

Large negative values → Strong downward momentum

Values approaching zero → Weakening momentum or consolidation

The indicator compares ROC to a reference line that can be either:

The traditional zero level

A user-defined moving average of ROC itself (ROC MA mode)

✨ Key Features
🔹 Dual Operating Modes
Zero Line Mode: Classic ROC implementation where signals occur when ROC crosses above or below the zero line

ROC MA Mode: Enhanced version where signals occur when ROC crosses its own moving average, providing smoother, filtered entries

🔹 Flexible Moving Average Selection
Choose from six MA types for the ROC MA mode:

EMA (Exponential Moving Average) for responsive signals

SMA (Simple Moving Average) for smoother readings

RMA (Rolling Moving Average) for weighted recent data

WMA (Weighted Moving Average) for customizable weighting

VWMA (Volume-Weighted Moving Average) incorporating volume

HMA (Hull Moving Average) for reduced lag

🔹 Customizable ROC Parameters
Length ROC: Lookback period for ROC calculation (default 35)

Source ROC: Price source for calculations (default Close)

🔹 Extended Range Visualization
The indicator includes gradient fills at +/-40, providing reference points for extreme momentum readings, though actual overbought/oversold levels vary by instrument.

🔹 Customizable Color Themes
Eight distinct color schemes to match your charting preferences:

Classic – Green for bullish, Red for bearish

Modern – White for bullish, Purple for bearish

Robust – Amber for bullish, Maroon for bearish

Accented – Violet for bullish, Pink for bearish

Monochrome – Light gray for bullish, Dark gray for bearish

Moderate – Green for bullish, Red for bearish

Aqua – Blue for bullish, Orange for bearish

Cosmic – Pink for bullish, Purple for bearish

🔹 Comprehensive Visual Feedback
Colored ROC Line: Changes color based on position relative to the reference line

Signal Line: Yellow line showing zero or MA reference

Gradient Fill Zones: Clear visualization of extreme momentum readings

Dynamic Zone Fills: Semi-transparent fills showing when ROC is above or below the reference line

Color-Coded Candles: Bars reflect current ROC bias (above or below reference)

Signal Markers: Triangle up/down symbols at crossover points

Live Value Display: Current ROC value shown in a floating label

Trend Table: Bullish/Bearish status displayed on the chart

🔹 Ready-to-Use Alerts
Built-in alert conditions trigger LONG signals on bullish crossovers and SHORT signals on bearish crossunders across both operating modes.

⚙️ Settings Summary
Color Choice: Select from eight visual themes (Default: Classic)

Length ROC: Lookback period for ROC calculation (Default: 35)

Source ROC: Price source for calculations (Default: Close)

Entry/Exit Signal: Choose between zero line or ROC MA mode (Default: Zero Line)

Length MA: Moving average period for ROC MA mode (Default: 365)

ROC MA Type: Moving average method for signal line (Default: EMA)

📈 Practical Applications
🔹 Trend Direction Identification
The ROC line's position relative to zero indicates trend direction:

ROC above zero → Bullish trend

ROC below zero → Bearish trend

The steepness of the slope indicates momentum strength

🔹 Zero Line Crossovers
In Zero Line mode, crossovers provide momentum signals:

Crossover above zero → Bullish momentum strengthening, potential trend reversal up

Crossunder below zero → Bearish momentum strengthening, potential trend reversal down

These are among the simplest and most intuitive trading signals

🔹 Signal Line Crossovers
In ROC MA mode, crossovers between ROC and its moving average provide filtered signals:

ROC crosses above its MA → Bullish signal

ROC crosses below its MA → Bearish signal

These signals reduce whipsaws in choppy markets

🔹 Divergence Trading
ROC is excellent for spotting divergences:

Bullish Divergence: Price makes lower low, ROC makes higher low → Potential upside reversal

Bearish Divergence: Price makes higher high, ROC makes lower high → Potential downside reversal

Divergences are most significant when occurring at extreme levels

🔹 Momentum Confirmation
The slope and magnitude of ROC confirm trend strength:

Rising ROC values → Strengthening bullish momentum

Falling ROC values → Strengthening bearish momentum

Flattening ROC → Momentum slowing, potential trend change

🔹 Centerline Rejections
When ROC approaches zero but reverses before crossing, it can signal trend continuation:

ROC pulls back toward zero but reverses up → Bullish continuation

ROC rallies toward zero but reverses down → Bearish continuation

🔹 Multiple Timeframe Analysis
Compare ROC readings across different timeframes:

Higher timeframe ROC confirms primary trend direction

Lower timeframe ROC identifies entry timing and short-term momentum shifts

🎯 Ideal For
✅ Trend Traders seeking to confirm trend direction and strength

✅ Momentum Traders wanting to measure the rate of price change

✅ Divergence Traders looking for early reversal signals

✅ Swing Traders capturing medium-term momentum shifts

✅ System Developers needing simple, reliable crossover logic

✅ Beginner Traders starting with one of the most intuitive indicators

📌 Key Takeaways
Percentage-Based Measurement: ROC expresses momentum as a percentage, making it comparable across different price levels and instruments

Dual-Mode Flexibility: Choose between classic zero-line crossovers for simplicity or MA-smoothed signals for filtered entries

Unbounded Nature: Unlike RSI or Stochastic, ROC has no upper or lower limits, making it suitable for strongly trending markets

Comprehensive Visualization: Color themes, gradient fills for extreme readings, candles, and labels provide immediate market awareness

Divergence Capability: Excellent for spotting both regular and hidden divergences

Alert-Ready: Built-in alerts for both LONG and SHORT signals across both operating modes

⚠️ Important Notes
Because ROC is unbounded, the scale will vary significantly between different instruments and timeframes. The gradient fills at +/-40 are arbitrary reference points and may not represent actual overbought/oversold conditions for all instruments. The default length of 35 provides a medium-term perspective; shorter lengths (9-14) provide more responsive signals, while longer lengths identify longer-term trends. The 365-day MA default in ROC MA mode is designed for longer-term trend context on daily charts. Divergences are most reliable when they occur after extended trends. Always combine with proper risk management and additional confirmation for best results.

Disclaimer: This indicator is provided for educational and informational purposes only. Past performance is not indicative of future results. Always conduct thorough testing and align with your risk management strategy before live deployment.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.