OPEN-SOURCE SCRIPT

5EMA BollingerBand Nifty Stock Scanner

Actualizado

What ?

We all heard about (well: over-heard) 5-EMA strategy. Which falls into the broader category of mean reversal type of trading setup.

What is mean reversal?

Price (or any time series, in fact) tries to follow a mean. Whenever price diverges from the mean it tries to meet it back.
It is empirically observed by some traders (I honestly don't know who first time observed it) that in Indian context specially, 5 Exponential Moving Average (5-EMA) works pretty good as that mean.
So whenever price moves away from that 5-EMA, it ultimately comes back and attain total nirvana :) Means: if price moved way higher than the 5EMA without touching it, then price will correct to meet it's 5-EMA and if price moved way lower, it will be uplifted to meet it's 5-EMA. Funny - but it works!

Now there are already enough social media coverage on this 5-EMA strategy/setup. Even TradingView has some excellent work done on these setups. Kudos to all those great souls.

So when we came to know about this, we were thinking what we should do for the community. Because it is well cover topic (specially in Indian context). Also, there are public indicators.
Then we thought why not come up with a scanner which will scan all the Nifty-50 constituent stocks and find out on the fly, real-time which all stocks are matching this 5-EMA setup and causing a Buy/Sell trade recommendation.

Hence here we are with the first version of our first scanner on the 5EMA setup (well it has some more masala than merely a 5-EMA setup).


Why?

Parts of why is already covered up.
Now instead of blindly following 5-EMA setup, we added the Bollinger band as well. Again: it's also not new. There are enough coverage in social media about the 5-EMA+BB strategy/setup. We mercilessly borrowed from all of these.

Suppose you have an indicator.

Now you apply the indicator in your chart. And then you need to (rock) and roll through your watchlist of Nifty-50 stocks (note: TradingView has no default watchlist of Nifty-50 stock by default - you have to create one custom watchlist to list all manually) to find out which all are matching the setup, need to take a note about the trade recomendations (entry, SL, target) and other stuffs like VWAP, Volume, volatility (Bollinger Band Width).

Not any more.

This scanner will track all the Nifty-50 stocks (technically: 40 stocks other than Banking stocks) and provide which one to Buy or Sell (if any), what's the entry, SL, target, where is the VWAP of the day, what's the picture in volume (high, low, rising, falling) and the implied volatility (using Bolling band width). Also it has a naive alerting mechanism as well.

In fact the code is there to monitor the (Future) OI also and all the OI drama (OI vs price and all the 4 stuffs like long build up, long unwinding, short covering, short buildup). But unfortunately, due to some limitations of the TradingView (that one can not monitor more than 40 `ta.security` call) we have to comment out the code. If you wish you can monitor only 20 stocks and enable the OI monitoring also (20 for stocks + 20 for their OI monitoring .. total 40 `ta.security` call).


How?

To know the divergence from 5-EMA we just check if the high of the candle (on closing) is below the 5-EMA. Then we check if the closing is inside the Bollinger Band (BB). That's a Buy signal. SL: low of the candle, T: middle and higher BB.

Just opposite for selling. 5-EMA low should be above 5-EMA and closing should be inside BB (lesser than BB higher level). That's a Sell signal. SL: high of the candle, T: middle and lower BB.

Along with we compare the current bar's volume with the last-20 bar VWMA (volume weighted moving average) to determine if the volume is high or low.
Present bar's volume is compared with the previous bar's volume to know if it's rising or falling.

VWAP is also determined using `ta.vwap` built-in support of TradingView.

The Bolling Band width is also notified, along with whether it is rising or falling (comparing with previous candle).

Simple, but effective.


Customization

As usual the EMA setup (5 default), the BB setup (20 SMA with 1.5 standard deviation), we provided option wherther to include or exclude BB role in the 5-EMA setup (as we found out there are two schools of thought .. some people use BB some don't. Lets make all happy :))

We also provide options to choose other symbols using Settings if they wish so. We have the default 40 non banking Nifty stocks (why non-banking? - Bank Nifty is in ATH :) .. enough :)). But if user wishes can monitor others too (provided the symbol is there in TradingView).

Although we strongly recommend the timeframe as 30 minutes , you can choose what's fit you most.

The output of the scanner is a table. By default the table is placed in the right-bottom (as we are most comfortable with that). However you can change per your wish. We have the option to choose that.

What is unique in it ?

This is more of an indicator. This is a scanner (of Nifty-50 stocks). So you can apply (our recommendation is in 30m timeframe) it to any chart (does not matter which chart it is) and it will show every 30 mins (which is also configurable) which all stocks (along with trade levels) to Buy and Sell according to the setup.
It will ease your trading activity.
You can concentrate only on the execution, the filtering you can leave it to this one.


Limitations
  • There is a build in limitation of the TradingView platform is that one can call only upto 40 securities API. Not beyond that. So naturally we are constraint by that. Otherwise we could monitor 190 Nifty F&O stocks itself.
  • 30m is the recommended timeframe. In very lower (say 5m) this script tends to go out of heap (out of memory). Please note that also.



How to trade using this?


* Put any chart in 30m (recommended) timeframe.
* Apply this screener from Indicators (shortcut to launch indicators is just type / in your keyboard).
* This will provide the Buy (shown in green color) or Sell (shown in red color) recommendations in a table, at every 30m candle closing.
* Note the volume and BB width as well.
* Wait for at least 2 5-minutes candles to close above/below the recommended level.
* Take the trade with the SL and target mentioned.


Mentions

  • @QuantNomad. The whole implementation concept we mercilessly borrowed from him, even some of his code snippet we took it (after asking him through one of his videos comment section and seeking explicit permission which he readily granted within an hour). Thank You sir @QuantNomad. Indebted to you.
  • Monika (Rawat) ji: for reviewing, correcting, providing real time examples during live market hours, often compromising her own trading activities, about the effectiveness and usefulness of this setup. Thank You madam ji. Indebted to you.
  • There are innumerable contents in social media about this. Don't even know whom all we checked. Thanks to all of them.


Happy Trading (in stocks - isn't enough of Indices already?)


Disclaimer

* This piece of software does not come up with any warrantee or any rights of not changing it over the future course of time.
* We are not responsible for any trading/investment decision you are taking out of the outcome of this indicator.


Notas de prensa
Updated after fixing the alerts as people are using it, hence getting the SL and T in alert itself makes sense.
Some minor defects fixing also done.
Notas de prensa
A couple of fixes:
  1. The change in Nifty constituent (HDFC is now out) has been fixed for default run.
  2. A new setting provided to set the alert message start (to get it linked to other social media like TG, X etc.).
  3. Minor cosmetic fix.


Note
Please note: this is for 30m timeframe (stock) and one needs to set it in the chart and wait for the next 30m candle to close to get it reflected.
If and only if some stocks of Nifty satisfy the scanner criteria as mentioned in the description above - only then it will show up in the table (default position: bottom right of the chart, can be customizable by `tablepos`.

5emastrategyBollinger Bands (BB)bollingerbandstrategyExponential Moving Average (EMA)indianstockmarketscreenerstockscreenerVolume Weighted Average Price (VWAP)

Script de código abierto

Siguiendo fielmente el espíritu de TradingView, el autor de este script lo ha publicado en código abierto, permitiendo que otros traders puedan entenderlo y verificarlo. ¡Olé por el autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la reutilización de este código en la publicación se rige por las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

¿Quiere utilizar este script en un gráfico?


También en:

Exención de responsabilidad