OPEN-SOURCE SCRIPT
Stock Highs Tracker with Indices

This Pine Script indicator tracks stock highs and compares them with major indices (Nifty, Nifty 500, CNX-SmallCap, and CNX-MidCap). Here’s what it does:
1. Retrieves and Displays Key Price Metrics
All-Time High (ATH): The highest price the stock has ever reached.
52-Week High: The highest price in the last 252 trading days.
Current Price: The stock’s closing price.
2. Calculates Percentage Differences
% from ATH: How much the stock is below its all-time high.
% from 52WKH: How much the stock is below its 52-week high.
3. Fetches and Compares with Indices
It retrieves similar metrics (ATH, 52-Week High, Current Price, % from ATH, % from 52WKH) for:
Nifty 50
Nifty 500
CNX-SmallCap
CNX-MidCap
This helps in assessing whether the stock's movement aligns with broader market trends.
4. Displays Data in a Table
The script creates a table positioned at the top-right corner.
It color-codes different rows for easy readability.
The table compares the stock’s performance against the major indices.
Use Case
Helps traders and investors track stock highs relative to market indices.
Identifies whether the stock is outperforming or underperforming the broader market.
1. Retrieves and Displays Key Price Metrics
All-Time High (ATH): The highest price the stock has ever reached.
52-Week High: The highest price in the last 252 trading days.
Current Price: The stock’s closing price.
2. Calculates Percentage Differences
% from ATH: How much the stock is below its all-time high.
% from 52WKH: How much the stock is below its 52-week high.
3. Fetches and Compares with Indices
It retrieves similar metrics (ATH, 52-Week High, Current Price, % from ATH, % from 52WKH) for:
Nifty 50
Nifty 500
CNX-SmallCap
CNX-MidCap
This helps in assessing whether the stock's movement aligns with broader market trends.
4. Displays Data in a Table
The script creates a table positioned at the top-right corner.
It color-codes different rows for easy readability.
The table compares the stock’s performance against the major indices.
Use Case
Helps traders and investors track stock highs relative to market indices.
Identifies whether the stock is outperforming or underperforming the broader market.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.