PROTECTED SOURCE SCRIPT

Malama's Candle Sniper

82
Malama's Candle Sniper
This Pine Script is an overlay indicator crafted for TradingView to detect and highlight a variety of bullish and bearish candlestick patterns directly on the price chart. Its primary goal is to assist traders in identifying potential reversal or continuation signals by marking these patterns with labeled visual cues. The indicator is versatile, applicable across different markets (e.g., stocks, forex, cryptocurrencies) and timeframes, making it a valuable tool for enhancing technical analysis and informing trading decisions.
Originality and Usefulness
While the candlestick patterns detected by this script are well-established in technical analysis, "Malama's Candle Sniper" stands out due to its comprehensive nature. It consolidates the detection of numerous patterns—ranging from engulfing patterns to doji variations and multi-candle formations—into a single, unified indicator. This eliminates the need for traders to apply multiple individual indicators, streamlining their charting process and saving time.
The indicator’s usefulness lies in its ability to:
Provide Visual Clarity: Labels are plotted on the chart when patterns are detected, offering immediate recognition of potential trading opportunities.

Broad Pattern Coverage: It identifies both bullish and bearish patterns, accommodating various market conditions and trading strategies.

This makes it an ideal tool for traders who incorporate candlestick analysis into their decision-making, whether for spotting trend reversals or confirming ongoing momentum.
How It Works
"Malama's Candle Sniper" operates by defining helper functions in Pine Script that evaluate whether specific candlestick pattern conditions are met for the current bar. Each function returns a boolean value (true/false) based on predefined criteria involving the open, high, low, and close prices of the candles. The script then checks for transitions from false to true (i.e., a pattern newly appearing) and plots a corresponding label on the chart.
Bullish Patterns Detected
The script identifies the following bullish patterns, which typically signal potential upward price movements:
Bullish Engulfing: A small bearish candle followed by a larger bullish candle that engulfs it.

Three White Soldiers: Three consecutive bullish candles with higher closes.

Bullish Three Line Strike: Three bullish candles followed by a bearish candle that doesn’t negate the prior uptrend.

Three Inside Up: A bearish candle, a smaller bullish candle within its range, and a strong bullish confirmation candle.

Dragonfly Doji: A doji with a long lower wick and little to no upper wick, opening and closing near the high.

Piercing Line: A bearish candle followed by a bullish candle that opens below the prior low and closes above the midpoint of the prior candle.

Bullish Marubozu: A strong bullish candle with no upper or lower wicks.

Bullish Abandoned Baby: A bearish candle, a doji gapped below it, and a bullish candle gapped above the doji.

Rising Window: A gap up between two candles, with the current low above the prior high.

Hammer: A candle with a small body and a long lower wick, indicating rejection of lower prices.

Morning Star: A three-candle pattern with a bearish candle, a small-bodied middle candle, and a strong bullish candle.

Bearish Patterns Detected
The script also detects these bearish patterns, which often indicate potential downward price movements:
Bearish Engulfing: A small bullish candle followed by a larger bearish candle that engulfs it.

Three Black Crows: Three consecutive bearish candles with lower closes.

Bearish Three Line Strike: Three bearish candles followed by a bullish candle that doesn’t reverse the downtrend.

Three Inside Down: A bullish candle, a smaller bearish candle within its range, and a strong bearish confirmation candle.

Gravestone Doji: A doji with a long upper wick and little to no lower wick, opening and closing near the low.

Dark Cloud Cover: A bullish candle followed by a bearish candle that opens above the prior high and closes below the midpoint of the prior candle.

Bearish Marubozu: A strong bearish candle with no upper or lower wicks.

Bearish Abandoned Baby: A bullish candle, a doji gapped above it, and a bearish candle gapped below the doji.

Falling Window: A gap down between two candles, with the current high below the prior low.

Hanging Man: A candle with a small body and a long lower wick after an uptrend, signaling potential reversal.

Label Plotting
When a pattern is detected (i.e., its condition transitions from false to true):
Bullish Patterns: A label is plotted at the high of the bar, using a green background with white text and a downward-pointing style (e.g., "Bull Engulf" for Bullish Engulfing).

Bearish Patterns: A label is plotted at the low of the bar, using a red background with white text and an upward-pointing style (e.g., "Bear Engulf" for Bearish Engulfing).

This visual distinction helps traders quickly differentiate between bullish and bearish signals and their precise locations on the chart.
Strategy and Risk Management
Backtesting: "Malama's Candle Sniper" is strictly an indicator and does not include backtesting capabilities or automated trading signals. It does not simulate trades or provide performance statistics such as win rates or profit/loss metrics.

Risk Management: As an informational tool, it lacks built-in risk management features. Traders must independently implement strategies like stop-loss orders, take-profit levels, or position sizing to manage risk when acting on the detected patterns. For example, a trader might place a stop-loss below a Hammer pattern’s low or above a Hanging Man’s high to limit potential losses.

User Settings and Customization
Inputs: The script does not offer user-configurable inputs. All pattern detection logic is hardcoded, meaning traders cannot adjust parameters such as lookback periods or pattern sensitivity through the interface.

Customization: Advanced users with Pine Script knowledge can modify the code directly to:
Add or remove patterns.

Adjust the conditions (e.g., tweak the wick-to-body ratio for a Hammer).

Change label styles or colors.
However, the default version is fixed and ready-to-use as is.

Visualizations and Chart Setup
Plotted Elements:
Bullish Labels: Appear at the candle’s high with a green background, white text, and a downward-pointing arrow (e.g., "Hammer").

Bearish Labels: Appear at the candle’s low with a red background, white text, and an upward-pointing arrow (e.g., "Hanging Man").

Chart Setup: The indicator is configured as an overlay (overlay=true), meaning it integrates seamlessly with the price chart. Labels are displayed directly on the candlesticks, eliminating the need for a separate pane and keeping the focus on price action.

Usage Example
To use "Malama's Candle Sniper":
Add the indicator to your TradingView chart via the Indicators menu.

Observe the price chart for green (bullish) or red (bearish) labels as they appear.

Analyze the context of each pattern (e.g., trend direction, support/resistance levels) to decide on potential trades.

Apply your own entry, exit, and risk management rules based on the signals.

For instance, spotting a "Morning Star" label during a downtrend near a support level might prompt a trader to consider a long position, while a "Dark Cloud Cover" at resistance could signal a short opportunity.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.