TEXT

Candlestick Reversal Pattern Detector in Pine Script

Contributed by cutejsq@gmail.com

Improved by Laravel Company · 2026-09-07

Prompt v2:

Act as an expert TradingView Pine Script v5 developer. Your mission is to design a sophisticated custom indicator that automatically identifies and labels specific candlestick reversal patterns on the price chart, providing users with precise entry signals and optional trend confirmation tools.

Your objective is to:

  • Implement automatic detection and plotting for the following candlestick patterns:
    • Bullish Patterns: Morning Star, Hammer
    • Bearish Patterns: Evening Star, Bearish Engulfing
  • For each identified pattern:
    • Plot a prominent green upward arrow below the relevant candle for bullish patterns, displaying the text "BUY: Pattern Name" in a clear and legible font.
    • Plot a distinct red downward arrow above the candle for bearish patterns, displaying the text "SELL: Pattern Name" for quick recognition.
  • Integrate an optional moving average trend confirmation feature:
    • Allow users to input the length of the moving average (default to 50).
    • Restrict bullish signals to only appear above the moving average line and bearish signals to only appear below it.
    • Provide a toggle to enable/disable this feature.
  • Add an optional RSI panel:
    • Include an input field for the RSI length (default to 14).
    • Allow users to set custom overbought and oversold levels (default to 70 and 30).
    • Implement an additional filter for signals using the RSI (on/off toggle).
  • Ensure the indicator overlays signals directly on the price chart, using vibrant colors, clear labels, and distinct arrow styles for optimal visibility.
  • Provide individual toggles for enabling/disabling each candlestick pattern, allowing users to customize their preferred pattern detection.
  • Optimize the script for performance, ensuring minimal resource usage and compatibility with TradingView's platform.
  • Implement proper documentation, including input parameters, output formats, and usage instructions.
  • Maintain a clean and well-commented code structure for easy maintenance and updates.

Deliver a polished, production-ready script that meets the highest standards of TradingView developers, providing users with a powerful, user-friendly tool for technical analysis and trading.

Original prompt (before our improvements)

Act as a TradingView Pine Script v5 developer. You are tasked with creating an indicator that automatically detects and plots candlestick reversal patterns on the price chart. Your task is to: - Identify and label the following candlestick patterns: - Bullish: Morning Star, Hammer - Bearish: Evening Star, Bearish Engulfing - For each detected pattern: - Plot a green upward arrow below the candle for bullish patterns with the text “BUY: Pattern Name” - Plot a red downward arrow above the candle for bearish patterns with the text “SELL: Pattern Name” - Add optional trend confirmation using a moving average (user-selectable length). - Only show bullish signals above the MA and bearish signals below the MA (toggleable). - Include an optional RSI panel: - RSI length input - Overbought and oversold levels - Allow RSI to be used as an additional filter for signals (on/off) - Ensure the indicator overlays signals on the price chart and uses clear labels and arrows - Allow user inputs to enable/disable each candlestick pattern individually - Make sure the script is clean, optimized, and fully compatible with TradingView.