How the Script Works:
Pivot Points:
The script calculates pivot highs and pivot lows using user-defined lengths. These pivots can serve as important levels of support and resistance. Green lines represent support levels (pivot lows), and red lines represent resistance levels (pivot highs).
These pivot points are drawn only for the last 1000 bars to maintain clarity and efficiency.
Volume and Confirmation:
The script calculates a simple moving average (SMA) of volume over a user-defined period (default: 20 bars). For a signal to be valid, the volume of the current bar must be greater than this volume SMA.
The script also uses the close SMA to confirm buy and sell signals. When the price crosses under the close SMA, a sell confirmation occurs. When the price crosses above the close SMA, a buy confirmation occurs.
Candlestick Patterns:
Pin Bar (Bearish and Bullish): The script identifies Pin Bar patterns where the candlestick has a long upper wick (for bearish) or a long lower wick (for bullish), indicating potential price reversals.
Bearish Pin Bar: Long upper wick, small body, and close lower than open.
Bullish Pin Bar: Long lower wick, small body, and close higher than open.
Engulfing Pattern (Bearish and Bullish): The script detects Engulfing patterns, where the current candlestick fully engulfs the previous one.
Bearish Engulfing: Current candlestick closes below the previous low, with the body larger than the previous candlestick.
Bullish Engulfing: Current candlestick closes above the previous high, with the body larger than the previous candlestick.
Sell Signals:
Sell signals are generated when either the Pin Bar Bearish or Engulfing Bearish pattern is detected, along with a confirmation of high volume.
The sell signal is confirmed when the price crosses below the close SMA.
Sell signals are displayed as red upward arrows labeled "Sell" above the candlestick.
Buy Signals:
Buy signals are generated when either the Pin Bar Bullish or Engulfing Bullish pattern is detected, along with a confirmation of high volume.
The buy signal is confirmed when the price crosses above the close SMA.
Buy signals are displayed as green downward arrows labeled "Buy" below the candlestick.
Confirmation Indicators:
When a signal (buy or sell) is generated, the confirmation is shown with a blue triangle. For buy confirmations, triangles point upwards, and for sell confirmations, triangles point downwards.
How to Adjust the Settings:
Pivot High and Low Length:
You can change the length of the pivot highs and lows using the Pivot High Length and Pivot Low Length input settings. This will determine how many candles to consider before identifying a pivot point.
Volume SMA Length:
The Volume SMA Length setting allows you to adjust the period over which the moving average of volume is calculated. A higher length will smooth out volume fluctuations.
Close SMA Length:
The Close SMA Length defines the period for the moving average of the closing price, which is used to confirm the buy and sell signals.
Candlestick Pattern Sensitivity:
You can adjust the Pin Bar High Ratio and Pin Bar Low Ratio to fine-tune the sensitivity of the Pin Bar patterns. The default settings are:
Pin Bar High Ratio: 0.66 for the bearish Pin Bar (defines how long the upper wick should be relative to the entire candlestick).
Pin Bar Low Ratio: 0.33 for the bullish Pin Bar (defines how long the lower wick should be relative to the entire candlestick).
Practical Use Cases:
Buy and Sell Confirmation: You can use the script as a confirmation tool for existing strategies by only acting on signals when both the candlestick pattern and volume confirmation are present.
Scalping or Swing Trading: This script can be used in both lower time frames (e.g., 1-minute or 5-minute charts) for scalping or in higher time frames (e.g., daily charts) for swing trading.
Reversals and Continuations: The candlestick patterns help you identify potential market reversals, while the confirmation with SMA ensures you only take trades with momentum in your favor.
Key Tips:
Adjust the settings based on market conditions: In more volatile markets, you may want to reduce the length of the moving averages for quicker signals. In slower markets, longer periods can help filter out noise.
Volume is key: For the signals to be valid, the current volume should be above the moving average of volume. This helps you avoid false signals in low liquidity periods.