TradingView
wugamlo
2021年2月3日午前2時46分

MACD including 6-period Forecast and Divergences 

Bitcoin / U.S. dollarBitstamp

詳細

█ 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.
コメント
NextdoorLaoWang
Hi, thank you for your indicator. I am a fresher and not a programmer so I don't understand the codes. I want to add an alert that it will notice me once a bullish or bearish divergence appears. Can you tell me how to set the alert? In the alert settings, there are 2 "regular bullish", which one should I use? and which action should I chose? crossing? less than? moving up ??
Kao_5MIN
Hi , awesome indicator ! 🏌🏼‍♂️ What mean the gray zone ?
bullmastercapital
para mi uno de los mejores indicadores
ER_OL
@bullmastercapital, Can you tell us about the time period and how you use this indicator? How do you trade with this indicator in futures trading? tanks
NetoDav
thanks mate. could it be possible to add both the histogram and ma divergences at the same time.
mtuser
Could​ you​ please​ add​ Alert​ for​ divergence?
mixmax911
Super good .. would love it for multi time frame, and for dark and bright background.. thnx a lot great job
Astarlight
like u
PumpyDumpy
One of my favs. Thanks
Gunslinger2005
this is great
詳細