Zerodha PI script to check for better performing index

Wanted some help with writing script for:

Write a alert tradescript that will run in Zerodha

Generate an alert on a daily 1 minute timeframe when 1) 2) and 3) below are satisfied:

  1. At any point of time, check for any stock trading in NSE under Nifty 50 whose LTP as compared to Close price 15 minutes back >0.5%
  2. The stock which is being checked is a part of an NSE sector. eg. SBIN is a part of NIFTY PSU BANK. Check the if 90% of other stocks in the same sector is trading with LTP as compared to Close price 15 minutes back >0.5%. This means if the sector contains 12 stocks, and 8 stocks show a behaviour of LTP as compared to Close price 15 minutes back >0.5%, then the percentage of socks trading in the same sector with this condition is 0.66% and will result in a false condition. If 11/12 stocks would be trading with the above condition then only this will evaluated to true
  3. Check if LTP>EMA(10)

If all the above are true generate an alert - Thats it

1 Like

For the above condition you can use scanner with below script

LAST > REF(CLOSE,)*1.005

For the EMA


Thx, But how do I code 2) above. To understand how many of the individual sector stocks are trading above 0.5% of their close that was 15 minutes back?

Hi Sir
i have the same question that you have posted. Did you find script code for the same?

No, not possible in pi.

hi sir i need script code for , last two week high breakout for buy and last two week low breakout for sell