OPEN-SOURCE SCRIPT
MTF RSI Stacked + AI + Gradient

MTF RSI Stacked + AI + Gradient
Quick-start guide & best-practice rules
What the indicator does
Multi-Time-Frame RSI in one pane
• 10 time-frames (1 m → 1 M) are stacked 100 points apart (0, 100, 200 … 900).
• Each RSI is plotted with a smooth red-yellow-green gradient:
– Red = RSI below 30 (oversold)
– Yellow = RSI near 50
– Green = RSI above 70 (overbought)
• Grey 30-70 bands are drawn for every TF so you can see extremities at a glance.
Built-in AI (KNN) signal
• On every close of the chosen AI-time-frame the script:
– Takes the last 14-period RSI + normalised ATR as “features”
– Compares them to the last N bars (default 1 000)
– Votes of the k = 5 closest neighbours → BUY / SELL / NEUTRAL
• Confidence % is shown in the badge (top-right).
• A thick vertical line (green/red) is printed once when the signal flips.
How to read it
• Gradient colour tells you instantly which TFs are overbought/obove sold.
• When all or most gradients are green → broad momentum up; look for shorts only on lower-TF pullbacks.
• When most are red → broad momentum down; favour longs only on lower-TF bounces.
• Use the AI signal as a confluence filter, not a stand-alone entry:
– If AI = BUY and 3+ higher-TF RSIs just crossed > 50 → consider long.
– If AI = SELL and 3+ higher-TF RSIs just crossed < 50 → consider short.
• Divergences: price makes a higher high but 1 h/4 h RSI (gradient) makes a lower high → possible reversal.
Settings you can tweak
AI timeframe – leave empty = same as chart, or pick a higher TF (e.g. “15” or “60”) to slow the signal down.
Training bars – 500-2 000 is the sweet spot; bigger = slower but more stable.
K neighbours – 3-7; lower = more signals, higher = smoother.
RSI length – 14 is standard; 9 gives earlier turns, 21 gives fewer false swings.
Practical trading workflow
Open the symbol on your execution TF (e.g. 5 m).
Set AI timeframe to 3-5× execution TF (e.g. 15 m or 30 m) so the signal survives market noise.
Wait for AI signal to align with gradient extremes on at least one higher TF.
Enter on the first gradient reversal inside the 30-70 band on the execution TF.
Place stop beyond the swing that caused the gradient flip; target next opposing 70/30 level on the same TF or trail with structure.
Colour cheat-sheet
Bright green → RSI ≥ 70 (overbought)
Bright red → RSI ≤ 30 (oversold)
Muted colours → RSI near 50 (neutral, momentum pause)
That’s it—one pane, ten time-frames, colour-coded extremes and an AI confluence layer.
Keep the chart clean, use price action for precise entries, and let the gradient tell you when the wind is at your back.
Quick-start guide & best-practice rules
What the indicator does
Multi-Time-Frame RSI in one pane
• 10 time-frames (1 m → 1 M) are stacked 100 points apart (0, 100, 200 … 900).
• Each RSI is plotted with a smooth red-yellow-green gradient:
– Red = RSI below 30 (oversold)
– Yellow = RSI near 50
– Green = RSI above 70 (overbought)
• Grey 30-70 bands are drawn for every TF so you can see extremities at a glance.
Built-in AI (KNN) signal
• On every close of the chosen AI-time-frame the script:
– Takes the last 14-period RSI + normalised ATR as “features”
– Compares them to the last N bars (default 1 000)
– Votes of the k = 5 closest neighbours → BUY / SELL / NEUTRAL
• Confidence % is shown in the badge (top-right).
• A thick vertical line (green/red) is printed once when the signal flips.
How to read it
• Gradient colour tells you instantly which TFs are overbought/obove sold.
• When all or most gradients are green → broad momentum up; look for shorts only on lower-TF pullbacks.
• When most are red → broad momentum down; favour longs only on lower-TF bounces.
• Use the AI signal as a confluence filter, not a stand-alone entry:
– If AI = BUY and 3+ higher-TF RSIs just crossed > 50 → consider long.
– If AI = SELL and 3+ higher-TF RSIs just crossed < 50 → consider short.
• Divergences: price makes a higher high but 1 h/4 h RSI (gradient) makes a lower high → possible reversal.
Settings you can tweak
AI timeframe – leave empty = same as chart, or pick a higher TF (e.g. “15” or “60”) to slow the signal down.
Training bars – 500-2 000 is the sweet spot; bigger = slower but more stable.
K neighbours – 3-7; lower = more signals, higher = smoother.
RSI length – 14 is standard; 9 gives earlier turns, 21 gives fewer false swings.
Practical trading workflow
Open the symbol on your execution TF (e.g. 5 m).
Set AI timeframe to 3-5× execution TF (e.g. 15 m or 30 m) so the signal survives market noise.
Wait for AI signal to align with gradient extremes on at least one higher TF.
Enter on the first gradient reversal inside the 30-70 band on the execution TF.
Place stop beyond the swing that caused the gradient flip; target next opposing 70/30 level on the same TF or trail with structure.
Colour cheat-sheet
Bright green → RSI ≥ 70 (overbought)
Bright red → RSI ≤ 30 (oversold)
Muted colours → RSI near 50 (neutral, momentum pause)
That’s it—one pane, ten time-frames, colour-coded extremes and an AI confluence layer.
Keep the chart clean, use price action for precise entries, and let the gradient tell you when the wind is at your back.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.