PROTECTED SOURCE SCRIPT
Malama's Heikin Count

Malama's Heikin Count is a Pine Script indicator designed to enhance price action analysis by combining Heikin Ashi candlestick calculations with a normalized measurement of upper and lower shadow sizes. The indicator overlays Heikin Ashi candles on the chart and displays the relative sizes of upper and lower shadows as numerical labels (scaled from 1 to 10) for candles within the last two days, starting from 9:00 AM each day. This tool aims to help traders identify the strength of price movements and potential reversals by quantifying the significance of candlestick shadows in the context of Heikin Ashi’s smoothed price data. It is particularly useful for day traders and swing traders who rely on candlestick patterns to gauge market sentiment and momentum.
The indicator solves the problem of interpreting raw candlestick data by providing a smoothed visualization through Heikin Ashi candles and a simplified, numerical representation of shadow sizes. This allows traders to quickly assess whether a candle’s upper or lower shadow indicates strong buying or selling pressure, aiding in decision-making for entries, exits, or reversals.
Originality and Usefulness
Originality: While Heikin Ashi candles are a well-known technique for smoothing price data and reducing noise, Malama's Heikin Count introduces a novel feature by calculating and normalizing the sizes of upper and lower shadows relative to the total candle height. Unlike standard Heikin Ashi implementations, which focus solely on candle body trends, this indicator quantifies shadow proportions and presents them on a standardized 1–10 scale. This normalization makes it easier for traders to compare shadow significance across different timeframes and assets without needing to manually interpret raw measurements. The restriction of shadow size labels to the last two days from 9:00 AM ensures relevance for active trading sessions, avoiding clutter from older data.
Usefulness: The indicator is particularly valuable for traders who combine candlestick pattern analysis with trend-following strategies. By integrating Heikin Ashi’s trend-smoothing capabilities with shadow size metrics, it provides a unique perspective on market dynamics. For example, large upper shadows (high normalized values) may indicate rejection at resistance levels, while large lower shadows may suggest support or buying pressure. Unlike other open-source Heikin Ashi indicators, which typically focus only on candle plotting, this script’s shadow size normalization and time-based filtering offer a distinctive tool for intraday and short-term trading strategies.
Detailed Methodology ("How It Works")
The core logic of Malama's Heikin Count revolves around three main components: Heikin Ashi candle calculations, shadow size analysis, and time-based filtering for label display. Below is a breakdown of how these components work together:
Heikin Ashi Candle Calculations:
The script calculates Heikin Ashi candles to smooth price data and reduce market noise, making trends easier to identify.
Formulas:
haClose = (open + high + low + close) / 4: The Heikin Ashi close is the average of the current bar’s open, high, low, and close prices.
haOpen = na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2: The Heikin Ashi open is either the average of the current bar’s open and close (for the first bar) or the average of the previous Heikin Ashi open and close.
haHigh = max(high, max(haOpen, haClose)): The Heikin Ashi high is the maximum of the current bar’s high, Heikin Ashi open, and Heikin Ashi close.
haLow = min(low, min(haOpen, haClose)): The Heikin Ashi low is the minimum of the current bar’s low, Heikin Ashi open, and Heikin Ashi close.
These calculations produce smoothed candles that emphasize trend direction and reduce the impact of short-term price fluctuations.
Shadow Size Analysis:
The script calculates the upper and lower shadows of each Heikin Ashi candle to assess market sentiment.
Formulas:
upperShadow = haHigh - max(haClose, haOpen): Measures the length of the upper shadow (distance from the top of the candle body to the high).
lowerShadow = min(haClose, haOpen) - haLow: Measures the length of the lower shadow (distance from the bottom of the candle body to the low).
totalHeight = haHigh - haLow: Calculates the total height of the candle (from high to low).
upperShadowPercentage = (upperShadow / totalHeight) * 100: Converts the upper shadow length to a percentage of the total candle height.
lowerShadowPercentage = (lowerShadow / totalHeight) * 100: Converts the lower shadow length to a percentage of the total candle height.
Normalization: The normalizeShadowSize function scales the shadow percentages to a 1–10 range using math.round(value / 10). This ensures that shadow sizes are presented in an easily interpretable format, where 1 represents a very small shadow (less than 10% of the candle height) and 10 represents a very large shadow (90–100% of the candle height). The normalization caps values between 1 and 10 for consistency.
Time-Based Filtering:
The script only displays shadow size labels for candles within the last two days, starting from 9:00 AM each day. This is achieved by calculating a start timestamp using timestamp(year(timenow), month(timenow), dayofmonth(timenow) - daysBack, startHour, startMinute), where daysBack = 2, startHour = 9, and startMinute = 0.
The condition time >= startTime ensures that labels are only plotted for candles within this time window, keeping the chart relevant for recent trading activity and avoiding clutter from older data.
Signal Generation:
The script does not generate explicit buy or sell signals but provides visual cues through shadow size labels. Large upper shadow sizes (e.g., 8–10) may indicate selling pressure or resistance, while large lower shadow sizes may suggest buying pressure or support. Traders can use these metrics in conjunction with the Heikin Ashi candle colors (green for bullish, red for bearish) to make trading decisions.
Strategy Results and Risk Management
Backtesting: The script is an indicator and does not include built-in backtesting or strategy logic for generating buy/sell signals. As such, it does not assume specific commission, slippage, or account sizing parameters. Traders using this indicator should incorporate it into their existing strategies, applying their own risk management rules.
Risk Management Guidance:
Traders can use the shadow size labels to inform risk management decisions. For example, a large upper shadow (e.g., 8–10) at a resistance level may prompt a trader to set a tighter stop-loss above the candle’s high, anticipating a potential reversal. Conversely, a large lower shadow at a support level may suggest a wider stop-loss below the low to account for volatility.
Default settings (e.g., 2-day lookback, 9:00 AM start) are designed to focus on recent price action, which is suitable for intraday and short-term swing trading. Traders should combine the indicator with other tools (e.g., support/resistance levels, trendlines) to define risk limits, such as risking 5–10% of equity per trade.
The indicator does not enforce specific risk management settings, allowing traders to customize their approach based on their risk tolerance and trading style.
User Settings and Customization
The script includes the following user-customizable inputs:
Days Back (daysBack = 2):
Description: Controls the lookback period for displaying shadow size labels. The default value of 2 means labels are shown for candles within the last two days.
Impact: Increasing daysBack extends the time window for label display, which may be useful for longer-term analysis but could clutter the chart. Decreasing it focuses on more recent data, ideal for intraday trading.
Start Hour (startHour = 9) and Start Minute (startMinute = 0):
Description: Defines the start time of the trading day (default is 9:00 AM). Labels are only shown for candles after this time each day within the lookback period.
Impact: Traders can adjust these settings to align with their preferred trading session (e.g., 9:30 AM for U.S. market open). Changing the start time shifts the time window for label display, affecting which candles are analyzed.
These settings allow traders to tailor the indicator to their trading timeframe and session preferences, ensuring that the shadow size labels remain relevant to their analysis.
Visualizations and Chart Setup
The indicator plots the following elements on the chart:
Heikin Ashi Candles:
Plotted using plotcandle(haOpen, haClose, haHigh, haLow), these candles overlay the standard price chart.
Color Coding: Green candles indicate bullish momentum (Heikin Ashi close ≥ open), while red candles indicate bearish momentum (Heikin Ashi close < open).
These candles provide a smoothed view of price trends, making it easier to identify trend direction and continuations.
Shadow Size Labels:
Upper Shadow Labels: Displayed above each candle at the Heikin Ashi high, showing the normalized upper shadow size (1–10). These labels are green with white text and use the label.style_label_down style for clear visibility.
Lower Shadow Labels: Displayed below each candle at the Heikin Ashi low, showing the normalized lower shadow size (1–10). These labels are red with white text and use the label.style_label_up style.
Labels are only shown for candles within the last two days from 9:00 AM, ensuring that only recent and relevant data is visualized.
Debugging Labels (Optional):
A blue label at the bottom of the chart displays the text "Upper: [value] Lower: [value]" for each candle, showing both shadow sizes for debugging purposes. This can be removed or commented out if not needed, as it is primarily for development use.
The visualizations are designed to be minimal and focused, ensuring that traders can quickly interpret the Heikin Ashi trend and shadow size metrics without unnecessary clutter. The use of color-coded candles and labels enhances readability, while the time-based filtering keeps the chart clean and relevant.
The indicator solves the problem of interpreting raw candlestick data by providing a smoothed visualization through Heikin Ashi candles and a simplified, numerical representation of shadow sizes. This allows traders to quickly assess whether a candle’s upper or lower shadow indicates strong buying or selling pressure, aiding in decision-making for entries, exits, or reversals.
Originality and Usefulness
Originality: While Heikin Ashi candles are a well-known technique for smoothing price data and reducing noise, Malama's Heikin Count introduces a novel feature by calculating and normalizing the sizes of upper and lower shadows relative to the total candle height. Unlike standard Heikin Ashi implementations, which focus solely on candle body trends, this indicator quantifies shadow proportions and presents them on a standardized 1–10 scale. This normalization makes it easier for traders to compare shadow significance across different timeframes and assets without needing to manually interpret raw measurements. The restriction of shadow size labels to the last two days from 9:00 AM ensures relevance for active trading sessions, avoiding clutter from older data.
Usefulness: The indicator is particularly valuable for traders who combine candlestick pattern analysis with trend-following strategies. By integrating Heikin Ashi’s trend-smoothing capabilities with shadow size metrics, it provides a unique perspective on market dynamics. For example, large upper shadows (high normalized values) may indicate rejection at resistance levels, while large lower shadows may suggest support or buying pressure. Unlike other open-source Heikin Ashi indicators, which typically focus only on candle plotting, this script’s shadow size normalization and time-based filtering offer a distinctive tool for intraday and short-term trading strategies.
Detailed Methodology ("How It Works")
The core logic of Malama's Heikin Count revolves around three main components: Heikin Ashi candle calculations, shadow size analysis, and time-based filtering for label display. Below is a breakdown of how these components work together:
Heikin Ashi Candle Calculations:
The script calculates Heikin Ashi candles to smooth price data and reduce market noise, making trends easier to identify.
Formulas:
haClose = (open + high + low + close) / 4: The Heikin Ashi close is the average of the current bar’s open, high, low, and close prices.
haOpen = na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2: The Heikin Ashi open is either the average of the current bar’s open and close (for the first bar) or the average of the previous Heikin Ashi open and close.
haHigh = max(high, max(haOpen, haClose)): The Heikin Ashi high is the maximum of the current bar’s high, Heikin Ashi open, and Heikin Ashi close.
haLow = min(low, min(haOpen, haClose)): The Heikin Ashi low is the minimum of the current bar’s low, Heikin Ashi open, and Heikin Ashi close.
These calculations produce smoothed candles that emphasize trend direction and reduce the impact of short-term price fluctuations.
Shadow Size Analysis:
The script calculates the upper and lower shadows of each Heikin Ashi candle to assess market sentiment.
Formulas:
upperShadow = haHigh - max(haClose, haOpen): Measures the length of the upper shadow (distance from the top of the candle body to the high).
lowerShadow = min(haClose, haOpen) - haLow: Measures the length of the lower shadow (distance from the bottom of the candle body to the low).
totalHeight = haHigh - haLow: Calculates the total height of the candle (from high to low).
upperShadowPercentage = (upperShadow / totalHeight) * 100: Converts the upper shadow length to a percentage of the total candle height.
lowerShadowPercentage = (lowerShadow / totalHeight) * 100: Converts the lower shadow length to a percentage of the total candle height.
Normalization: The normalizeShadowSize function scales the shadow percentages to a 1–10 range using math.round(value / 10). This ensures that shadow sizes are presented in an easily interpretable format, where 1 represents a very small shadow (less than 10% of the candle height) and 10 represents a very large shadow (90–100% of the candle height). The normalization caps values between 1 and 10 for consistency.
Time-Based Filtering:
The script only displays shadow size labels for candles within the last two days, starting from 9:00 AM each day. This is achieved by calculating a start timestamp using timestamp(year(timenow), month(timenow), dayofmonth(timenow) - daysBack, startHour, startMinute), where daysBack = 2, startHour = 9, and startMinute = 0.
The condition time >= startTime ensures that labels are only plotted for candles within this time window, keeping the chart relevant for recent trading activity and avoiding clutter from older data.
Signal Generation:
The script does not generate explicit buy or sell signals but provides visual cues through shadow size labels. Large upper shadow sizes (e.g., 8–10) may indicate selling pressure or resistance, while large lower shadow sizes may suggest buying pressure or support. Traders can use these metrics in conjunction with the Heikin Ashi candle colors (green for bullish, red for bearish) to make trading decisions.
Strategy Results and Risk Management
Backtesting: The script is an indicator and does not include built-in backtesting or strategy logic for generating buy/sell signals. As such, it does not assume specific commission, slippage, or account sizing parameters. Traders using this indicator should incorporate it into their existing strategies, applying their own risk management rules.
Risk Management Guidance:
Traders can use the shadow size labels to inform risk management decisions. For example, a large upper shadow (e.g., 8–10) at a resistance level may prompt a trader to set a tighter stop-loss above the candle’s high, anticipating a potential reversal. Conversely, a large lower shadow at a support level may suggest a wider stop-loss below the low to account for volatility.
Default settings (e.g., 2-day lookback, 9:00 AM start) are designed to focus on recent price action, which is suitable for intraday and short-term swing trading. Traders should combine the indicator with other tools (e.g., support/resistance levels, trendlines) to define risk limits, such as risking 5–10% of equity per trade.
The indicator does not enforce specific risk management settings, allowing traders to customize their approach based on their risk tolerance and trading style.
User Settings and Customization
The script includes the following user-customizable inputs:
Days Back (daysBack = 2):
Description: Controls the lookback period for displaying shadow size labels. The default value of 2 means labels are shown for candles within the last two days.
Impact: Increasing daysBack extends the time window for label display, which may be useful for longer-term analysis but could clutter the chart. Decreasing it focuses on more recent data, ideal for intraday trading.
Start Hour (startHour = 9) and Start Minute (startMinute = 0):
Description: Defines the start time of the trading day (default is 9:00 AM). Labels are only shown for candles after this time each day within the lookback period.
Impact: Traders can adjust these settings to align with their preferred trading session (e.g., 9:30 AM for U.S. market open). Changing the start time shifts the time window for label display, affecting which candles are analyzed.
These settings allow traders to tailor the indicator to their trading timeframe and session preferences, ensuring that the shadow size labels remain relevant to their analysis.
Visualizations and Chart Setup
The indicator plots the following elements on the chart:
Heikin Ashi Candles:
Plotted using plotcandle(haOpen, haClose, haHigh, haLow), these candles overlay the standard price chart.
Color Coding: Green candles indicate bullish momentum (Heikin Ashi close ≥ open), while red candles indicate bearish momentum (Heikin Ashi close < open).
These candles provide a smoothed view of price trends, making it easier to identify trend direction and continuations.
Shadow Size Labels:
Upper Shadow Labels: Displayed above each candle at the Heikin Ashi high, showing the normalized upper shadow size (1–10). These labels are green with white text and use the label.style_label_down style for clear visibility.
Lower Shadow Labels: Displayed below each candle at the Heikin Ashi low, showing the normalized lower shadow size (1–10). These labels are red with white text and use the label.style_label_up style.
Labels are only shown for candles within the last two days from 9:00 AM, ensuring that only recent and relevant data is visualized.
Debugging Labels (Optional):
A blue label at the bottom of the chart displays the text "Upper: [value] Lower: [value]" for each candle, showing both shadow sizes for debugging purposes. This can be removed or commented out if not needed, as it is primarily for development use.
The visualizations are designed to be minimal and focused, ensuring that traders can quickly interpret the Heikin Ashi trend and shadow size metrics without unnecessary clutter. The use of color-coded candles and labels enhances readability, while the time-based filtering keeps the chart clean and relevant.
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.