NSE/BSE Derivative - Next Expiry Date With HolidaysNSE & BSE Expiry Tracker with Holiday Adjustments
This Pine Script is a TradingView indicator that helps traders monitor upcoming expiry dates for major Indian derivative contracts. It dynamically adjusts these expiry dates based on weekends and holidays, and highlights any expiry that falls on the current day.
⸻
Key Features
1. Tracks Expiry Dates for Major Contracts
The script calculates and displays the next expiry dates for the following instruments:
• NIFTY (weekly expiry every Thursday)
• BANKNIFTY, FINNIFTY, MIDCPNIFTY, NIFTYNXT50 (monthly expiry on the last Thursday of the month)
• SENSEX (weekly expiry every Tuesday)
• BANKEX and SENSEX 50 (monthly expiry on the last Tuesday of the month)
• Stocks in the F&O segment (monthly expiry on the last Thursday)
2. Holiday Awareness
Users can input a list of holiday dates in the format YYYY-MM-DD,YYYY-MM-DD,.... If any calculated expiry falls on one of these holidays or a weekend, the script automatically adjusts the expiry to the previous working day (Monday to Friday).
3. Customization Options
The user can:
• Choose the position of the expiry table on the chart (e.g. top right, bottom left).
• Select the font size for the expiry table.
• Enable or disable the table entirely (if implemented as an input toggle).
4. Visual Expiry Highlighting
If today is an expiry day for any instrument, the script highlights that instrument in the display. This makes it easy to spot significant expiry days, which are often associated with increased volatility and trading volume.
⸻
How It Works
• The script calculates the next expiry for each index using built-in date/time functions.
• For weekly expiries, it finds the next occurrence of the designated weekday.
• For monthly expiries, it finds the last Thursday or Tuesday of the month.
• Each expiry date is passed through a check to adjust for holidays or weekends.
• If today matches the adjusted expiry date, that row is visually emphasized.
⸻
Use Case
This script is ideal for traders who want a quick glance at which instruments are expiring soon — especially those managing options, futures, or expiry-based strategies.