jorgelg93

MACDh with divergences & impulse system (overlayed on prices)

-----------------------------------------------------------------
General Description:

This indicator (the one on the top panel above) consists on some lines, arrows and labels drawn over the price bars/candles indicating the detection of regular divergences between price and the classic MACD histogram (shown on the low panel). This script is special because it can be adjusted to fit several criteria when trading divergences filtering them according to the "height" and "width" of the patterns. The script also includes the "extra features" Impulse System and Keltner Channels, which you will hardly find anywhere else in similar classic MACD histogram divergence indicators.

The indicator helps to find trend reversals, and it works on any market, any instrument, any timeframe, and any market condition (except against really strong trends that do not show any other sign of reversion yet).

Please take on consideration that divergences should be taken with caution.


-----------------------------------------------------------------
Definition of classic Bullish and Bearish divergences:

*Bearish divergences occur in uptrends identifying market tops. A classical or regular bearish divergence occurs when prices reach a new high and then pull back, with an oscillator (MACD histogram in this case) dropping below its zero line. Prices stabilize and rally to a higher high, but the oscillator reaches a lower peak than it did on a previous rally.

In the chart above (weekly charts of NKE, Nike, Inc.), in area X (around August 2021), NKE rallied to a new bull market high and MACD-Histogram rallied with it, rising above its previous peak and showing that bulls were extremely strong. In area Y, MACD-H fell below its centerline and at the same time prices punched below the zone between the two moving averages. In area Z, NKE rallied to a new bull market high, but the rally of MACD-H was feeble, reflecting the bulls’ weakness. Its downtick from peak Z completed a bearish divergence, giving a strong sell signal and auguring a nasty bear market.

*Bullish divergences, in the other hand, occur towards the ends of downtrends identifying market bottoms. A classical (also called regular) bullish divergence occurs when prices and an oscillator (MACD histogram in this case) both fall to a new low, rally, with the oscillator rising above its zero line, then both fall again. This time, prices drop to a lower low, but the oscillator traces a higher bottom than during its previous decline.

In the example in the chart above (weekly charts of NKE, Nike, Inc.), you see a bearish divergence that signaled the October 2022 bear market bottom, giving a strong buy signal right near the lows. In area A, NKE (weekly charts) appeared in a free fall. The record low A of MACD-H indicated that bears were extremely strong. In area B, MACD-H rallied above its centerline. Notice the brief rally of prices at that moment. In area C, NKE slid to a new bear market low, but MACD-H traced a much more shallow low. Its uptick completed a bullish divergence, giving a strong buy signal.


-----------------------------------------------------------------
Some cool features included in this indicator:

1. This indicator also includes the “Impulse System”. The Impulse System is based on two indicators, a 13-day exponential moving average and the MACD-Histogram, and identifies inflection points where a trend speeds up or slows down. The moving average identifies the trend, while the MACD-Histogram measures momentum. This unique indicator combination is color coded into the price bars for easy reference.

Calculation:
Green Price Bar: (13-period EMA > previous 13-period EMA) and
(MACD-Histogram > previous period's MACD-Histogram)

Red Price Bar: (13-period EMA < previous 13-period EMA) and
(MACD-Histogram < previous period's MACD-Histogram)

Price bars are colored blue when conditions for a Red Price Bar or Green Price Bar are not met. The MACD-Histogram is based on MACD(12,26,9).

The Impulse System works more like a censorship system. Green price bars show that the bulls are in control of both trend and momentum as both the 13-day EMA and MACD-Histogram are rising (you don't have permission to sell). A red price bar indicates that the bears have taken control because the 13-day EMA and MACD Histogram are falling (you don't have permission to buy). A blue price bar indicates mixed technical signals, with neither buying nor selling pressure predominating (either both buying or selling are permitted).

2. Another "extra feature" included here is the "Keltner Channels". Keltner Channels are volatility-based envelopes set above and below an exponential moving average.

3. It were also included a couple of EMAs.

Everything can be removed from the chart any time.


-----------------------------------------------------------------
Options/adjustments for this indicator:

*Horizontal Distance (width) between two tops/bottoms criteria.
Refers to the horizontal distance between the MACH histogram peaks involved in the divergence

*Height of tops/bottoms criteria (for Histogram).
Refers to the difference/relation/vertical distance between the MACH HISTOGRAM peaks involved in the divergence: 1st Histogram Peak is X times the 2nd.

*Height/Vertical deviation of tops/bottoms criteria (for Price).
Deviation refers to the difference/relation/vertical distance between the PRICE peaks involved in the divergence.

*Plot Regular Bullish Divergences?.

*Plot Regular Bearish Divergences?.

*Delete Previous Cancelled Divergences?.

*Shows a pair of EMAs.

*Shows Keltner Channels (using ATR)
Keltner Channels are volatility-based envelopes set above and below an exponential moving average.

*This indicator also has the option to show the Impulse System over the price bars/candles.



オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。

チャートでこのスクリプトを利用したいですか?