OPEN-SOURCE SCRIPT
Market Breadth & Sector Rotation Analyzer -[KK]

A real-time market environment analyzer for NSE India built for swing traders and breakout traders.
Designed to answer one question before every trade: Should I take this trade today?
What This Indicator Does
Analyzes 33 NSE indices across market cap, sectors, themes, and volatility to deliver a complete snapshot of current market health, sector rotation, and risk conditions. Shows only live conditions with no historical clutter.
Market Breadth Score 0–100
Composite score based on 30 percent market cap breadth, 40 percent sector breadth using 19 sectors above 50 MA, 25 percent long-term momentum using 200 MA, and 5 percent India VIX for volatility and fear assessment.
Actionable Trading Guidance
Automatically classifies market regime as Bull, Trending, Neutral, or Bear. Provides clear trade guidance, position sizing recommendations, and sector focus based on current market conditions.
Sector Rotation Analysis
Groups sectors into five mega sectors.
Financial: Banks, Private Banks, PSU Banks, Finance, Financial Services
Technology: IT, Services, Media
Cyclical: Auto, Metal, Realty, Infra, Energy, Oil and Gas
Defensive: FMCG, Pharma, Healthcare
Consumer: Consumer Durables, Consumption
Market Phase Detection
Identifies Expansion, Recovery, Defensive, Contraction, or Rotation phases based on sector leadership. Helps align trades with the broader economic cycle.
Trading Rules by Market Breadth
75 to 100: Bull market, trade all quality setups with full position size
60 to 75: Trending market, selective trades with normal size
40 to 60: Neutral market, very selective trades with 50 percent size
Below 40: Bear market, raise cash and use minimal exposure
Sector Strength Interpretation
Above 80 percent: Leading sector, trade aggressively
60 to 80 percent: Strong sector, good opportunities
40 to 60 percent: Weak sector, be selective
Below 40 percent: Avoid or use minimal exposure
Defensive Sector Logic
High defensive strength signals fear, not strength. Defensive above 70 percent with weak technology indicates market topping. Defensive below 40 percent indicates a risk-on environment.
Indices Covered
Market Cap: NIFTY, CNX100, CNX500, NIFTY Total Market, NIFTY Midcap 150, CNX Midcap, NIFTY Mid Small 400, NIFTY Small-cap 250, NIFTY 500 Multicap, NIFTY IPO
Banking and Finance: BANKNIFTY, NIFTY Private Bank, CNX PSU Bank, CNX Finance, NIFTY Fin Service 25 50
Technology: CNX IT, CNX Service, CNX Media
Cyclicals: CNX Auto, CNX Metal, CNX Realty, CNX Infra
Energy: CNX Energy, NIFTY Oil and Gas, CPSE
Defensives: CNX FMCG, CNX Pharma, NIFTY Healthcare
Consumer: NIFTY Consumer Durables, CNX Consumption
Thematic: NIFTY MNC, NI15
Volatility: India VIX
Market Alerts
Bull Market alert when breadth crosses above 75
Bear Market alert when breadth drops below 40
Broad Rally alert when more than 75 percent of sectors are bullish
Settings
Table position with 9 placement options, table size from Tiny to Large, customizable short and long moving averages. Default settings are Top Right position, Normal size, 50 MA and 200 MA.
Best Useful Script for
Ideal for swing traders, breakout traders, position traders, and NSE equity traders who need market context before taking trades. Not suitable for scalping, day trading, or non-NSE markets.
Disclaimer
This indicator is for educational purposes only and does not constitute any kind of financial advice to buy/sell any financial securities.
Trading involves risk and past performance does not guarantee future results.
Designed to answer one question before every trade: Should I take this trade today?
What This Indicator Does
Analyzes 33 NSE indices across market cap, sectors, themes, and volatility to deliver a complete snapshot of current market health, sector rotation, and risk conditions. Shows only live conditions with no historical clutter.
Market Breadth Score 0–100
Composite score based on 30 percent market cap breadth, 40 percent sector breadth using 19 sectors above 50 MA, 25 percent long-term momentum using 200 MA, and 5 percent India VIX for volatility and fear assessment.
Actionable Trading Guidance
Automatically classifies market regime as Bull, Trending, Neutral, or Bear. Provides clear trade guidance, position sizing recommendations, and sector focus based on current market conditions.
Sector Rotation Analysis
Groups sectors into five mega sectors.
Financial: Banks, Private Banks, PSU Banks, Finance, Financial Services
Technology: IT, Services, Media
Cyclical: Auto, Metal, Realty, Infra, Energy, Oil and Gas
Defensive: FMCG, Pharma, Healthcare
Consumer: Consumer Durables, Consumption
Market Phase Detection
Identifies Expansion, Recovery, Defensive, Contraction, or Rotation phases based on sector leadership. Helps align trades with the broader economic cycle.
Trading Rules by Market Breadth
75 to 100: Bull market, trade all quality setups with full position size
60 to 75: Trending market, selective trades with normal size
40 to 60: Neutral market, very selective trades with 50 percent size
Below 40: Bear market, raise cash and use minimal exposure
Sector Strength Interpretation
Above 80 percent: Leading sector, trade aggressively
60 to 80 percent: Strong sector, good opportunities
40 to 60 percent: Weak sector, be selective
Below 40 percent: Avoid or use minimal exposure
Defensive Sector Logic
High defensive strength signals fear, not strength. Defensive above 70 percent with weak technology indicates market topping. Defensive below 40 percent indicates a risk-on environment.
Indices Covered
Market Cap: NIFTY, CNX100, CNX500, NIFTY Total Market, NIFTY Midcap 150, CNX Midcap, NIFTY Mid Small 400, NIFTY Small-cap 250, NIFTY 500 Multicap, NIFTY IPO
Banking and Finance: BANKNIFTY, NIFTY Private Bank, CNX PSU Bank, CNX Finance, NIFTY Fin Service 25 50
Technology: CNX IT, CNX Service, CNX Media
Cyclicals: CNX Auto, CNX Metal, CNX Realty, CNX Infra
Energy: CNX Energy, NIFTY Oil and Gas, CPSE
Defensives: CNX FMCG, CNX Pharma, NIFTY Healthcare
Consumer: NIFTY Consumer Durables, CNX Consumption
Thematic: NIFTY MNC, NI15
Volatility: India VIX
Market Alerts
Bull Market alert when breadth crosses above 75
Bear Market alert when breadth drops below 40
Broad Rally alert when more than 75 percent of sectors are bullish
Settings
Table position with 9 placement options, table size from Tiny to Large, customizable short and long moving averages. Default settings are Top Right position, Normal size, 50 MA and 200 MA.
Best Useful Script for
Ideal for swing traders, breakout traders, position traders, and NSE equity traders who need market context before taking trades. Not suitable for scalping, day trading, or non-NSE markets.
Disclaimer
This indicator is for educational purposes only and does not constitute any kind of financial advice to buy/sell any financial securities.
Trading involves risk and past performance does not guarantee future results.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.