Zerodha Pi Scanner Code Examples (TradeScript Codes)

Zerodha provides a trading software named Zerodha Pi to the clients who wish to trade through it. Though Zerodha has other 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 autotrade.

Zerodha Pi scanner is a powerful tool for intraday traders as well. Today we are going to discuss few codes written in TradeScript (programming language employed by Zerodha for scanner and autotrade). These Zerodha Pi scanner code or TradeScript codes will come to 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. The only prerequisite for using these codes is the basic knowledge of technical analysis.

tradescript codes1. 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)

Join Our Team For Rocket Calls

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 bullish crossover signal, the opposing signal defines the time for exit and vice versa.  MA parameter can be of one’s own choice.

2. 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 MACD crosses signal line indicating a bullish crossover.

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

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

There are many effective Zerodha Pi scanner code or TradeScript codes which are beneficial to traders. Kindly visit our Zerodha Pi scanner page for more efficient use of the scanner.

Categories: Zerodha

Tags: , , ,

2 replies

  1. I am not able to use variables in the scanner. Also it seems to be taking only single line code instructions. Whenever I try setting variables like using “Set” or multiline instruction it gives an error.

    Not sure if that’s the correct behavior


Leave a Reply

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

Do you want at least RS. 5000 PROFITS EVERYDAY?YES, I WANT