wugamlo

MACD including 6-period Forecast and Divergences

█ OVERVIEW

This is my personal interpretation of the classic MACD Indicator. I am using the MACD as part of my analysis, and often I was wondering when I can expect the next signal (e.g. a Histogram cross). As I had come across some EMA forecast logics on tradingview, my goal was to use the EMA forecast calculation as basis to come to a complete MACD forecast. Here is the result.

Starting point is the classic MACD which is then plotted with MACD-Line, Signal Line and Histogram. In addition to the classic MACD, a 6 period Forecast for MACD, Signal and Histogram is available and divergences can be displayed on either the Histogram or the MACD Line.

Important:
As I am considering the closing price of the current candle as the basis for the calculation, the forecast values will REPAINT. But in my opinion this is fine as this indicator will not provide direct trading signals, but more an outlook into a potential future.


█ CALCULATION LOGIC

Below some details regarding the additional functionalities:

MACD Forecast:

The MACD Forecast is mainly based on a combination of EMA Forecasts. The inspiration for this basic forecast calculation is taken from the below tradingview members:
--> EMA Forecast input taken from "Triple MA Forecast" by yatrader2
--> Forecast Bias input taken from "Fancy Bollinger Bands" by BigBitsIO

When showing the forecast, the following options are available:
- Forecast Type: Determines if the Forecast is assuming a Flat price (last values of the MA calculation are replaced by current value) or if a Linear Regression is taken
- Number of candles taken for Linear Regression Calculation
- Bias of Forecast (Based on the recent Average True Range, the forecast values are either more bullish or more bearish calculated. "Neutral" turns off this function)
- Number of ATR Periods used to calculate Bias adjustment value
- Possibility to weight the Bias via a Multiplier - Default value is 1

Based on the above inputs, the forecasted values for MACD, Signal Line and Histogram are calculated and plotted for the next 6 periods.


Divergence Detection:

Based on the default tradingview divergence script with some adjustments:
- User can select to use either Histogram or MACD Line as basis for Divergence detection (Histogram by default)
- User can select if Divergence detection should be based on the candles including Wicks or only the Candle Bodies (Wicks by default)


█ DISCLAIMER

This is an experimental indicator and I do not know if my theory works in real life. So treat this not as financial advise, but purely for entertainment and educational purposes.
I publish this code open so that everyone can re-use it or hopefully even improve it.


Let me know if you have any ideas for improvement and if it is within my coding capabilities (which to be honest are quite limited), I will try to accomodate it.

Have fun.

오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?