This is the pine script which calculate the nifty 50 .
Take each stock contribute to nifty 50 and find it's .
Multiply the same with contribution percentage of the same on Nifty 50
Add up all of them and find the total .
I took the open source code from @daytraderph script called, Custom
I will make sure I will update the contribution percentage of all stocks my self instead o you update using input methods. This is the difference. Some people don't know where to look at this to update the value, so for them this script might be useful. And this is the only difference comparing to Custom script.