Indicator · Pine Script v6 · Own pane

RSI multi-length fixed timeframe

by InNoobWeTrust

This indicator calculates the Relative Strength Index alongside a smoothing moving average and multiple length tiers based on a fixed timeframe.

View on GitHub

GitHub stars4on the repository
Pine versionv6current
Lines of code188
Settings30inputs
LicenceNone statedfile: MPL-2.0
Last update2 days ago28 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

188 lines of Pine Script v6 from .innoobwetrust/life_hacks/tradingview/rsi_multilen_fixed_tf.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

rsi_multilen_fixed_tf.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © InNoobWeTrust

//@version=6
indicator("RSI multi-length fixed timeframe", overlay = false)
import TradingView/ta/9

//===============================================================================
// Types
//===============================================================================
enum MaT
    sma = 'SMA'
    wma = 'WMA'
    ema = 'EMA'

//===============================================================================
// Functions
//===============================================================================
ma(MaT t, src, int len) =>
    switch t
        MaT.sma => ta.sma(src,len)
        MaT.wma => ta.wma(src,len)
        MaT.ema => ta.ema(src,len)

//===============================================================================
// Input
//===============================================================================
tf = input.timeframe('','► Timeframe')

threshold_grp = '► Thresholds'
threshold_low_limit = input.float(30,'Low threshold',minval=0,maxval=50,group = threshold_grp)
threshold_high_limit = input.float(70,'High threshold',minval=50,maxval=100,group = threshold_grp)
threshold_color_inline = 'Threshold colors (middle line to low/high)'
threshold_color_middle_low = input.color(color.new(color.blue,90),threshold_color_inline,group = threshold_grp,inline = threshold_color_inline)
threshold_color_middle_high = input.color(color.new(color.yellow,90),'',group = threshold_grp,inline = threshold_color_inline)

rsi_grp = '► RSI'
rsi_src = input.source(close,'RSI source',group = rsi_grp)
rsi_len = input.int(14,'RSI length',group = rsi_grp)
rsi_ma_inline = 'RSI MA'
rsi_ma_type = input.enum(MaT.wma,rsi_ma_inline,group = rsi_grp,inline = rsi_ma_inline)
rsi_ma_len = input.int(9,'',group = rsi_grp,inline = rsi_ma_inline)
bearish_color = input.color(color.new(color.red,50),'Bearish area color',group = rsi_grp)
bullish_color = input.color(color.new(color.green,50),'Bullish area color',group = rsi_grp)

bg_grp = '► Bullish/bearish chart background'
bg_enable = input.bool(true,'Enable',group = bg_grp)
bg_color_inline = 'Background colors (bullish/bearish)'
bg_bullish_color = input.color(color.new(color.aqua,90),bg_color_inline,group = bg_grp,inline = bg_color_inline)
bg_bearish_color = input.color(color.new(color.orange,90),'',group = bg_grp,inline = bg_color_inline)

multilen_grp = '► Multi-length'
multilen_tf = input.timeframe('5','Base',group = multilen_grp)
multilen_mult = input.int(6,'Multiplier',group = multilen_grp)
multilen_levels = input.int(4,'Levels',minval=0,maxval=4,group = multilen_grp)
multilen_color = input.color(color.new(color.aqua,85),'Color',group = multilen_grp)
multilen_avg_inline = 'Multi-length Average'
multilen_avg_enable = input.bool(true,multilen_avg_inline,group = multilen_grp,inline = multilen_avg_inline)
multilen_avg_color = input.color(color.new(color.teal,70),'',group = multilen_grp,inline = multilen_avg_inline)

spike_grp = '► Spike detection background'
spike_signal_line = input.string('Multi-length Base','Signal line',options = ['RSI','MA','Multi-length Base','Multi-length Average'],group = spike_grp)
spike_cross_high_inline = 'High threshold'
spike_cross_high_enable = input.bool(true,spike_cross_high_inline,group = spike_grp,inline = spike_cross_high_inline)
spike_cross_high_threshold = input.int(60,'',group = spike_grp,inline = spike_cross_high_inline)
spike_cross_high_bg_color = input.color(color.new(color.maroon,25),'',group = spike_grp,inline = spike_cross_high_inline)
spike_cross_low_inline = 'Low threshold'
spike_cross_low_enable = input.bool(true,spike_cross_low_inline,group = spike_grp,inline = spike_cross_low_inline)
spike_cross_low_threshold = input.int(40,'',group = spike_grp,inline = spike_cross_low_inline)
spike_cross_low_bg_color = input.color(color.new(color.navy,25),'',group = spike_grp,inline = spike_cross_low_inline)
spike_only_crossing = input.bool(true, 'Highligh only crossing point', group = spike_grp)
spike_only_correction_wave = input.bool(true,'Only correction wave (main line stays outside thresholds)',group = spike_grp)
spike_main_line = input.string('MA','Main line',options = ['RSI','MA','Multi-length Base','Multi-length Average'],group = spike_grp)

//===============================================================================
// Pre-calculated
//===============================================================================
var tf_secs = timeframe.in_seconds(tf)
var multilen_tf_secs = timeframe.in_seconds(multilen_tf)
var multilen_scale = multilen_tf_secs / tf_secs
//===============================================================================
// Calculation
//===============================================================================

// RSI
rsi = ta.rsi(rsi_src,rsi_len)
rsi_ma = ma(rsi_ma_type,rsi,rsi_ma_len)
tf_rsi = request.security(syminfo.tickerid,tf,rsi)
bullish_area_color = rsi >= threshold_high_limit ? bullish_color : na
bearish_area_color = rsi <= threshold_low_limit ? bearish_color : na

// Multilen RSI
multi_rsi_data = array.new<float>(4,0.)
multi_rsi_data.set(0,request.security(syminfo.tickerid,multilen_tf,ta.rsi(rsi_src,rsi_len * 1)))
multi_rsi_data.set(1,request.security(syminfo.tickerid,multilen_tf,ta.rsi(rsi_src,rsi_len * 2)))
multi_rsi_data.set(2,request.security(syminfo.tickerid,multilen_tf,ta.rsi(rsi_src,rsi_len * 3)))
multi_rsi_data.set(3,request.security(syminfo.tickerid,multilen_tf,ta.rsi(rsi_src,rsi_len * 4)))

multi_rsi_avg = multi_rsi_data.avg()

// Cross
cross_signal = switch spike_signal_line
    'RSI' => rsi
    'MA' => rsi_ma
    'Multi-length Base' => tf_rsi
    'Multi-length Average' => multi_rsi_avg
cross_signal_is_mtf = switch spike_signal_line
    'RSI' => false
    'MA' => false
    'Multi-length Base' => true
    'Multi-length Average' => true
cross_high_signal_expr = switch spike_only_crossing
    false => cross_signal >= spike_cross_high_threshold
    true => ta.crossover(cross_signal, spike_cross_high_threshold)
cross_low_signal_expr = switch spike_only_crossing
    false => cross_signal <= spike_cross_low_threshold
    true => ta.crossunder(cross_signal, spike_cross_low_threshold)

signal_cross_high = cross_signal_is_mtf ? request.security(syminfo.tickerid,multilen_tf, cross_high_signal_expr) : cross_high_signal_expr
signal_cross_low = cross_signal_is_mtf ? request.security(syminfo.tickerid,multilen_tf, cross_low_signal_expr) : cross_low_signal_expr

cross_main = switch spike_main_line
    'RSI' => rsi
    'MA' => rsi_ma
    'Multi-length Base' => tf_rsi
    'Multi-length Average' => multi_rsi_avg
main_crossover_high = ta.crossover(cross_main,spike_cross_high_threshold)
main_crossunder_low = ta.crossunder(cross_main,spike_cross_low_threshold)

main_lowest_since_crossover = ta.lowestSince(main_crossover_high,cross_main)
main_highest_since_crossunder = ta.highestSince(main_crossunder_low,cross_main)

main_remain_high = spike_cross_high_threshold <= main_lowest_since_crossover
main_remain_low = main_highest_since_crossunder <= spike_cross_low_threshold

if spike_only_correction_wave
    signal_cross_high := signal_cross_high and main_remain_low
    signal_cross_low := signal_cross_low and main_remain_high

signal_cross_or_remain_high = signal_cross_high or (spike_cross_high_threshold <= cross_signal and cross_signal <= threshold_high_limit)
signal_cross_or_remain_low = signal_cross_low or (threshold_low_limit <= cross_signal and cross_signal <= spike_cross_low_threshold)

//===============================================================================
// Visual calculation
//===============================================================================
chart_bg_color = switch
    bg_enable and tf_rsi <= threshold_low_limit => bg_bearish_color
    bg_enable and tf_rsi >= threshold_high_limit => bg_bullish_color
    => color(na)
bg_color = switch
    spike_cross_high_enable and signal_cross_high => spike_cross_high_bg_color
    spike_cross_low_enable and signal_cross_low => spike_cross_low_bg_color
    => color(na)

//===============================================================================
// Plot
//===============================================================================

// Thresholds
low_line = hline(threshold_low_limit,'Index Low threshold',linestyle = hline.style_dashed,color=color.new(color.gray,50))
middle_line = hline(50,'Index Middle',linestyle = hline.style_dashed,color=color.new(color.gray,50))
high_line = hline(threshold_high_limit,'Index High threshold',linestyle = hline.style_dashed,color=color.new(color.gray,50))
fill(low_line,middle_line,threshold_color_middle_low)
fill(high_line,middle_line,threshold_color_middle_high)

// Cross thresholds
cross_high_line = hline(spike_cross_high_enable ? spike_cross_high_threshold : na,'Cross high threshold',linestyle = hline.style_dotted,color = color.new(color.gray,70))
cross_low_line = hline(spike_cross_low_enable ? spike_cross_low_threshold : na,'Cross low threshold',linestyle = hline.style_dotted,color = color.new(color.gray,70))

// RSI
plot(rsi,'RSI',color.purple,force_overlay = false)
plot(rsi_ma,'RSI MA', color.yellow,force_overlay = false)
plot(rsi,'Oversold',bearish_area_color,style = plot.style_area,histbase = threshold_low_limit)
plot(rsi,'Overbought',bullish_area_color,style = plot.style_area,histbase = threshold_high_limit)

// Chart background
bgcolor(chart_bg_color,force_overlay = true)

// Panel background
bgcolor(bg_color,force_overlay = false)

// Multi-length RSI
plot(multilen_levels > 0 ? multi_rsi_data.get(0) : na,'Multi-length RSI #1',color = multilen_color,force_overlay = false)
plot(multilen_levels > 1 ? multi_rsi_data.get(1) : na,'Multi-length RSI #2',color = multilen_color,force_overlay = false)
plot(multilen_levels > 2 ? multi_rsi_data.get(2) : na,'Multi-length RSI #3',color = multilen_color,force_overlay = false)
plot(multilen_levels > 3 ? multi_rsi_data.get(3) : na,'Multi-length RSI #4',color = multilen_color,force_overlay = false)
// Multi-length RSI Average
plot(multilen_levels > 0 and multilen_avg_enable ? multi_rsi_avg : na,'Multi-length RSI Average',color = multilen_avg_color,force_overlay = false)

Overview

RSI multi-length fixed timeframe draws in a separate pane below the price chart, plotting tiered RSI levels and an optional multi-length average. Background coloring signals market spikes and correction waves when chosen indicator lines cross designated upper or lower thresholds. User settings control RSI length, smoothing moving average type, base timeframes, multiplier levels, and spike detection criteria. The script operates strictly as an analytical tool without automated execution logic.

Details

Published by

InNoobWeTrust on GitHub

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

dotfiles

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
► Timeframetimeframetf
Low thresholdfloat30threshold_low_limit
High thresholdfloat70threshold_high_limit
threshold_color_middle_lowcolorcolor.new(color.blue,90)threshold_color_middle_low
threshold_color_middle_highcolorcolor.new(color.yellow,90)threshold_color_middle_high
RSI sourcesourceclosersi_src
RSI lengthint14rsi_len
rsi_ma_typeenumMaT.wmarsi_ma_type
rsi_ma_lenint9rsi_ma_len
Bearish area colorcolorcolor.new(color.red,50)bearish_color
Bullish area colorcolorcolor.new(color.green,50)bullish_color
Enablebooltruebg_enable
Show all 30 settings
SettingTypeDefaultVariable
bg_bullish_colorcolorcolor.new(color.aqua,90)bg_bullish_color
bg_bearish_colorcolorcolor.new(color.orange,90)bg_bearish_color
Basetimeframe5multilen_tf
Multiplierint6multilen_mult
Levelsint4multilen_levels
Colorcolorcolor.new(color.aqua,85)multilen_color
multilen_avg_enablebooltruemultilen_avg_enable
multilen_avg_colorcolorcolor.new(color.teal,70)multilen_avg_color
Signal linestringMulti-length Basespike_signal_line
spike_cross_high_enablebooltruespike_cross_high_enable
spike_cross_high_thresholdint60spike_cross_high_threshold
spike_cross_high_bg_colorcolorcolor.new(color.maroon,25)spike_cross_high_bg_color
spike_cross_low_enablebooltruespike_cross_low_enable
spike_cross_low_thresholdint40spike_cross_low_threshold
spike_cross_low_bg_colorcolorcolor.new(color.navy,25)spike_cross_low_bg_color
Highligh only crossing pointbooltruespike_only_crossing
Only correction wave (main line stays outside thresholds)booltruespike_only_correction_wave
Main linestringMAspike_main_line
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

947 stars

The Derivative Oscillator calculates a double-exponentially smoothed Relative Strength Index (RSI) and subtracts its Simple Moving Average (SMA) to form the main oscillator line. A secondary signal line is plotted using an SMA of the main oscillator values. Th

Indicator v4 Oscillators & momentumMoving averages
Updated 12 days ago · GPL-3.0 GitHub repository of Derivative Oscillator

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

MACD

by Alorse
330 stars

This indicator calculates and plots the standard Moving Average Convergence Divergence oscillator in a separate pane. It computes the difference between a fast and slow moving average, derives a signal line through smoothing, and plots a histogram representing

Indicator v4 Oscillators & momentumMoving averages
Updated 2 months ago · None stated GitHub repository of MACD
228 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

MACD-V

by harryguiacorn
220 stars

MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of MACD-V

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of KamaFama

More Oscillators & momentum scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers