Using Zerodha Pi Scanner Code for Intraday Alert

Zerodha Pi Scanner Code

Zerodha provides trading software named Zerodha Pi to clients who wish to trade through it. Though Zerodha has another web trading platform, KitePi is preferred by many because of the unique advantages which are inbuilt into the software. The most attractive feature Pi comes with is the scanner. The scanner runs on simple programming code popularly known as Zerodha Pi scanner code or the TradeScript code. There is a big array of codes in the archive for simple or complex strategies to be employed for the scanner or auto trade.

A few months back Zerodha introduced Zerodha Pi scanner in their Pi terminal. The scanner is especially helpful in getting trading alerts in live markets. Let’s discuss how we can successfully use the Zerodha Pi scanner in generating real-time trade alerts and make out trading semi-automated.

What is the Usage of a Stock Scanner?

A stock scanner OR screener can save a lot of time for a trader. Suppose you have a list of 50 stocks and you want to know in which scrips the 20 moving average crosses over the 50 moving average. You have 2 choices:

  1. Inspect each chart every now and then OR
  2. Create a scanner that will send you trading alerts when the moving average crossover happens in any scrip.

Few Zerodha Pi Scanner Code

Zerodha Pi scanner is a powerful tool for intraday traders as well. Today we are going to discuss a few codes written in TradeScript (the programming language employed by Zerodha for scanner and auto-trade). These Zerodha Pi scanner codes or TradeScript codes will come of immense help to the traders. Using these codes one can instantly know which stock is performing the way one would like it to or which stock is preparing for the next move. However, the only prerequisite for using these codes is a basic knowledge of technical analysis.

Tradescript Codes

Moving Average Crossover

It is a popular method of determining the trend.  SMA or a simple moving average of closing prices of two different time frames are compared to get an overview of the price trend. The code is as follows.

SET MA1 = SimpleMovingAverage(Close, 28)

SET MA2 = SimpleMovingAverage(Close, 14)

CROSSOVER(MA2, MA1) = TRUE. In this code, the scanner will notify when the shorter moving average of any stock price in any time frame crosses over the longer moving average indicating a bullish crossover/ trend. The opposite code i.e. CROSSOVER(MA1, MA2) = TRUE will denote the opposite trend. Otherwise speaking if one buys a stock at a bullish crossover signal, the opposing signal defines the time for exit and vice versa.  MA parameter can be of one’s own choice.

MACD (Moving Average Convergence Divergence)

MACD shows potential overbought/ oversold condition. The Zerodha Pi scanner code or Tradescript codes for MACD is;

Long Cycle: 26
Short Cycle: 13
Signal Periods: 9
MA Type: SIMPLE (recommended parameters)
Code –
SET A = MACDSignal(13, 26, 9, SIMPLE)
SET B = MACD(13, 26, 9, SIMPLE)
CROSSOVER(A, B) = TRUE. The signal holds true if MACD crosses the signal line indicating a bullish crossover.

Stochastic Oscillator

This indicator has two components, %K and %D. A simple rule is to buy when the oscillator rises above 80 0r %K>%D and sell when it falls below 20 or %K<%D.

% K Periods: 9
% K Slowing Periods: 3
And % D Periods: 9
MA Type: SIMPLE (recommended parameters)
Example
SOPK(9, 3, 9, SIMPLE) > 80 OR SOPD(9, 3, 9, SIMPLE) > 80.

There are many effective Zerodha Pi scanner codes or TradeScript codes which are beneficial to traders. Let us pictorially see how to write a simple Zerodha Scanner Code like Open = Low.

Step-by-Step Guide to Creating a Zerodha Pi Scanner Code

Open and log in to Zerodha Pi. We will create a simple scanner that will alert us if the open and low of any Nifty 50 stocks are the same. We can load the Nifty 50 stocks market watch from File –> Predefined Workspace –> NSE –> Nifty 50.

Create a New Scanner

Now create a new scanner, click Alerts –> Scanner.

Zerodha Scanner

Give the scanner name OPEN = LOW and write this script inside OPEN = LOW. Say we will check open and low same in 4 hours candle. Hence select Periodicity = Hour and Bar Interval = 4, select Days = 1 and click on Add Symbols.

Create New Scan

Choose the Stock Group to Scan

We will be scanning from Nifty 50 index stocks. Hence in Add Symbol window select Default Symbols and from the dropdown menu select Nifty 50. Click on add.

Zerodha Pi Scanner Code

This will show OPEN = LOW 51 symbols loaded. Now click on OK. This will create the scanner, but the scanner is not yet running as we have not loaded it. Therefore, click on load and this will load the symbols.

Open Low Same Scanner

The Final Scanner

Now as and when a scrip’s open and low will be the same in any candle the Zerodha Pi scanner will highlight the scrip in yellow and will generate trading alerts. I have tested the OPEN = LOW scanner on 15-minute candles. I got the YESBANK share in the result.

Zerodha Scanner Symbols

You can open the charts OR trade from the scanner window. We just opened the chart and checked YESBANK last 15 minutes candle OPEN = LOW logic is fulfilled. Check the image below:

Trading Alerts from Zerodha

Open a Chart or Initiate a Trade

You can open the charts OR trade from the scanner window. We just opened the chart and checked YESBANK last 15 minutes candle OPEN = LOW logic is fulfilled. Check the image below:

Yes Bank Chart

Writing Similar Zerodha Pi Scanner Code

In the same way, you can also write a scanner code open high same formula and scan for the open high low same strategy.

You can check my video above to have a complete understanding of how to create a Zerodha scanner to get trading alerts. Your comments will be welcome in the comment box below.

Conclusion

In this post, we have discussed the Zerodha Pi Scanner code and how we can create market time alerts with it. However, Zerodha has discontinued support for their Pi platform. Hence, this idea is now obsolete. Readers can use services like Zerodha Sentinel to generate alerts during market hours.

Visited 268 times, 1 visit(s) today

Author: Indrajit Mukherjee

Indrajit is a professional blogger and trading system developer. Amibroker expert, Wordpress expert, SEO expert and stock market analyst.Trading since 2002, he has started the journey of StockManiacs.net on 2008. He follows Indian and world stock markets closely. Nowadays, he is also taking help of artificial intelligence for writing valuable contents for his readers.

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

23 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Ramesh Rao

very nice video sir. I want to know how to access to download profit making from ichimoko clouds. when i press the down load botton below this it is not downloading.

thanks

Ashish Majumdar

Hi Sri I am Ashim Majumdar newe investors pl help me

Geeta Makwana

i have opened new A/c with Zerodha through you…i m new.. how to start trade ?This is my beginning so only for some days, can you give meexact instruction for intra day what and when buy and sale……thanks …Geeta

Rakesh G R

Hi Sir,
Please tell me the codes for generating alert in scanner
1. Buy when LTP crosses 5 days high.

Thanks
Rakesh G R

Sachin Bal

Hi,

How do we code open = low and open = high in a scanner in zerodha. What is the periodicity , the bar interval and the number of days which we need to select?

I was trying with periodicity as “minute” and bar interval as “1” and Days as “1” but it was not giving me the correct result. Can you please guide?

Thanks
Sachin

Sachin Bal

Ok. Thanks. I will try this out tomorrow.

Sachin Bal

Dear Indrajit,

Sorry to say that the hourly candle after 5 minutes of market opening up does not work 🙁

Do you have any other suggestions?

Thanks
Sachin

Sachin Bal

So, if I understand correctly, you are suggesting that I should get the open, high, low data from zerodha into excel and then use the strategy? correct? Should i get the data after 5 minutes of market opening up or more than that? Please advise

Thanks
Sachin

dilip k sharma

i want to create 1 day scanner in zerodha PI while only MINUTE and HOUR option is shown. 8 hours selection is not working.

Umesh

Indrajit Sir, after creating the scanner when I logout from pi, on next login I am unable to see my scanners. Can you guide on this?

Jayesh

hi, i m looking for a scrip, open=low and also open>previous days close, i am getting individual scrip but when i combine it doesnt work, can you please let me know how to do it. it should match both conditions to generate an alert.

Jayesh

Thanks for your reply. Also i want to know that, can i punch automatic orders from that, like say 4 conditions i put and if matches it should punch auto orders becoz morning trades are so quick by the time i search for right scripts, tgt is already done in first 5 to 15 min candle mostly. or any other way possible? how to write afl in ami broker say for 4 conditions to match and all… as mentioned above….

Nityanand Prasad

How to save screener in pi.

Arpan jain

hi..

23
0
Would love your thoughts, please comment.x
()
x