OPEN-SOURCE SCRIPT

S&P 2024: Magnificent 7 vs. the rest of S&P

由omnibus提供
This chart is designed to calculate and display the percentage change of the Magnificent 7 (M7) stocks and the S&P 500 excluding the M7 (Ex-M7) from the beginning of 2024 to the most recent data point. The Magnificent 7 consists of seven major technology stocks: Apple (AAPL), Microsoft (MSFT), Amazon (AMZN), Alphabet (GOOGL), Meta (META), Nvidia (NVDA), and Tesla (TSLA). These stocks are a significant part of the S&P 500 and can have a substantial impact on its overall performance.

Key Components and Functionality:

1. Start of 2024 Baseline:
- The script identifies the closing prices of the S&P 500 and each of the Magnificent 7 stocks on the first trading day of 2024. These values serve as the baseline for calculating percentage changes.

2. Current Value Calculation:
- It then fetches the most recent closing prices of these stocks and the S&P 500 index to calculate their current values.

3. Percentage Change Calculation:
- The script calculates the percentage change for the M7 by comparing the sum of the current prices of the M7 stocks to their combined value at the start of 2024.
- Similarly, it calculates the percentage change for the Ex-M7 by comparing the current value of the S&P 500 excluding the M7 to its value at the start of 2024.

4. Plotting:
- The calculated percentage changes are plotted on the chart, with the M7’s percentage change shown in red and the Ex-M7’s percentage change shown in blue.

Use Case:

This indicator is particularly useful for investors and analysts who want to understand how much the performance of the S&P 500 in 2024 is driven by the Magnificent 7 stocks compared to the rest of the index. By showing the percentage change from the start of the year, it provides clear insights into the relative growth or decline of these two segments of the market over the course of the year.

Visualization:

- Red Line (M7 % Change): Displays the percentage change of the combined value of the Magnificent 7 stocks since the start of 2024.
- Blue Line (Ex-M7 % Change): Displays the percentage change of the S&P 500 excluding the Magnificent 7 since the start of 2024.

This script enables a straightforward comparison of the performance of the M7 and Ex-M7, highlighting which segment is contributing more to the overall movement of the S&P 500 in 2024.
Portfolio managementsentimentstatistics

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明