Indicator · Pine Script v5 · On the chart

Stochastic RSI Screener

by Abbas-Borji

The Stochastic RSI Screener calculates the Relative Strength Index and Stochastic RSI values (K and D lines) for up to five user-defined symbols.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code152
Settings18inputs
LicenceNone statedfile: MPL-2.0
Last update3 years ago24 Apr 2023

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

152 lines of Pine Script v5 from srsIndicator.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

srsIndicator.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Forex_Associate (Abbas Borji)

//@version=5
indicator('Stochastic RSI Screener', overlay=true)



////////////
// Inputs //

candle = input(close, title='Candle State')
rsi_len = input.int(14, title = "RSI Length",     group = 'Stochastic RSI')
rsi_os  = input.float(30, title = "RSI Overbought", group = 'Stochastic RSI')
rsi_ob  = input.float(70, title = "RSI Oversold",   group = 'Stochastic RSI')
smoothKD = input.int(3, 'K & D  Smoothing', minval=1, group='Stochastic RSI')
lengthStoch = input.int(14, 'Stochastic Length', minval=1, group='Stochastic RSI')
stoch_low = input.int(20, title='Stoch Oversold Level', group='Stochastic RSI')
stoch_high = input.int(80, title='Stoch Overbought Level', group='Stochastic RSI')

// Flags & Symbols
u01 = input.bool(true,  title = "", group = 'Symbols', inline = 's01')
u02 = input.bool(true,  title = "", group = 'Symbols', inline = 's02')
u03 = input.bool(true,  title = "", group = 'Symbols', inline = 's03')
u04 = input.bool(true,  title = "", group = 'Symbols', inline = 's04')
u05 = input.bool(true,  title = "", group = 'Symbols', inline = 's05')

s01 = input.symbol('EURUSD',  group = 'Symbols', inline = 's01')
s02 = input.symbol('GBPUSD',  group = 'Symbols', inline = 's02')
s03 = input.symbol('AUDUSD', group = 'Symbols', inline = 's03')
s04 = input.symbol('USDJPY',  group = 'Symbols', inline = 's04')
s05 = input.symbol('USDCAD',  group = 'Symbols', inline = 's05')



//////////////////
// Functions //

// Get Only Symbol
only_symbol(symbol) => 
    array.get(str.split(symbol, ":"), 1)

// Calculations
calculate() =>
    
    rsi = ta.rsi(candle, rsi_len)
    k_value = ta.sma(ta.stoch(rsi, rsi, rsi, lengthStoch), smoothKD)
    d_value =  ta.sma(k_value, smoothKD)
    [math.round_to_mintick(candle), rsi, k_value, d_value]



////////////
// Security Calls //

[candle01, rsi01, k01, d01] = request.security(s01, timeframe.period, calculate())
[candle02, rsi02, k02, d02] = request.security(s02, timeframe.period, calculate())
[candle03, rsi03, k03, d03] = request.security(s03, timeframe.period, calculate())
[candle04, rsi04, k04, d04] = request.security(s04, timeframe.period, calculate())
[candle05, rsi05, k05, d05] = request.security(s05, timeframe.period, calculate())

////////////
// Arrays //

s_arr   = array.new_string(0)
u_arr   = array.new_bool(0)
candle_arr  = array.new_float(0)
rsi_arr = array.new_float(0)
k_arr = array.new_float(0)
d_arr = array.new_float(0)

///////////
// Symbols //

array.push(s_arr, only_symbol(s01))
array.push(s_arr, only_symbol(s02))
array.push(s_arr, only_symbol(s03))
array.push(s_arr, only_symbol(s04))
array.push(s_arr, only_symbol(s05))

///////////
// Flags //

array.push(u_arr, u01)
array.push(u_arr, u02)
array.push(u_arr, u03)
array.push(u_arr, u04)
array.push(u_arr, u05)

///////////
// Candle Values //

array.push(candle_arr, candle01)
array.push(candle_arr, candle02)
array.push(candle_arr, candle03)
array.push(candle_arr, candle04)
array.push(candle_arr, candle05)

/////////
// RSI Values//

array.push(rsi_arr, rsi01)
array.push(rsi_arr, rsi02)
array.push(rsi_arr, rsi03)
array.push(rsi_arr, rsi04)
array.push(rsi_arr, rsi05)

/////////
// K Values //

array.push(k_arr, k01)
array.push(k_arr, k02)
array.push(k_arr, k03)
array.push(k_arr, k04)
array.push(k_arr, k05)

/////////
// D Values //

array.push(d_arr, d01)
array.push(d_arr, d02)
array.push(d_arr, d03)
array.push(d_arr, d04)
array.push(d_arr, d05)



///////////
// Table //

var tbl = table.new(position.top_right, 5, 6, frame_color=color.navy, frame_width=1, border_width=2, border_color=color.new(color.white, 100))

if barstate.islast

    table.cell(tbl, 0, 0, 'Symbol',     text_halign = text.align_center, bgcolor = color.navy, text_color = color.white, text_size = size.small)
    table.cell(tbl, 1, 0, 'Price',      text_halign = text.align_center, bgcolor = color.navy, text_color = color.white, text_size = size.small)
    table.cell(tbl, 2, 0, 'RSI',        text_halign = text.align_center, bgcolor = color.navy, text_color = color.white, text_size = size.small)
    table.cell(tbl, 3, 0, 'K Value',        text_halign = text.align_center, bgcolor = color.navy, text_color = color.white, text_size = size.small)
    table.cell(tbl, 4, 0, 'D Value',        text_halign = text.align_center, bgcolor = color.navy, text_color = color.white, text_size = size.small)

    for i = 0 to 4
        if array.get(u_arr, i)
        
            rsi_col  = array.get(rsi_arr, i) > rsi_ob    ? color.red   : array.get(rsi_arr, i) < rsi_os ? color.green : #aaaaaa
            k_col  = array.get(k_arr, i) > stoch_high    ? color.red   : array.get(k_arr, i) < stoch_low ? color.green : #aaaaaa
            d_col  = array.get(d_arr, i) > stoch_high    ? color.red   : array.get(d_arr, i) < stoch_low ? color.green : #aaaaaa
            
            table.cell(tbl, 0, i + 1, array.get(s_arr, i),                                 text_halign = text.align_left,   bgcolor = #FFA500, text_color = color.navy, text_size = size.small)
            table.cell(tbl, 1, i + 1, str.tostring(array.get(candle_arr, i)),                  text_halign = text.align_center, bgcolor = #aaaaaa,    text_color = color.white, text_size = size.small)
            table.cell(tbl, 2, i + 1, str.tostring(array.get(rsi_arr, i), "#.##"),         text_halign = text.align_center, bgcolor = rsi_col,    text_color = color.white, text_size = size.small)
            table.cell(tbl, 3, i + 1, str.tostring(array.get(k_arr, i), "#.##"),         text_halign = text.align_center, bgcolor = k_col,    text_color = color.white, text_size = size.small)
            table.cell(tbl, 4, i + 1, str.tostring(array.get(d_arr, i), "#.##"),         text_halign = text.align_center, bgcolor = d_col,    text_color = color.white, text_size = size.small)

Overview

Stochastic RSI Screener retrieves the current price, RSI, K-value, and D-value for each selected asset using security calls and displays them in an on-chart table overlay. Users can adjust RSI length, overbought and oversold thresholds, Stochastic length, and smoothing settings, as well as toggle individual symbols on or off.

Details

Published by

Abbas-Borji on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Oscillators & momentum, Screeners & dashboards

Markets

Forex

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.

Settings

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

SettingTypeDefaultVariable
Candle Statesourceclosecandle
RSI Lengthint14rsi_len
RSI Overboughtfloat30rsi_os
RSI Oversoldfloat70rsi_ob
K & D Smoothingint3smoothKD
Stochastic Lengthint14lengthStoch
Stoch Oversold Levelint20stoch_low
Stoch Overbought Levelint80stoch_high
u01booltrueu01
u02booltrueu02
u03booltrueu03
u04booltrueu04
Show all 18 settings
SettingTypeDefaultVariable
u05booltrueu05
s01symbolEURUSDs01
s02symbolGBPUSDs02
s03symbolAUDUSDs03
s04symbolUSDJPYs04
s05symbolUSDCADs05
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

This overlay indicator screens a pasted list of up to forty symbols and draws a table on the price chart. It classifies bullish or bearish setups from the percent change between the current candle and the candle 250 bars back, then shows RSI with a simple movi

Indicator v5 Oscillators & momentumVolume
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
330 stars

This multi-symbol indicator evaluates a combined trading condition across up to 40 user-defined symbols. It processes MACD bullish crossovers, RSI thresholds, Bollinger Band boundaries, and DMI/ADX trend filters using security calls. When buy or sell criteria

Indicator v5 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of Multi MACD + BB + RSI [Alorse]
218 stars

TradersPost Trading Checklist is an overlay indicator that evaluates a suite of popular technical conditions for long and short trade setups. It checks session-anchored VWAP, fast and slow EMA alignments and crosses, 200 SMA, RSI overbought or oversold conditi

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of TradersPost Trading Checklist

8zz反指標v2

by hansai-art
121 stars

The 8zz Contrarian Indicator plots reverse sentiment trading signals directly on the price chart based on tracked retail post activity. It generates bullish signals during retail panic and bearish signals during market euphoria. The indicator features adjustab

Indicator v6 Moving averagesOscillators & momentum
Updated 3 months ago · None stated GitHub repository of 8zz反指標v2

Chart Background

by be-thomas
65 stars

This indicator colors the chart background using a full-screen single-cell table based on the 20-period Relative Strength Index (RSI). When the RSI is above 50, the table applies a bullish background color, and when below 50, a bearish color. The background up

Indicator v4 Oscillators & momentumScreeners & dashboards
Updated 4 days ago · GPL-3.0 GitHub repository of Chart Background
53 stars

This indicator analyzes historical candle direction and price range over a configurable lookback window to gauge market trend. It categorizes trend direction using candle count, price range sum, or both. Signals are filtered using a Simple Moving Average to en

Indicator v6 TrendOscillators & momentum
Updated 2 months ago · MPL-2.0 GitHub repository of Candle Counter + MA + RSI + Mode

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers