Stoch RSI Band Fill with Cross 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.3
MetaTrader 4 ships with a Stochastic and an RSI, but not with a Stochastic RSI. This indicator fills that gap for MT4 users and is built to be TV-compatible: it follows the calculation of the Stoch RSI that comes with TradingView, and the pane looks the way TradingView users expect - a blue K line, an orange D line, dashed 80 and 20 levels, a dotted 50 line and a light band between 80 and 20.
WHAT APPEARS IN THE SUBWINDOW
- K and D lines. The Data Window lists only K and D.
- Upper band (80) and lower band (20) as dashed lines, middle line (50) as a dotted line. They are drawn as MT4 indicator levels, so they reach the right edge and their values show on the scale. Each can be hidden.
- A filled band between the upper and lower levels, drawn behind the lines. It can continue into the empty right margin of the chart (100 bars by default).
- Scale: Fixed 0-100 (default), Auto (MT4 autoscale), or Auto clamped to 0-100, which fits the K and D values you can see and is refitted when you scroll or zoom.
INPUTS (MT4 lists them in this order, without group headings)
- K = 3, D = 3, RSI Length = 14, Stochastic Length = 14 (each 1 to 1000)
- RSI Source = close (open, high, low, hl2, hlc3, ohlc4, hlcc4 are also available)
- Upper Band = 80, Lower Band = 20 (0 <= Lower < Upper <= 100)
- Show upper/lower band lines = true, Show middle line (50) = true, Show background fill = true
- Extend fill to the right = 100 bars (0 to 5000; 0 = no extension)
- K line, D line, Band / middle lines, Background fill color
- Background fill opacity % = 10 (1 to 100)
- Scale mode = Fixed 0-100
- Alert: K crosses D = false
- Alert: K crosses above upper / below lower band = false
- Alert by pop-up = true, Alert by sound = false, Alert by push notification = false
- Alert language = Auto (terminal language), English or Japanese
If a value is out of range, the indicator does not load and writes the reason to the Experts log.
MT4 SETUP NOTES - PLEASE READ
1. Colors. The colors of the K and D lines come from the inputs "K line" and "D line". A color chosen in MT4's Colors tab is replaced by the input color when the indicator loads. Line width and line style, however, are taken from the Colors tab. The level values and the level color also come from the inputs.
2. One per subwindow. MT4 has no built-in way to fill between two levels, so the band is a rectangle object placed in the background of the subwindow. Use one copy per subwindow. If you put two copies in the same subwindow, give both the same Upper Band and Lower Band. Do not share the subwindow with another indicator: the band will not line up with that window's scale.
3. Switching from Fixed to Auto. After changing Scale mode from Fixed 0-100 to one of the Auto modes, open the indicator properties and clear the Fixed minimum and Fixed maximum check boxes. Otherwise MT4 may keep the 0-100 range.
4. Fill strength. MT4 cannot draw semi-transparent areas, so the fill color is mixed with the chart background at the opacity you set. 10% suits a white chart. On a black chart, 20 to 30% is easier to see. If you change the chart background, the fill follows it.
ALERTS
- Two conditions, both off by default: K crosses D (up or down), and K crosses above the upper band or below the lower band.
- Checked only on the bar that has just closed, once per bar.
- Bars that had already closed before the indicator was loaded do not raise alerts, so attaching it or restarting MT4 does not produce old alerts.
- Pop-up, sound and push can be combined. Push needs your MetaQuotes ID in the terminal options.
- An alert only reports that a line crossed. It is not a buy or sell recommendation.
HOW THE NUMBERS ARE MADE
RSI with Wilder smoothing (RMA, first value = simple average of the first changes), then the stochastic of that RSI over the Stochastic Length, then K = SMA of it and D = SMA of K. When the RSI range in the window is zero, the previous value is carried forward, as TradingView does. In our tests on MT4 the output matched an independent reference calculation of this formula on every bar, apart from floating-point rounding.
Values on your chart can still differ slightly from a TradingView chart or from another MT4 terminal, because each data feed delivers slightly different prices. The RSI smoothing also depends on where your chart history starts; after a few hundred bars this hardly matters.
FOR EA AND iCUSTOM USERS
- Buffer 0 = K, buffer 1 = D.
- Buffer 2 = upper band, buffer 3 = lower band. These two hold values only while the fill is on (they keep the band inside the autoscale range); otherwise EMPTY_VALUE.
- Bars without a value return EMPTY_VALUE.
Note that the buffer numbers are not the same as in the MT5 edition.
LIMITATIONS
- Closed bars are not redrawn. The current bar moves until it closes.
- Stoch RSI is a fast oscillator. In a strong trend K and D can stay near 0 or 100 for a long time, and in a quiet market a small price move can swing them from one side to the other. Being above 80 or below 20 does not mean that price will turn.
- With a length at the maximum of 1000, the first calculation on a long M1 history can take a few seconds (about 4 seconds for 65,000 M1 bars in our test; your PC may differ). Shorter lengths load faster.
- In the Strategy Tester it raises no alerts and draws no objects.
- No DLLs, no external files, no internet connection.
- A charting aid only: it places no orders and does not guarantee any trading result.
SUPPORT
Installation, settings and bug reports are handled through MQL5 messages. Questions about where the market is going or about individual trades are outside the support scope.
There is also an MT5 edition, Stoch RSI Band Fill with Cross Alerts, and other MT4 tools in the same style such as RSI AutoScale with Zone Fills MT4 and MACD Four Color Histogram with Alerts MT4. Please see my seller profile.
TradingView is a trademark of TradingView, Inc. This product is not affiliated with, sponsored by or endorsed by TradingView, Inc.
