PROTECTED SOURCE SCRIPT

[TehThomas] - CandleStick Patterns

213
Script Overview
This script is designed to identify and highlight various candlestick patterns on a trading chart. It detects bullish, bearish, indecisive, and continuation patterns and visually represents them with color-coded bars. Additionally, it displays a table summarizing the detected patterns.

Key Features

Candlestick Pattern Detection

Identifies multiple candlestick patterns, including:
  • Bullish Patterns: Bullish Engulfing, Hammer, Inverse Hammer, Morning Star, Piercing Line.
  • Bearish Patterns: Bearish Engulfing, Hanging Man, Shooting Star, Evening Star, Dark Cloud Cover.
  • Indecisive Patterns: Doji, Dragonfly Doji, Gravestone Doji.
  • Each pattern is assigned a distinct color for easy visualization.


Customizable Visibility & Colors
  • Users can enable or disable the detection of specific patterns.
  • Custom colors can be assigned to each pattern for better chart clarity.


Trend Identification
  • Uses the Simple Moving Average (SMA) to determine whether the market is in an uptrend or downtrend.
  • Helps in filtering patterns based on the prevailing trend.


Pattern Highlighting
  • Changes the color of the candlesticks whenever a pattern is detected.
  • Uses barcolor() to color the candles accordingly.


Pattern Dashboard (Table Display)
  • A static table in the top-right corner of the chart summarizes the detected patterns.
  • Ensures the table is only created once per chart load to avoid performance issues.


Function Breakdown

1. Input Parameters
  • Uses input.bool() to allow traders to toggle specific patterns on or off.
  • Uses input.color() to let users customize the colors for different patterns.

2. Candlestick Measurements
  • bodySize(index): Measures the absolute size of the candle body.
  • upperWick(index): Measures the upper wick size.
  • lowerWick(index): Measures the lower wick size.

3. Trend Determination
  • isUptrend(length): Checks if the price is above its SMA (indicating an uptrend).
  • isDowntrend(length): Checks if the price is below its SMA (indicating a downtrend).

4. Candlestick Pattern Identification
Engulfing Patterns
  • Bullish Engulfing: A large green candle fully engulfs the previous red candle, occurring in a downtrend.
  • Bearish Engulfing: A large red candle fully engulfs the previous green candle, occurring in an uptrend.

Hammer & Related Patterns
  • Hammer: A candle with a small body and a long lower wick, appearing after a downtrend.
  • Inverse Hammer: A candle with a small body and a long upper wick, appearing after a downtrend.
  • Hanging Man: A Hammer-like pattern that appears in an uptrend.
  • Shooting Star: An Inverse Hammer-like pattern that appears in an uptrend.

Doji Patterns
  • Doji: A candle with a small body (open and close prices nearly equal).
  • Dragonfly Doji: A Doji with a long lower wick.
  • Gravestone Doji: A Doji with a long upper wick.

Star Patterns
  • Morning Star: A bullish reversal pattern consisting of three candles.
  • Evening Star: A bearish reversal pattern consisting of three candles.

Continuation Patterns
  • Piercing Line: A two-candle bullish continuation pattern.
  • Dark Cloud Cover: A two-candle bearish continuation pattern.

5. Candlestick Coloring
  • Uses barcolor() to color the candles based on the detected pattern.
  • The color is determined using a conditional statement, ensuring only one pattern applies per candle.

6. Pattern Dashboard
  • Uses tables (table.new()) to display a static dashboard with all enabled patterns.
  • Calls updateTableCell() to add rows for each active pattern.


How This Script is Useful for Trading
1. Identifying Trade Opportunities
  • Helps traders spot potential reversal points (e.g., Bullish Engulfing, Hammer, Morning Star).
  • Highlights trend continuation signals (e.g., Piercing Line, Dark Cloud Cover).

2. Confirming Trend Strength
  • Engulfing patterns in the direction of the trend confirm trend strength.
  • Doji and indecisive patterns warn traders of potential reversals or trend slowdowns.

3. Enhancing Trade Entries & Exits
  • Enter long positions after spotting bullish patterns like Morning Star, Hammer.
  • Exit long positions when bearish patterns like Evening Star, Shooting Star appear.
  • Enter short positions upon seeing bearish engulfing, Hanging Man, or Dark Cloud Cover.

4. Improving Risk Management
  • Traders can set stop-loss orders based on the pattern structure.
  • Example: Placing stop-loss below the low of a Hammer confirms bullish strength.

5. Works with Other Indicators
  • Can be combined with RSI, MACD, Bollinger Bands for more reliable signals.


Limitations
  • False Signals: Candlestick patterns alone are not 100% reliable; traders should confirm signals with volume and trend analysis.
  • No Automatic Alerts: This script does not send trading alerts; manual observation is required.
  • No Multi-Timeframe Analysis: It only considers the timeframe it is applied to.


Final Thoughts
This script is a powerful visual tool for traders who rely on candlestick patterns. It helps identify potential reversals, continuations, and indecision zones in the market. While it’s highly useful for discretionary trading, it’s best used alongside other technical indicators to confirm trade setups.

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。