How to develop Screener in Pine Script TradingView

How to develop Screener in Pine Script TradingView


Developing a screener in Pine Script on TradingView involves creating custom scanning criteria, filters, and alerts. This guide will walk you through the process of developing a screener using Pine Script, enabling you to efficiently scan and identify trading opportunities based on technical indicators and patterns within the TradingView platform.


Sample Code :-

//========================================================================
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © subhajitbhattacharya

//@version=5
indicator(title='Screener', overlay=true)
len = input.int(9,title="RSI Length")

//========================================================================
screen() =>
    rsi = ta.rsi(close,len)
    bull = rsi > 55
    bear = rsi < 45
    [bull, bear]

//========================================================================

tf = timeframe.period

s1 = input.symbol('NSE:NIFTY1!','Symbol 1', inline = '1', group = 'STOCK LIST')
s2 = input.symbol('NSE:BANKNIFTY1!','Symbol 2', inline = '1', group = 'STOCK LIST')
s3 = input.symbol('NSE:SBIN','Symbol 3', inline = '1', group = 'STOCK LIST')
s4 = input.symbol('NSE:HDFC','Symbol 4', inline = '1', group = 'STOCK LIST')
s5 = input.symbol('NSE:RELIANCE','Symbol 5', inline = '1', group = 'STOCK LIST')

[c1,v1] = request.security(s1,tf,screen())
[c2,v2] = request.security(s2,tf,screen())
[c3,v3] = request.security(s3,tf,screen())
[c4,v4] = request.security(s4,tf,screen())
[c5,v5] = request.security(s5,tf,screen())

//========================================================================

buy_label = ' =====BUY======\n'
buy_label := c1 ? buy_label + str.tostring(s1) + '\n' : buy_label
buy_label := c2 ? buy_label + str.tostring(s2) + '\n' : buy_label
buy_label := c3 ? buy_label + str.tostring(s3) + '\n' : buy_label
buy_label := c4 ? buy_label + str.tostring(s4) + '\n' : buy_label
buy_label := c5 ? buy_label + str.tostring(s5) + '\n' : buy_label

lab_buy = label.new(bar_index+10, close, buy_label, color=color.new(color.lime,70), textcolor=color.white, style=label.style_label_up, yloc=yloc.price,textalign=text.align_left)
label.delete(lab_buy[1])

sell_label = ' =====SELL======\n'
sell_label := v1 ? sell_label + str.tostring(s1) + '\n' : sell_label
sell_label := v2 ? sell_label + str.tostring(s2) + '\n' : sell_label
sell_label := v3 ? sell_label + str.tostring(s3) + '\n' : sell_label
sell_label := v4 ? sell_label + str.tostring(s4) + '\n' : sell_label
sell_label := v5 ? sell_label + str.tostring(s5) + '\n' : sell_label

lab_sell = label.new(bar_index+10, close, sell_label, color=color.new(color.red,70), textcolor=color.white, style=label.style_label_down, yloc=yloc.price,textalign=text.align_left)
label.delete(lab_sell[1])
//========================================================================


Video Tutorial :-




Comments

  1. I pasted the entire code in paid TradingView. It is accepted and shown as added to chart. But it is not showing up the List. I tried changing screening condition as ' rsi>50 and rsi<50' so that the either of the lists shall not turn empty. Would you please tell what can be the issue?

    ReplyDelete

Post a Comment

Popular posts from this blog

Import Chartink data into Python

Import Nifty Option Chain With Python