MACD Four Color Histogram with Alerts MT4
- 지표
- 버전: 1.1
A MetaTrader 4 MACD built to read like the MACD you see on TradingView: a MACD line, a signal line, and a histogram of the gap between them, colored in four shades. If you switch between the two platforms during the day, the MACD pane on your MT4 chart will look and behave the way you are used to.
WHY NOT THE MT4 BUILT-IN MACD?
MT4's own MACD draws the MACD line as gray bars and smooths the signal line with an SMA. There is no separate histogram and no color change. This indicator calculates the three parts the TradingView way (EMA seeded with an SMA, histogram = MACD minus signal) and colors every histogram bar.
READING THE FOUR COLORS (default colors)
- Dark green: histogram above zero and larger than on the previous bar
- Light green: histogram above zero and smaller than on the previous bar
- Light red: histogram below zero and higher than on the previous bar
- Dark red: histogram below zero and lower than on the previous bar
Blue = MACD line, orange = signal line, gray dashed line = zero.
CHANGING COLORS ON MT4 - PLEASE READ
Change colors in the Inputs tab (the color inputs listed under Inputs below). Changes made in MT4's Colors tab are not applied: the indicator sets its colors from the Inputs every time it loads. To hide the zero line, set "Zero line" to None (clrNONE).
INPUTS (in the order shown in the Inputs tab; MT4 shows them without group headings)
- Fast length = 12, Slow length = 26, Signal smoothing = 9 (each 1 to 1000)
- Source = close (also open, high, low, hl2, hlc3, ohlc4, hlcc4)
- Oscillator MA type = EMA, Signal line MA type = EMA (EMA or SMA, set separately)
- Histogram colors (4), MACD line, Signal line, Zero line
- Alert: MACD crosses signal line = false
- Alert: MACD line crosses zero = false
- Alert by pop-up = true, Alert by sound = false, Alert by push notification = false
- Alert language = Auto (terminal language), or English / Japanese
If an input is out of range (for example a length of 0 or above 1000), the indicator stops loading and writes the reason to the Experts log instead of drawing wrong values.
ALERTS
Both alert types are off until you switch them on.
- MACD / signal cross: raised when the histogram changes from negative to positive or from positive to negative.
- MACD zero cross: raised when the MACD line moves to the other side of zero.
- Judged on the closed bar only, at most once per bar.
- Bars that closed before the indicator was loaded never trigger an alert, so adding it to a chart or restarting MT4 does not produce a burst of old alerts.
- Pop-up, sound and push can be combined. Push needs your MetaQuotes ID in the terminal options.
- The alert text is in Japanese or English and follows the terminal language automatically.
An alert tells you that a condition on the indicator occurred. It is not advice to buy or sell.
TESTS ON MT4
- Values against an independent reference calculation of the TradingView MACD formula: largest difference 7.4e-13 (floating-point rounding).
- Histogram colors: 0 mismatches in 33 test cases, including W1 and MN1 charts.
- Speed: about 50 ms for the first calculation on 65,000 M1 bars in our test. Your PC may differ.
- Closed bars do not repaint. The bar that is still forming keeps changing until it closes, as with any MACD.
Note: price data is not the same at every data feed, so the numbers on your chart can differ slightly from a TradingView chart or another MT4 terminal. The formula is the same; the prices may not be. The EMA also depends on where your chart history begins; after a few hundred bars this hardly matters.
FOR EA AND iCUSTOM USERS
MT4 has no multi-color histogram, so the four colors are drawn by four histogram buffers, and each bar has a value in only one of them.
- 0 = histogram value (all bars, not drawn)
- 1 = dark green, 2 = light green, 3 = light red, 4 = dark red (value only on bars of that color, otherwise EMPTY_VALUE)
- 5 = MACD line, 6 = signal line
The Data Window shows only Histogram, MACD and Signal.
LIMITS
- Analysis tool only: it does not open, close or manage trades, and it does not guarantee any result.
- Uses no DLLs, no external files and no internet connection. It draws no chart objects.
- Inside the Strategy Tester it raises no alerts.
SUPPORT
Questions about installing, settings and bugs are welcome through MQL5 messages. Questions about market direction or about individual trades are outside the support scope.
This tool belongs to a series that brings TradingView-style indicators to MetaTrader. Other titles include RSI AutoScale with Zone Fills MT4 and Stoch RSI Band Fill with Cross Alerts. Please see my seller profile for the full list.
TradingView is a trademark of TradingView, Inc. This product is not affiliated with, sponsored by or endorsed by TradingView, Inc.
