Supertrend Trend Fill with Change Alerts MT4
- Indicators
-
Kazuma Uezono
MQL5 / MQL4 / Pine Script v6 developer and active trader.
Seller on the MQL5 Market (indicators for MT4/MT5).
Services:
- TradingView Pine Script to MT5/MT4 conversion (bar-by-bar matching, with tester report)
- MT4 to MT5 migration - Version: 1.2
Supertrend Trend Fill with Change Alerts MT4 brings a TV-compatible Supertrend to MetaTrader 4. If you also use TradingView, you know its built-in "Supertrend": a green line under price while the trend is up, a red line over price while it is down, and a soft colored band between the line and the candles. This MT4 indicator reproduces that calculation and that look.
What it is for: seeing the current trend direction and where it would flip. What it is not: a buy or sell signal or a forecast. A trend change on the chart says nothing about what price will do next.
THE CALCULATION IN SHORT
Setting | Default | Same as TradingView?
ATR Length | 10 | yes
Factor | 3.0 | yes
ATR method | RMA (Wilder) | yes (SMA is an extra option)
Source | hl2 = (H + L) / 2 | yes (close, hlc3, ohlc4 are extra options)
Bands: source +/- Factor x ATR. The lower band can only rise during an up trend and the upper band can only fall during a down trend. A close above the upper band turns the trend up; a close below the lower band turns it down. The extra options (SMA, other sources) are not in TradingView's built-in version, so with them the values will not match TradingView.
DOES IT REPAINT?
Closed bars: no. Their line and direction are final.
The forming bar: yes, in the same way as on TradingView. It is recalculated on every tick, so its color can still change before the bar closes. Alerts therefore look only at closed bars.
MT4 SETUP NOTES - PLEASE READ
1. Colors come from the inputs. Set "Up Trend line color" and "Down Trend line color" in the Inputs tab; the Colors tab is overridden by these inputs.
2. The fill is drawn with histogram bars whose width follows the chart zoom (MT4 has no area fill). At some zoom levels you may see thin gaps in the fill. The fill color is the line color mixed with the chart background (Fill opacity %, 1-100).
3. Candles on top: with the fill on, the indicator switches on "Chart on foreground" so the candles stay visible. Removing the last copy restores your original setting (if another tool by the same author that uses this setting is still on the chart, it is restored when the last of them is removed).
4. Right after loading (up to about 15 seconds), the name in the indicator list can briefly read "probe#..." while it checks that it is attached to a chart. This is normal.
5. MT4 shows the inputs without group headings, in the order listed below.
ALERTS
Off by default. With "Alert: trend direction changed" = true:
- one alert when a bar closes with a different direction than the bar before it;
- never for bars that closed before the indicator was loaded, so a restart does not repeat old alerts;
- text example: "Supertrend TV GBPUSD H1: trend changed to DOWN (1.27450)";
- pop-up, sound and push (MetaQuotes ID required) can be combined; English or Japanese text (Language input).
- No alerts in the Strategy Tester.
COMPARED WITH TRADINGVIEW
We checked the formula on TradingView's own EURUSD 1h prices: the same direction as TradingView's built-in Supertrend on 280 of 280 bars. Your MT4 chart uses your broker's prices, which differ slightly from TradingView's feed. In our EURUSD H1 comparison the direction was the same on 199 of 200 bars and the line was 1.3 pips apart on average; a trend change can appear one bar earlier or later because of such small price differences.
iCUSTOM BUFFERS
Buffer 0: Supertrend line value. Buffer 1: direction, +1 up / -1 down. The sign is reversed compared with the "direction" value in TradingView's Pine Script, where -1 means up. EMPTY_VALUE where there is no value.
Called through iCustom, the indicator draws nothing on the chart and sends no alerts; it only fills the buffers. The inputs have no group headings, so pass the inputs in the order below.
INPUTS (MT4 ORDER)
ATR Length = 10 (1-1000); Factor = 3.0 (0.01-100); ATR calculation method = RMA; Source of the bands = hl2; Up Trend line color = #4CAF50; Down Trend line color = #FF5252; Line width = 2 (1-5); Show background fill = true; Fill opacity % = 10 (1-100); Draw price bars above the fill = true; Show trend-change markers = false; Marker size = 1 (1-5); Alert: trend direction changed = false; Alert by pop-up = true; Alert by sound = false; Alert by push notification = false; Language = Auto (terminal language), English or Japanese.
Out-of-range values stop the indicator from loading, with the reason in the Experts log.
GOOD TO KNOW
- No DLLs, no files, no internet access.
- This is an analysis tool. It does not open or close trades, and no trading result is promised.
SUPPORT
Help with installation, settings and bug reports via MQL5 messages. I do not answer questions about market direction or specific trades.
The MT5 edition (a separate product) and other tools by the same author are listed on my seller profile.
TradingView is a trademark of TradingView, Inc. This product is not affiliated with, sponsored by or endorsed by TradingView, Inc.
