This TradingView script implements the Pi Cycle Top & Bottom Oscillator, a technical indicator designed to identify potential market tops and bottoms using moving average relationships. Here's a detailed breakdown:
Indicator Overview Purpose: The indicator calculates an oscillator based on the ratio of a 111-day simple moving average (SMA) to double the 350-day SMA. It identifies potential overbought (market tops) and oversold (market bottoms) conditions. Visualization: The oscillator is displayed in a standalone pane with dynamic color coding to represent different market conditions. Inputs 111-Day Moving Average Length (length_111): Adjustable parameter for the short-term moving average. Default is 111 days. 350-Day Moving Average Length (length_350): Adjustable parameter for the long-term moving average. Default is 350 days. Overheat Threshold (upper_threshold): Percentage level above which the market is considered overheated. Default is 100%. Cooling Down Threshold (lower_threshold): Percentage level below which the market is cooling down. Default is 75%. Calculation Moving Averages: 111-day SMA of the closing price. 350-day SMA of the closing price. Double the 350-day SMA ( 𝑚 𝑎 _ 2 _ 350 = 𝑚 𝑎 _ 350 × 2 ma_2_350=ma_350×2). Oscillator: Ratio of the 111-day SMA to double the 350-day SMA, expressed as a percentage: oscillator = 𝑚 𝑎 _ 111 𝑚 𝑎 _ 2 _ 350 × 100 oscillator= ma_2_350 ma_111 ×100 Market Conditions Overheated Market (Potential Top): Oscillator >= Overheat Threshold (100% by default). Highlighted in red. Cooling Down Market (Potential Bottom): Oscillator <= Cooling Down Threshold (75% by default). Highlighted in green. Normal Market Condition: Oscillator is between these thresholds. Highlighted in blue. Visual Features Dynamic Oscillator Plot: Color-coded to indicate market conditions: Red: Overheated. Green: Cooling down. Blue: Normal condition. Threshold Lines: Red Dashed Line: Overheat Threshold. Green Dashed Line: Cooling Down Threshold. White Dashed Line: Additional high-value marker at 30 for reference. Alerts Overheat Alert: Triggers when the oscillator crosses the overheat threshold, signaling a potential market top. Cooling Down Alert: Triggers when the oscillator crosses the cooling down threshold, signaling a potential market bottom. Use Case This script is particularly useful for traders seeking early signals of market reversals. The thresholds and dynamic color coding provide visual cues and alerts to aid decision-making in identifying overbought or oversold conditions.