TradingView is a hugely popular stock charting platform. It comes bundled with hundreds of technical indicators and many are contributed by the community. I use it regularly for my stock analysis.
In addition to charting, TradingView also has a Screener that allows us to filter stocks based on our custom criteria.
In the above example, we are looking for stocks whose Markert Cap is greater than equal to Rs.10 Billion, 5 year Beta is greater than 1 and Price is just above the 21-EMA.
These filtering parameters are predetermined and as long as our criteria are in this list, it will serve our purpose. No doubt this is quite useful most of the time.
Screeners such as ChartInk and Screener come with their own powerful expression languages for specifying filtering criteria. These tools give us greater control over screening stocks. Here is an example from ChartInk:
This looks for stocks whose last day’s Close is at least 5% more than the Open. The following stocks match that criteria.
It is only recently that TradingView introduced its “Pine Screener” (currently in Beta) that makes it possible to implement arbitrary filtering logic in Pine Script. To go into this mode, we have to select “Screeners > Pine” from the TradingView Products menu.
In order for the Pine Script to be available in the screener, we have to include the indicator in the “Favorites” list.
Here is a sample script.
This toy script contains three “plot()” functions and one “alertcondition()” function. Let us open this indicator in the Pine screener.
I am using my “Nifty-100” watchlist. This contains the top 100 (actually 96) companies in Nifty 100. This can be any list of yours. The “Indicator” drop down shows that I have opened my sample screener for filtering stocks from the Nifty-100 list. Notice that, by default, the three plots and the alert condition in the script are displayed. The “+” button allows us to add other plots/alerts that might be in our script (in this case there is nothing else).
Let us set our first filter condition: All stocks whose Close has just crossed above 21 EMA.
After setting this, we click “Scan”. This applies the condition on our watch list and we get 12 stocks that match.
Next, we add another condition: Only those stocks whose last day volume exceeds 1 million.
This filter reduces the number of stocks to 7.
Our final filter condition is to select those stocks whose Close >= 200 and Close <= 4000.
Here is the final filtered result.
There are only 4 stocks in this list.
Note that “alertcondition” appears with “True” option that can be enabled or reset. For “plot” elements, the actual values need to be specified.
One important point to keep in mind is that the filter conditions are “AND”ed, not “OR”ed. That is, all the conditions must be met for a stock to be in the final result. This might appear restrictive, but since we have full control over defining the conditions within Pine Script, we can implement complex logic with minimal effort.
Hope TradingView releases the final version soon, with more capabilities.
You can download the Sample code from here.
Have a nice week!












Recent Comments