Skip to content
YinYang
indicatorActiveOpen Source

Machine Learning: Optimal RSI

Evaluate RSI lengths and optionally smooth the strongest recent candidate through machine-learning modes.

AlertsSource updated 2023-10-23Reviewed 2026-07-19
Machine Learning Optimal RSI publication chart on TradingView

Overview

Evaluate RSI lengths and optionally smooth the strongest recent candidate through machine-learning modes.

The script scores RSI lengths by historical RSI/MA cross performance, selects an Optimal RSI, and can average or KNN-filter recent optimal values. It is intended for adaptive RSI exploration rather than guaranteed parameter selection.

Key capabilities

  • RSI length scoring
  • Optimal RSI selection
  • Simple-average and KNN modes
  • Optional bullish/bearish filtering
  • Adaptive overbought and oversold context

Configuration

Start with the documented controls

  • Define the tested RSI length range and lookback.
  • Choose simple average, KNN, or no machine-learning filter.
  • Validate the selected length outside the optimization window.

Tutorial

Learn the workflow in context

Step 1

How it works

The script scores RSI lengths by historical RSI/MA cross performance, selects an Optimal RSI, and can average or KNN-filter recent optimal values. It is intended for adaptive RSI exploration rather than guaranteed parameter selection.

  • RSI length scoring
  • Optimal RSI selection
  • Simple-average and KNN modes
  • Optional bullish/bearish filtering
  • Adaptive overbought and oversold context

Step 2

Set up the script

Open the original publication, choose Use on TradingView, then add the script to the intended symbol and timeframe. Review each input before relying on the display; defaults are a starting point, not a universal recommendation.

  • Define the tested RSI length range and lookback.
  • Choose simple average, KNN, or no machine-learning filter.
  • Validate the selected length outside the optimization window.

Step 3

Create an alert

All current YinYang publications support TradingView alerts. Select a condition exposed by the script, confirm the symbol and timeframe, and test notifications before relying on them. This Alerts label does not by itself mean a webhook execution workflow has been verified.

Risk and results context

Signals, projections, and strategy outputs are analytical tools—not financial advice or guarantees of future results. Trading involves substantial risk.

This guide is a rewritten YinYang overview. For the author’s complete source description and release notes, view the original publication.

Related scripts

Continue exploring the library

Ultimate

Use the complete TradingView library

Ultimate combines the web analytics platform with all six featured invite-only TradingView tools.

TradingView® is a trademark of TradingView, Inc. YinYang Algorithms is not affiliated with or endorsed by TradingView. A separate TradingView account is required; paid TradingView plans are not included.