Strategy · Pine Script v4 · Own pane

Test Swing Screener

by TPCharts

This script functions as a multi-symbol swing screener calculating the Relative Strength Index across up to 40 user-selected stock tickers using security calls.

View on GitHub

GitHub stars10on the repository
Pine versionv4older, still runs
Lines of code179
Settings40inputs
LicenceGPL-3.0
Last update5 years ago1 Dec 2020

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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

179 lines of Pine Script v4 from SwingScreener.v.0.1.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

SwingScreener.v.0.1.pine
//@version=4
strategy("Test Swing Screener (@tradeprophet)", shorttitle = 'Test Swing Screener (@tradeprophet)', overlay = false)

////////////
// INPUTS //

rsi_length     = input(14, title = "RSI Length")
rsi_overbought = input(70, title = "RSI Overbought Level")

// Symbols 
s01 = input('AAPL',  type=input.symbol)
s02 = input('MSFT',  type=input.symbol)
s03 = input('AMZN',  type=input.symbol)
s04 = input('GOOGL', type=input.symbol)
s05 = input('BABA',  type=input.symbol)
s06 = input('FB',    type=input.symbol)
s07 = input('BRK.A', type=input.symbol)
s08 = input('V',     type=input.symbol)
s09 = input('JNJ',   type=input.symbol)
s10 = input('WMT',   type=input.symbol)
s11 = input('TSM',   type=input.symbol)
s12 = input('PG',    type=input.symbol)
s13 = input('MA',    type=input.symbol)
s14 = input('JPM',   type=input.symbol)
s15 = input('TSLA',  type=input.symbol)
s16 = input('UNH',   type=input.symbol)
s17 = input('HD',    type=input.symbol)
s18 = input('NVDA',  type=input.symbol)
s19 = input('INTC',  type=input.symbol)
s20 = input('NFLX',  type=input.symbol)
s21 = input('VZ',    type=input.symbol)
s22 = input('ADBE',  type=input.symbol)
s23 = input('DIS',   type=input.symbol)
s24 = input('T',     type=input.symbol)
s25 = input('PYPL',  type=input.symbol)
s26 = input('BAC',   type=input.symbol)
s27 = input('NVS',   type=input.symbol)
s28 = input('CSCO',  type=input.symbol)
s29 = input('KO',    type=input.symbol)
s30 = input('MRK',   type=input.symbol)
s31 = input('PFE',   type=input.symbol)
s32 = input('PEP',   type=input.symbol)
s33 = input('CMCSA', type=input.symbol)
s34 = input('SAP',   type=input.symbol)
s35 = input('XOM',   type=input.symbol)
s36 = input('CRM',   type=input.symbol)
s37 = input('ORCL',  type=input.symbol)
s38 = input('TM',    type=input.symbol)
s39 = input('ABBV',  type=input.symbol)
s40 = input('ASML',  type=input.symbol)

///////////////
// FUNCTIONS //

// Screener Function
screenerFunc() => 
    rsi  = rsi(close, rsi_length) // Value
    cond = rsi > rsi_overbought     // Condition
    [rsi, cond]
 
// Rounding Function
roundn(x, n) => 
    mult = 1 
    if n != 0
        for i = 1 to abs(n)
            mult := mult * 10
    
    n >= 0 ? round(x * mult) / mult : round(x / mult) * mult 

///////////////////////////////////////
// Running Functions for all sybmols //

[v01, c01] = security(s01, timeframe.period, screenerFunc())
[v02, c02] = security(s02, timeframe.period, screenerFunc())
[v03, c03] = security(s03, timeframe.period, screenerFunc())
[v04, c04] = security(s04, timeframe.period, screenerFunc())
[v05, c05] = security(s05, timeframe.period, screenerFunc())
[v06, c06] = security(s06, timeframe.period, screenerFunc())
[v07, c07] = security(s07, timeframe.period, screenerFunc())
[v08, c08] = security(s08, timeframe.period, screenerFunc())
[v09, c09] = security(s09, timeframe.period, screenerFunc())
[v10, c10] = security(s10, timeframe.period, screenerFunc())
[v11, c11] = security(s11, timeframe.period, screenerFunc())
[v12, c12] = security(s12, timeframe.period, screenerFunc())
[v13, c13] = security(s13, timeframe.period, screenerFunc())
[v14, c14] = security(s14, timeframe.period, screenerFunc())
[v15, c15] = security(s15, timeframe.period, screenerFunc())
[v16, c16] = security(s16, timeframe.period, screenerFunc())
[v17, c17] = security(s17, timeframe.period, screenerFunc())
[v18, c18] = security(s18, timeframe.period, screenerFunc())
[v19, c19] = security(s19, timeframe.period, screenerFunc())
[v20, c20] = security(s20, timeframe.period, screenerFunc())
[v21, c21] = security(s21, timeframe.period, screenerFunc())
[v22, c22] = security(s22, timeframe.period, screenerFunc())
[v23, c23] = security(s23, timeframe.period, screenerFunc())
[v24, c24] = security(s24, timeframe.period, screenerFunc())
[v25, c25] = security(s25, timeframe.period, screenerFunc())
[v26, c26] = security(s26, timeframe.period, screenerFunc())
[v27, c27] = security(s27, timeframe.period, screenerFunc())
[v28, c28] = security(s28, timeframe.period, screenerFunc())
[v29, c29] = security(s29, timeframe.period, screenerFunc())
[v30, c30] = security(s30, timeframe.period, screenerFunc())
[v31, c31] = security(s31, timeframe.period, screenerFunc())
[v32, c32] = security(s32, timeframe.period, screenerFunc())
[v33, c33] = security(s33, timeframe.period, screenerFunc())
[v34, c34] = security(s34, timeframe.period, screenerFunc())
[v35, c35] = security(s35, timeframe.period, screenerFunc())
[v36, c36] = security(s36, timeframe.period, screenerFunc())
[v37, c37] = security(s37, timeframe.period, screenerFunc())
[v38, c38] = security(s38, timeframe.period, screenerFunc())
[v39, c39] = security(s39, timeframe.period, screenerFunc())
[v40, c40] = security(s40, timeframe.period, screenerFunc())

////////////////////
// Screener label //

scr_label = 'Screener: \n##########\n'

scr_label := c01  ? scr_label + s01 + ' ' + tostring(roundn(v01, 3)) +  '\n'  : scr_label
scr_label := c02  ? scr_label + s02 + ' ' + tostring(roundn(v02, 3)) +  '\n'  : scr_label
scr_label := c03  ? scr_label + s03 + ' ' + tostring(roundn(v03, 3)) +  '\n'  : scr_label
scr_label := c04  ? scr_label + s04 + ' ' + tostring(roundn(v04, 3)) +  '\n'  : scr_label
scr_label := c05  ? scr_label + s05 + ' ' + tostring(roundn(v05, 3)) +  '\n'  : scr_label
scr_label := c06  ? scr_label + s06 + ' ' + tostring(roundn(v06, 3)) +  '\n'  : scr_label
scr_label := c07  ? scr_label + s07 + ' ' + tostring(roundn(v07, 3)) +  '\n'  : scr_label
scr_label := c08  ? scr_label + s08 + ' ' + tostring(roundn(v08, 3)) +  '\n'  : scr_label
scr_label := c09  ? scr_label + s09 + ' ' + tostring(roundn(v09, 3)) +  '\n'  : scr_label
scr_label := c10  ? scr_label + s10 + ' ' + tostring(roundn(v10, 3)) +  '\n'  : scr_label
scr_label := c11  ? scr_label + s11 + ' ' + tostring(roundn(v11, 3)) +  '\n'  : scr_label
scr_label := c12  ? scr_label + s12 + ' ' + tostring(roundn(v12, 3)) +  '\n'  : scr_label
scr_label := c13  ? scr_label + s13 + ' ' + tostring(roundn(v13, 3)) +  '\n'  : scr_label
scr_label := c14  ? scr_label + s14 + ' ' + tostring(roundn(v14, 3)) +  '\n'  : scr_label
scr_label := c15  ? scr_label + s15 + ' ' + tostring(roundn(v15, 3)) +  '\n'  : scr_label
scr_label := c16  ? scr_label + s16 + ' ' + tostring(roundn(v16, 3)) +  '\n'  : scr_label
scr_label := c17  ? scr_label + s17 + ' ' + tostring(roundn(v17, 3)) +  '\n'  : scr_label
scr_label := c18  ? scr_label + s18 + ' ' + tostring(roundn(v18, 3)) +  '\n'  : scr_label
scr_label := c19  ? scr_label + s19 + ' ' + tostring(roundn(v19, 3)) +  '\n'  : scr_label
scr_label := c20  ? scr_label + s20 + ' ' + tostring(roundn(v20, 3)) +  '\n'  : scr_label
scr_label := c21  ? scr_label + s21 + ' ' + tostring(roundn(v21, 3)) +  '\n'  : scr_label
scr_label := c22  ? scr_label + s22 + ' ' + tostring(roundn(v22, 3)) +  '\n'  : scr_label
scr_label := c23  ? scr_label + s23 + ' ' + tostring(roundn(v23, 3)) +  '\n'  : scr_label
scr_label := c24  ? scr_label + s24 + ' ' + tostring(roundn(v24, 3)) +  '\n'  : scr_label
scr_label := c25  ? scr_label + s25 + ' ' + tostring(roundn(v25, 3)) +  '\n'  : scr_label
scr_label := c26  ? scr_label + s26 + ' ' + tostring(roundn(v26, 3)) +  '\n'  : scr_label
scr_label := c27  ? scr_label + s27 + ' ' + tostring(roundn(v27, 3)) +  '\n'  : scr_label
scr_label := c28  ? scr_label + s28 + ' ' + tostring(roundn(v28, 3)) +  '\n'  : scr_label
scr_label := c29  ? scr_label + s29 + ' ' + tostring(roundn(v29, 3)) +  '\n'  : scr_label
scr_label := c30  ? scr_label + s30 + ' ' + tostring(roundn(v30, 3)) +  '\n'  : scr_label
scr_label := c31  ? scr_label + s31 + ' ' + tostring(roundn(v31, 3)) +  '\n'  : scr_label
scr_label := c32  ? scr_label + s32 + ' ' + tostring(roundn(v32, 3)) +  '\n'  : scr_label
scr_label := c33  ? scr_label + s33 + ' ' + tostring(roundn(v33, 3)) +  '\n'  : scr_label
scr_label := c34  ? scr_label + s34 + ' ' + tostring(roundn(v34, 3)) +  '\n'  : scr_label
scr_label := c35  ? scr_label + s35 + ' ' + tostring(roundn(v35, 3)) +  '\n'  : scr_label
scr_label := c36  ? scr_label + s36 + ' ' + tostring(roundn(v36, 3)) +  '\n'  : scr_label
scr_label := c37  ? scr_label + s37 + ' ' + tostring(roundn(v37, 3)) +  '\n'  : scr_label
scr_label := c38  ? scr_label + s38 + ' ' + tostring(roundn(v38, 3)) +  '\n'  : scr_label
scr_label := c39  ? scr_label + s39 + ' ' + tostring(roundn(v39, 3)) +  '\n'  : scr_label
scr_label := c40  ? scr_label + s40 + ' ' + tostring(roundn(v40, 3)) +  '\n'  : scr_label

// Adding #telegram hashtag for alertatron
scr_label := scr_label + "\n #telegram"

// Plot Label
lab_l = label.new(
          bar_index, 0, scr_label, 
          color=color.gray, 
          textcolor=color.black, 
          style =  label.style_labeldown,
          yloc = yloc.price)

label.delete(lab_l[1])

plot(0, transp = 100)

////////////////////
// Dummy strategy //
if (time >= timestamp(year(timenow), month(timenow), dayofmonth(timenow), 00, 00))
    strategy.entry("dummy_long", true, when = strategy.position_size[1] == 0 and barstate.isconfirmed, alert_message = scr_label)
    strategy.close("dummy_long",       when = strategy.position_size[1] != 0 and barstate.isconfirmed, alert_message = scr_label)

Overview

Test Swing Screener evaluates whether each symbol's RSI exceeds a specified overbought threshold level. Inputs allow users to adjust the RSI length, overbought cutoff value, and individual symbol selections. Displayed in a separate pane, the script serves as a monitoring tool and lacks automated entry or exit triggers, position management, or stop loss controls.

Details

Published by

TPCharts on GitHub

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Screeners & dashboards, Oscillators & momentum

Markets

Stocks

Timeframes

H4 and above, M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Settings

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

SettingTypeDefaultVariable
RSI Lengthint14rsi_length
RSI Overbought Levelint70rsi_overbought
s01symbolAAPLs01
s02symbolMSFTs02
s03symbolAMZNs03
s04symbolGOOGLs04
s05symbolBABAs05
s06symbolFBs06
s07symbolBRK.As07
s08symbolVs08
s09symbolJNJs09
s10symbolWMTs10
Show all 40 settings
SettingTypeDefaultVariable
s11symbolTSMs11
s12symbolPGs12
s13symbolMAs13
s14symbolJPMs14
s15symbolTSLAs15
s16symbolUNHs16
s17symbolHDs17
s18symbolNVDAs18
s19symbolINTCs19
s20symbolNFLXs20
s21symbolVZs21
s22symbolADBEs22
s23symbolDISs23
s24symbolTs24
s25symbolPYPLs25
s26symbolBACs26
s27symbolNVSs27
s28symbolCSCOs28
s29symbolKOs29
s30symbolMRKs30
s31symbolPFEs31
s32symbolPEPs32
s33symbolCMCSAs33
s34symbolSAPs34
s35symbolXOMs35
s36symbolCRMs36
s37symbolORCLs37
s38symbolTMs38
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

8 stars

This strategy calculates a StockCharts Technical Rank metric alongside an O'Neil-style relative strength rating, plotting both curves in a separate pane. It evaluates long-term, medium-term, and short-term exponential moving average deviations, rate-of-change

Strategy v5 Oscillators & momentumMoving averages
Updated 4 years ago · None stated GitHub repository of SCTR & ONeil + RSI strategy

This strategy calculates intraday volatility mean reversion using session VWAP standard deviation bands, RSI overbought and oversold levels, and candle wick exhaustion ratios. It enters trades when price reaches statistical extremes filtered by RSI and wick co

Strategy v6 Mean reversionVolatility & bands
Updated 7 months ago · MIT GitHub repository of Intraday Volatility Reversion Z-Score
104 stars

This overlay strategy combines a machine-learning distance model with a MACD oscillator to open trades on the price chart. It compares recent history using cosine similarity or Euclidean and Lorentzian distance, then filters direction with selectable moving-av

Strategy v5 AI / machine learningOscillators & momentum
Updated 3 years ago · MIT GitHub repository of MLCEL and MACD Strategy
13 stars

This strategy automates the TradingLatino methodology by evaluating Squeeze Momentum combined with the Average Directional Index (ADX). It executes long or short positions based on momentum shifts and directional strength. Risk management options include const

Strategy v5 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of Ruckard Lupown TradingLatino A002

Dual Moving Average

by hirawatt
11 stars

Dual Moving Average is a Pine Script v4 strategy that overlays the price chart. The shown code declares a strategy with fixed quantity, cash commission, slippage, and calculation on every tick. Inputs set the price source, a start and end date, a symbol that d

Strategy v4 Oscillators & momentumScreeners & dashboards Repaints
Updated 2 years ago · MIT GitHub repository of Dual Moving Average

This long-only trend-following strategy combines Ichimoku Kinko Hyo components with higher timeframe moving average filters. It triggers long entries when price trades above a higher timeframe EMA and a bullish Tenkan-Sen cross above Kijun-Sen occurs under fav

Strategy v5 TrendOscillators & momentum
Updated 1 year ago · MPL-2.0 GitHub repository of Ichimoku Kinko Hyo Momentum Strategy

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers