The most popular indicator used in , the moving average convergence divergence ( ), created by Gerald Appel. is a trend-following , designed to reveal changes in the strength, direction, momentum, and duration of a trend in a financial instrument’s price
Historical evolution of ,
- Gerald Appel created the line,
- Thomas Aspray added the histogram feature to
- Giorgos E. Siligardos created a leader of
employs two Moving Averages of varying lengths (which are lagging indicators) to identify trend direction and duration. Then, takes the difference in values between those two Moving Averages ( Line) and an of those Moving Averages (Signal Line) and plots that difference between the two lines as a histogram which oscillates above and below a center Zero Line. The histogram is used as a good indication of a security's momentum.
Mathematically expressed as;
= ma(source, fast_length) – ma(source, slow_length)
signal = ma( , signal_length)
histogram = – signal
where ( ) is in common use as a moving average (ma)
fast_length = 12
slow_length = 26
signal_length = 9
The indicator is typically good for identifying three types of basic signals;
Signal Line Crossovers
A Signal Line Crossover is the most common signal produced by the . On the occasions where the Line crosses above or below the Signal Line, that can signify a potentially strong move. The standard interpretation of such an event is a recommendation to buy if the line crosses up through the Signal Line (a "bullish" crossover), or to sell if it crosses down through the Signal Line (a "bearish" crossover). These events are taken as indications that the trend in the financial instrument is about to accelerate in the direction of the crossover.
Zero Line Crossovers
Zero Line Crossovers occur when the Line crossed the Zero Line and either becomes positive (above 0) or negative (below 0). A change from positive to negative is interpreted as "bearish", and from negative to positive as "bullish". Zero crossovers provide evidence of a change in the direction of a trend but less confirmation of its momentum than a signal line crossover
Divergence is another signal created by the . Simply, divergence occurs when the and actual price are not in agreement. A "positive divergence" or "bullish divergence" occurs when the price makes a new low but the does not confirm with a new low of its own. A "negative divergence" or "bearish divergence" occurs when the price makes a new high but the does not confirm with a new high of its own. A divergence with respect to price may occur on the line and/or the Histogram
Moving Average Crossovers, another hidden signal that Indicator identifies
Many traders will watch for a short-term moving average to cross above a longer-term moving average and use this to signal increasing upward momentum. This crossover suggests that the price has recently been rising at a faster rate than it has in the past, so it is a common technical buy sign. Conversely, a short-term moving average crossing below a longer-term average is used to illustrate that the asset's price has been moving downward at a faster rate and that it may be a good time to sell.
Moving Average Crossovers in reality is Zero Line Crossovers, the value of the indicator is equal to zero each time the two moving averages cross over each other. For easy interpretation by trades, Zero Line Crossovers are simply described as positive or negative
Like any forecasting algorithm, the can generate false signals. A false positive, for example, would be a crossover followed by a sudden decline in a financial instrument. A false negative would be a situation where there is crossover, yet the financial instrument accelerated suddenly upwards
What is “MACD-X” and Why it is “More Than MACD”
In its simples form, MACD-X implements variety of different calculation techniques applied to obtain Line, ability to use of variety of different sources, including related sources, and can be plotted along with in the same window and all those features are available and presented within a single indicator, MACD-X
Different calculation techniques lead to different values for Line, as will further discuss below, and as a consequence the signal line and the histogram values will differentiate accordingly. Mathematical calculation of both signal line and the histogram remain the same.
Main features of MACD-X ;
1- Introduces different proven techniques applied on calculation, such as MACD-Histogram, MACD-Leader and MACD-Source, besides the traditional (MACD-TRADITIONAL)
• MACD-Traditional, by Gerald Appel
It is the that we know, stated as traditional just to avoid confusion with other techniques used with this study
• MACD-Histogram, by Thomas Aspray
The MACD-Histogram measures the distance between and its signal line (the 9-day of ). Aspray developed the MACD-Histogram to anticipate signal line crossovers in . Because uses moving averages and moving averages lag price, signal line crossovers can come late and affect the reward-to-risk ratio of a trade. or divergences in the MACD-Histogram can alert chartists to an imminent signal line crossover in
The MACD-Histogram represents the difference between and its 9-day , the signal line. Mathematically,
macdx = - ma( , signal_length)
Aspray's contribution served as a way to anticipate (and therefore cut down on lag) possible crossovers which are a fundamental part of the indicator.
Here come a question, what if repeat the same calculations once more (macdh2 = macdh - ma(macdh, signal_length), will it be even better, this question will remain to be tested
• MACD-Leader, by Giorgos E. Siligardos, PhD
Leader has the ability to lead at critical situations. Almost all smoothing methods encounter in are based on a relative-weighted sum of past prices, and the Leader is no exception. The concealed weights of Leader are such that more relative weight is used in the more recent prices than the respective weights used by the components of . In effect, the Leader expresses more changes in average price dynamics for the recent price movement than , thus eventually leading , especially when significant trend changes are about to take place.
Siligardos creates two less-laggard moving averages indicators in its formula using the same periods as follows
Indicator1 = ma(source, fast_length) + ma(source - ma(source, fast_length), fast_length)
Indicator2 = ma(source, slow_length) + ma(source - ma(source, slow_length), slow_length)
and then take the difference:
Indicator1 - Indicator2
The result is a new Leader indicator
macdx = + ma(source - fast_ma, fast_length) - ma(source - slow_ma, slow_length)
• MACD-Source, a custom experimental interpretation of mine,
Source, presents an application of that evaluates Source/MA Ratio, relatively with less lag, as a basis for Line, also can be expressed as source convergence/divergence to its moving average. Among the various techniques for removing the lag between price and moving average (MA) of the price, one in particular stands out: the addition to the moving average of a portion of the difference between the price and MA. Source, is based on signal length mean of the difference between Source and average value of shot length and long length moving average of the source (Source/MA Ratio), where the source is actual value and hence no lag and relatively less lag with the average value of moving average of the source . Mathematically expressed as,
macdx = ma(source - avg ( ma(source, fast_length), ma(source, slow_length) ), signal_length)
Source provides relatively early crossovers comparing to and better momentum direction indications, assuming the lengths are set to same values
For further details, you are invited to check the following two studies, where the first seeds were sown of the MACD-Source idea
Price Distance to its Moving Averages study, adapts the idea of “Prices high above the moving average (MA) or low below it are likely to be remedied in the future by a reverse price movement", presented in an article by Denis Alajbeg, Zoran Bubas and Dina Vasic published in International Journal of Economics, Commerce and Management
First like interpretation comes with the second study named as “P-MACD”, where P stands for price, P-MACD study attempts to display relationship between Price and its 20 and 200-period moving average. Calculations with P-MACD were based on price distance (convergence/divergence) to its 200-period moving average, and moving average convergence/divergence of 20-period moving average to 200-period moving average of price.
Now as explained above, Source is a one adapted with traditional , where Source stands for Price, Indicator etc, any source applicable with concept
2- Allows usage of variety of different sources, including related indicators
The most common usage of Source for calculation is close value of the financial instruments price. As an experimental approach, this study will allow source to be selected as one of the following series;
• Current Close Price (close)
• Average of High, Low, and Close Price (hlc3)
-Current Close Price and Average of High, Low, and Close Price are price actions of the financial instrument
-Accumulation Distribution is a based indicator designed to measure underlying
-On Balance (OBV), is a that measures positive and negative flow
-Price Trend (PVT) is a momentum based indicator used to measure
3- Can be plotted along with in the same window using the same scaling
Default setting of MACD-X will display MACD-Source with Current Close Price as a source and traditional can be plotted eighter as a companion of MACD-X or can be selected to be plotted alone.
Applying both will add ability to compare, or use as a confirmation of one other
In case, traditional Is plotted along with MACD-X to avoid misinterpreting, the lines plotted, the area between MACD-X Line and Signal-X Line is highlighted automatically, even if the highlight option not selected. Otherwise highlight will be applied only if that option selected
4- 4C Histogram
Histogram is plotted with four colors to emphasize the momentum and direction
Additional to ability of selecting Calculation Method, Source, plotting along with , there are few other option that allows users to customize the MACD-X indicator
Lengths are configurable, default values are set as 12, 26, 9 respectively for fast, slow and smoothing length. Setting lengths to 8,21,5 respectively Is worth checking, slower length moving averages will lead to less lag and earlier reaction to price actions but yet requires a caution and back testing before applying
Highlight the area between MACD-X Line and Signal-X Line, with colors emphasising the direction
Label can be added to display Calculation Method, Source and Length settings, the aim of this label is to server only as a reminder to trades to be aware of settings while they are occupied with charts, analysis etc.
Here comes another question, which is of more importance having the reminder or having the indicators with feature? Build-in features of Pine is not supported when labels and lines introduced in the script, there are other methods but brings complexity. To be studied further, this version will be with labels for time being.
MACD-X is an alternative variant of , the insight/signals provided by are also applicable to MACD-X with early and clear warnings for the changes in the trend.
If is essential to your analysis, then it is my guess that after using the MACD-X for a while and familiarizing yourself with its unique character and personality, you will make it an inseparable companion to other indicators in your charts.
The various signals generated by /MACD-X are easily interpreted and very few indicators in have proved to be more reliable than the , and this relatively simple indicator can quickly be incorporated into any short-term trading strategy
the easiest way to make it MTF is to change the study line and make it as shown below
study("MACD-X, More Than MACD by DGT", shorttitle="MACD-X by DGT", resolution="")
but this approach is not supported with Pine when lables, lines are introduced in the study, so you will need to simply disable lable plottings
//dispLabel = input(false,"Display Label")
//macdText = "Method : " + macdType + "\nSource : " + sourceType
//rsiText = colorRsi ? rsiValue > rsiOverBought ? "\nRSI : in OverBought Zone" : rsiValue < rsiOverSold ? "\nRSI : in OverSold Zone" : "\nRSI : Value " + tostring(round(rsiValue)) : na
//sqzText = dispSqueeze ? inSqz or unSqz ? "\nSQZ (src=close) : No Trade Recommended" : histx >= 0 ? "\nSQZ (src=close) : Buy Posibility" : "\nSQZ (src=close) : Sell Posibility" : na
// label macdLabel = label.new(bar_index, 0, text=macdText + rsiText + sqzText
// ,tooltip="evaluation given herein does not constitute professional and/or financial advice"
// ,color=#0094ff, style=label.style_label_left, textcolor=color.white, textalign=text.align_left)
there are other ways to benefit from MTF and Lables but have not tested them. I will try to do so when i have more convnient time
hope all the above helps
lables are not allowed when resolution argument (ability to use mtf version) included in the study fucntion. the above suggestion was made before i updated with backtest ability and backtest part of the study have lables too.
so to made this available mtf besides the above suggestions we need to remove/disable all backtest part of the code. if you still would like to proceed you need to remove all lines from line 214 till the end besides the above suggestions
if you ment MACD-X study, they are the statistical results to the trades simulated by the backtest framework
yes, simulation starts with 1.000 units (default value) and simulates the trades each time with the entire portfolio (both entres and exits)
and thanks a lot for the feedback with your observations 🙏