// Description: Welcome to the "Bars since EMA touch" indicator, designed and developed by StockJustice. This script provides a unique approach to analyzing price movements relative to the Exponential Moving Average (EMA). It offers valuable insights into trend strength and trend duration, allowing traders to make informed decisions.
// How it Works: The indicator calculates the EMA based on the chosen length, which is customizable through the input settings. Additionally, it calculates the MACD (Moving Average Convergence Divergence) and its signal line to further enhance the analysis.
The script tracks the number of bars since the price touches or crosses the EMA. It provides a histogram plot that represents this count. Positive values indicate bars since the price crossed above the EMA, while negative values indicate bars since the price crossed below the EMA.
The color of the histogram bars adjusts dynamically based on the relationship between the current close price and the EMA. If the close is above the EMA and the bars since EMA touch is greater than zero, the histogram will be colored red if the signal line is above the MACD. If the close is below the EMA and the bars since EMA touch is greater than zero, the histogram will be colored green if the signal line is below the MACD. Otherwise, the histogram bars will be colored blue or white, depending on the direction of the crossover.
The script also calculates percentiles for bullish and bearish trends. These percentiles indicate the proportion of trend durations that exceed a certain threshold, which is set at 20% by default. The percentile plots help identify significant trend durations and gauge their strength relative to the entire trend history.
// Usage: This indicator can be applied to various markets and timeframes, accommodating different trading strategies. It is suitable for both intraday and swing trading. Traders can use it in conjunction with other technical analysis tools to confirm trade entries, identify trend reversals, or determine potential price targets.
// Input Parameters:
Length of EMA: This parameter allows you to define the length of the Exponential Moving Average used in the calculations. The default value is 9, but feel free to adjust it according to your preferences and trading style.
// Notes on Uniqueness: The "Bars since EMA touch" indicator stands out from other published scripts due to its comprehensive analysis of trend durations, the use of MACD and its signal line, and the dynamic coloring of the histogram bars based on various conditions. The incorporation of percentiles provides further insights into trend strength. This unique combination of features makes the indicator a powerful tool for traders seeking a deeper understanding of price action.
// Relevance for Technical Analysis and Trading The "Bars since EMA touch" indicator can be utilized for various aspects of technical analysis, including trend continuation, trend reversal, and identifying potential entry and exit points. Here's how you can apply it in different scenarios:
Trend Continuation:
When the histogram bars show positive values (indicating bars since the price crossed above the EMA), it suggests the presence of an ongoing uptrend. Traders can use this information to confirm the strength of the prevailing trend. If the histogram bars remain positive and the trend continues to unfold, it signals a potential opportunity to stay in the trade or consider adding to existing positions.
Trend Reversal:
Conversely, when the histogram bars show negative values (indicating bars since the price crossed below the EMA), it indicates a potential trend reversal or the beginning of a downtrend. Traders can watch for the histogram bars to transition from positive to negative values, signaling a possible trend reversal. This information can be used as an early indication to exit long positions or consider initiating short positions.
Entry and Exit Points:
Traders can incorporate the "Bars since EMA touch" indicator with other technical analysis tools to identify optimal entry and exit points. For example, when the histogram bars are positive, indicating an ongoing uptrend, traders might consider entering long positions when the price retraces and touches the EMA. This strategy aims to capitalize on potential pullbacks within the overall upward trend.
Conversely, when the histogram bars are negative, indicating a potential downtrend, traders might wait for the price to rally and touch the EMA before considering short positions. This approach seeks to enter short positions during temporary bounces within the overall downward trend.
Confirmation with MACD:
The script also incorporates the MACD and its signal line. Traders can analyze the relationship between the MACD and the signal line to confirm trend signals provided by the histogram bars. When the MACD crosses above the signal line and the histogram bars are positive, it adds further strength to the bullish indication. Similarly, when the MACD crosses below the signal line and the histogram bars are negative, it reinforces the bearish signal.
Responsive Histogram Color Scheme:
The color change of the histogram in the "Bars since EMA touch" indicator is specifically designed to alert traders to potential trend weakness or a shift in market dynamics. When the histogram bars turn red (for uptrends) or green (for downtrends), it signifies a weakening trend as the price approaches or hovers around the EMA. This color change acts as a visual cue, indicating that the trend may be losing momentum or facing resistance. It prompts traders to exercise caution, reassess the market conditions, and consider adjusting their trading strategies accordingly, such as tightening stops, taking partial profits, or preparing for a potential trend reversal.
// Red and Green Horizontal Lines:
The plotted percentile values in the "Bars since EMA touch" indicator hold significant importance as they provide insights into the strength and duration of trends. The percentile lines represent the proportion of trend durations that exceed a certain threshold, which is set at 20% by default.
The "Bull 15% Percentile" plot indicates the percentage of bullish trends that have lasted longer than 20% of the entire trend history. A higher value suggests that a significant portion of bullish trends has surpassed the threshold, indicating the presence of relatively strong and sustained uptrends.
On the other hand, the "Bear 15% Percentile" plot represents the percentage of bearish trends that have persisted beyond 20% of the total bearish trend history. A higher value suggests that a notable proportion of bearish trends has extended beyond the threshold, signifying the presence of pronounced and enduring downtrends.
These percentile lines serve as valuable reference points for traders, as they highlight significant trend durations compared to the overall trend history. They offer insights into the relative strength and duration of the prevailing trends, enabling traders to assess the potential continuation or reversal of the current trend. Additionally, observing changes in the percentile values over time can provide further indications of shifts in market dynamics and trend strength.
By incorporating these percentile lines into their analysis, traders can gain a better understanding of the market's trend characteristics and make more informed trading decisions.
Remember, as with any technical analysis tool, it's essential to consider other factors such as support and resistance levels, volume patterns, and broader market conditions to increase the accuracy of your trading decisions. It's recommended to backtest and validate the indicator's performance before using it in live trading.
NOTE: The 9ema is plotted on the chart simply to visually show how, once contact is made, the histogram stops plotting new bars. This visualization is needed to confirm how the script works.
Skrip ini diterbitkan secara sumber tertutup dan anda boleh menggunakannya dengan bebas. Anda boleh menyukainya untuk menggunakannya pada carta. Anda tidak dapat melihat atau mengubah kod sumbernya.
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.