Machine Learning RSI (MLRSI): A KNN-Enhanced RSI Guide
How Sahi's Machine Learning RSI blends a standard RSI with a KNN prediction and smoothing filters, and how to trade its signals.
Quick Answer
Machine Learning RSI (MLRSI) starts from a standard RSI and blends in a K-Nearest Neighbours (KNN) prediction, so it reacts less to noise while still catching real momentum shifts. The line runs 0–100 in its own pane: above 50 is bullish (buyers in control) and below 50 is bearish. Trade the line crossing 50 after an oversold or overbought recovery, and use the status table's "Detected" row as confirmation. It is free on Sahi, with no subscription required.
Overview
Machine Learning RSI is a momentum oscillator that starts from a standard RSI and then blends in a K-Nearest Neighbours (KNN) prediction. Each bar, the indicator looks back over a historical window, finds the K past RSI states that most closely resemble the current one (using momentum, volatility, and slope as matching features), and weights their outcomes to produce a "smarter" RSI reading. An optional post-processing filter — Kalman, Double EMA, or ALMA — further smooths the result before it is drawn. The net effect is an RSI that reacts less to random noise while still catching real momentum shifts.
On the Sahi chart it draws a single coloured line in a separate pane, a faint 50 midline, gradient-filled overbought and oversold zones, and a small status table in the top-right corner. The main line and the price chart's bar colours both change to reflect the current trend or impulse state.
How to Read the Indicator
The RSI Line
The main line plots the final processed RSI value — after optional MA smoothing, KNN blending, and advanced filtering are all applied. The line moves between 0 and 100.
- Colour above 50: bull colour (default: neon teal #00FFBB). Momentum is net positive — buyers are in control.
- Colour below 50: bear colour (default: neon red #FF1100). Momentum is net negative — sellers are in control.
- The line is drawn at weight 3, so it is clearly visible even with the gradient fill beneath it.
The exact colour used depends on the Coloring Mode and Color Palette settings (see Settings Panel Guide). When Coloring Mode is set to "None", the line has no fill colour.
The 50 Midline
A thin, faded white horizontal line at level 50 marks the neutral midpoint. Use it as the primary trend divider: sustained readings above 50 = bullish bias; sustained readings below 50 = bearish bias. The gradient fill between the RSI line and this midline (visible when Neon Effect is on) amplifies the visual separation.
Gradient Fill Between the RSI Line and the Midline
When Neon Effect is enabled, a gradient fill appears between the RSI line and the 50 midline. When the RSI is above 50 the fill is bull-coloured (teal by default), fading toward the midline. When the RSI is below 50 the fill is bear-coloured (red by default), fading toward the midline. The fill is purely visual reinforcement — it carries no additional signal beyond what the line itself shows.
Overbought Zone (above the upper threshold)
A coloured band between the overbought level (default 70) and 100 is shaded in the bear colour. When the RSI line enters this zone the oscillator is signalling that the recent upswing is stretched. This is not an automatic sell signal — in a strong trend the RSI can stay overbought for many bars. Wait for the line to turn and exit the zone before acting.
Oversold Zone (below the lower threshold)
A coloured band between 0 and the oversold level (default 30) is shaded in the bull colour. When the RSI line enters this zone the oscillator is signalling that the recent downswing is stretched. Again, wait for the line to recover above the threshold rather than buying blindly into the zone.
Bar Colours on the Price Chart
The candles on the main price chart are also coloured by this indicator. Bars are tinted bull-colour when the RSI is above 50 and bear-colour when below 50, at 20% transparency. This lets you read momentum state directly on the price chart without switching panes. The colour follows the same bull/bear colours as the RSI line.
Status Table (top-right corner)
A small 2-column table overlays the top-right of the chart and updates every 10 bars. It shows:
- Mode — the active Coloring Mode setting ("Trend Following", "Impulse", or "None").
- Detected — the current market context: "Bullish Trend", "Bearish Trend", "Bullish Impulse", "Bearish Impulse", or "None".
- Machine Learning — "YES" if KNN enhancement is on; "NO" if it is off.
- OB/OS Thresholds — the active overbought and oversold levels, e.g. "70 / 30".
Use the "Detected" row as a quick confirmation that the indicator agrees with your reading of the line's position.
Example Scenarios
Scenario 1 — RSI crosses above 50 in an oversold recovery, buy a CE (bullish)
Nifty has been pulling back and MLRSI has been sitting in the oversold zone (below 30). The line bottoms out near 25, turns upward, crosses back above 30, and then crosses above 50 — the line colour switches from red to teal and the status table flips to "Bullish Trend." Price is around 24,830.
- What you do: buy 1 lot of Nifty 24,900 CE at a premium of about ₹105.
- Stop loss: if MLRSI turns back below 50 and price closes below 24,780, the recovery has failed — exit. The CE premium would be around ₹65 there.
- Target: the recent swing high near 25,050; CE premium roughly ₹160 there.
- Why it works: the cross above 50 after an oversold recovery is the indicator's cleanest bullish reset signal, backed by KNN-smoothed momentum confirmation.
Scenario 2 — RSI enters overbought zone and stalls, buy a PE (bearish)
Nifty has rallied and MLRSI is above 70 — inside the overbought band, status table reads "Bullish Impulse." The line then flattens and begins to slope down, crossing back below 70 while price is near 25,100. The line colour shifts from teal to red and the status table switches to "Bearish Trend."
- What you do: buy 1 lot of Nifty 25,000 PE at a premium of about ₹90.
- Stop loss: if MLRSI turns back above 70, the reversal has not materialised — exit. Premium roughly ₹58 there.
- Target: MLRSI falling back to the 50 level; price near 24,920; PE premium roughly ₹140.
- Why it works: the exit from the overbought zone on a weakening RSI slope is a high-quality exhaustion signal, and the KNN blend means it is less likely to be a one-bar spike.
Scenario 3 — What to avoid
- Do not act on a zone touch alone. The RSI entering the overbought or oversold band is context, not a trigger. Wait for the line to actually exit the zone (cross back through the threshold level) before treating it as a reversal signal.
- Do not ignore the 50-level trend filter. Shorting because the RSI touched 70 while the line is firmly above 50 and the table reads "Bullish Trend" puts you against the dominant momentum. Favour trades where the signal direction agrees with which side of 50 the RSI is on.
- Be cautious right after heavy news events. KNN looks back over a rolling window of recent bars. On a surprise macro event (RBI policy, US jobs data), the current RSI behavior will not closely match any historical neighbors — the KNN contribution becomes less reliable and the line can whipsaw. Widen your stop or sit out the first few bars until the RSI settles.
- Low-feature-count setups are noisier. If Number of Features is set to 1, the KNN matching uses only the RSI level itself, which misses momentum and volatility context. Signals generated with Features set to 1 or 2 are shallower than those with the default of 3.
Settings Panel Guide
RSI Base Settings
- RSI Length: the lookback period for the base RSI calculation. Default is 14. Shorter (e.g. 9–11) makes the RSI more reactive and suits fast intraday scalping on Nifty 5-min charts; longer (e.g. 20–21) suits swing reads on 15-min or hourly charts.
- Apply Moving Average: toggles a smoothing MA on top of the raw RSI before it is passed to the KNN. Default is on. Leave on unless you specifically want the raw, unsmoothed RSI as the KNN input.
- MA Length: the period of the smoothing MA applied to the base RSI. Default is 3. Increasing this softens the KNN input further; keep it short (2–5) for intraday use.
- Moving Average Type: which MA formula is used for that smoothing step. Default is ALMA. Options: SMA, EMA, DEMA, TEMA, WMA, VWMA, SMMA, HMA, LSMA, ALMA. ALMA is the least laggy of the adaptive options; EMA is a reliable simpler choice.
- ALMA Sigma: controls the sharpness of the ALMA bell curve. Default is 4. Only relevant when Moving Average Type is ALMA. Higher values (5–6) sharpen the peak; lower values (2–3) broaden it. Leave at 4 unless you are fine-tuning ALMA behavior specifically.
Threshold Settings
- Overbought Level: the upper boundary of the overbought zone. Default is 70. For BankNifty intraday (which trends hard), raising this to 75–80 reduces false reversal signals in strong trending periods.
- Oversold Level: the lower boundary of the oversold zone. Default is 30. Lowering to 25 on BankNifty for the same reason — let the oscillator stay extended longer before triggering.
KNN Machine Learning
- Enable KNN Machine Learning: master switch for the KNN blend. Default is on. Turn off to use the indicator as a smoothed RSI without any ML influence — useful for comparing results.
- K — Number of Neighbors: how many historical "similar" bars are averaged to produce the KNN prediction. Default is 5. Increasing to 7–10 produces a more stable but slower ML signal; decreasing to 3 makes it more reactive but noisier.
- Historical Period for KNN: how many bars back the algorithm searches for neighbors. Default is 100. Reducing to 50 focuses the ML on very recent market memory; increasing to 200 gives it a broader historical context. For intraday Nifty, 100 bars is a reasonable starting point.
- ML Weight vs Standard RSI: the blend ratio between the KNN prediction and the standard RSI. Default is 0.4 (40% KNN, 60% standard RSI). Raising toward 0.6–0.7 gives the ML layer more say; lowering toward 0.2 makes the final line closer to a standard RSI. Start at the default before experimenting.
- Number of Features: how many characteristics are used when finding historical neighbor bars. Default is 3 (RSI level + momentum + volatility). Options: 1–5. Feature 4 adds RSI slope; Feature 5 adds price momentum. More features = richer pattern matching but heavier computation. 3 is the recommended starting point.
Advanced Filtering
- Apply Additional Smoothing: toggles a second smoothing pass applied after the KNN step. Default is on. Reduces final line noise; leave on for cleaner signals.
- Smoothing Method: which filter is applied. Default is Kalman. Options: None, Kalman, DoubleEMA, ALMA. Kalman adapts its smoothing strength based on the RSI's own movement — it is the most responsive to real changes while still suppressing noise. DoubleEMA is heavier and introduces more lag. ALMA is an intermediate choice.
- Smoothing Parameter: controls the aggressiveness of the selected filter. Default is 0.3. For Kalman: lower values (0.1–0.2) = smoother but more lagged; higher values (0.5–0.8) = closer to the unfiltered line. Adjust based on how much lag you are comfortable with on your timeframe.
Visual Settings
- Neon Effect: switches between bright neon colours (on) and standard muted colours (off). Default is on. With Neon Effect off, the gradient fill between the RSI line and the midline is also hidden. Cosmetic only.
- Color Palette: selects the colour pair used for bull and bear states. Default is Classic (teal / red). Options: Classic, Deuteranopia (blue/yellow), Protanopia (blue/yellow variant), Tritanopia (orange/blue), Monochrome (light grey/dark grey). The Deuteranopia, Protanopia, and Tritanopia palettes are designed for traders with colour-vision deficiencies. Cosmetic only.
- Coloring Mode: controls what drives the line colour and the "Detected" table entry. Default is Trend Following. Options:
- None — no colour applied to the line.
- Trend Following — bull colour above 50, bear colour below 50. Best for momentum-trend reads.
- Impulse — bull colour only when RSI is above the overbought level; bear colour only when below the oversold level; white in the 45–55 neutral band; grey everywhere else. Best for catching extreme-momentum entries.