OPEN-SOURCE SCRIPT
Mis à jour MGI & Momentum Trend

The suite of indicators plotted here serves as an analytical foundation for capturing market "structure" from multiple perspectives. They are designed to facilitate everything from a broad assessment of the market environment based on weekly charts to precise, tactical entry decisions using daily charts.
Below is an explanation of the logic and role of each indicator, along with guidance on adapting them to market conditions.
This system is designed to deliver its full value when customized by the user to suit changing market environments and the specific characteristics of the assets being monitored.
The display is primarily based on weekly charts, with daily charts used as needed.
MarketGoingIndex (MGI) – Macro Liquidity Environment
Look for buying opportunities when the background indicator lights up while the purple line is rising.
Purpose:
This indicator utilizes the yield spread between US junk bonds and US Treasury bonds—one of the metrics most strongly inversely correlated with capital inflows into the stock market (risk-on sentiment). This spread widens sharply when large-scale investors become anxious about the economic outlook. By calculating the "cumulative 4-week momentum" of this spread and inverting the result, we create a leading indicator for the stock market.
Logic:
It is based on the credit spread of US high-yield bonds (junk bonds). A widening spread signifies rising credit risk, while a narrowing spread indicates abundant liquidity.
Role of the Index:
By calculating the "cumulative change" in the spread, it visualizes the direction of capital flow (risk-on vs. risk-off).
Usage (Market Adaptation):
For the US market: It functions using the default settings. Another suitable alternative is FRED:BAA10Y (Moody's Seasoned Baa Corporate Bond Yield Relative to Yield on 10-Year Treasury). Major recessions like the COVID-19 crash (where stock prices drop by nearly 20%) often occur in years ending in "9" or "0" and during the first or second year of a U.S. presidential term. In such cases, it is more effective to gauge the timing of a market bottom reversal by using indicators that offer stronger leading signals for recessions than the standard 10-year/2-year spread—specifically, the spread between 10-year and 3-month Treasury yields (FRED:T10Y3M), which the Federal Reserve prioritizes.
During major recessions like the COVID-19 crash, the FRED:BAMLH0A0HYM2 indicator is too slow to react.
Image
Focus on short-term Treasury yields, to which the Fed is likely to respond quickly (using the FRED:T10Y3M setting).
For the Japanese market: Since it is highly correlated with the U.S. market, I recommend using this as a leading indicator while also monitoring the momentum of the USD/JPY exchange rate and trends in the Nikkei 225 Volatility Index (NI225VI) for supplementary analysis.
2.Intermediate Trend Background Signal (A/D Difference)
Logic:
Uses the SMA of the Advance/Decline (A/D) line to indicate market overheating and trend direction via the background color.
Role:
An indicator that measures market "breadth." Areas with background coloring suggest the market is in an overheated zone with a clear trend.
Operation (Adjustment Method):
Thresholds (-1000, -1500) vary depending on the liquidity of the target market.
If the background color does not appear when you want it to, make the threshold looser (closer to 0).
If there is too much noise, adjust the threshold to be stricter (increase the negative value).
System Usage Workflow
Broad Perspective (Weekly Chart):
Check the capital environment using MGI and assess market "heat" via the background color. When the background turns green or pink, it indicates a phase requiring special attention.
Tactical Decision (Daily Chart):
Check the direction of the VStop line and the price position; consider trend-following trades aligned with the direction seen on the weekly chart.
Temporal Edge (Seasonality Chart):
Check where the current price stands relative to historical anomalies to increase your confidence when buying dips or selling rallies.
Key Points for Use
This system does not provide a single "answer"; rather, it is a tool to assist you in interpreting the current market environment. If you find yourself wondering, "Why did the background color appear but the price didn't follow suit?", try fine-tuning the parameters mentioned above.
Please make investment decisions calmly and at your own risk.
Below is an explanation of the logic and role of each indicator, along with guidance on adapting them to market conditions.
This system is designed to deliver its full value when customized by the user to suit changing market environments and the specific characteristics of the assets being monitored.
The display is primarily based on weekly charts, with daily charts used as needed.
MarketGoingIndex (MGI) – Macro Liquidity Environment
Look for buying opportunities when the background indicator lights up while the purple line is rising.
Purpose:
This indicator utilizes the yield spread between US junk bonds and US Treasury bonds—one of the metrics most strongly inversely correlated with capital inflows into the stock market (risk-on sentiment). This spread widens sharply when large-scale investors become anxious about the economic outlook. By calculating the "cumulative 4-week momentum" of this spread and inverting the result, we create a leading indicator for the stock market.
Logic:
It is based on the credit spread of US high-yield bonds (junk bonds). A widening spread signifies rising credit risk, while a narrowing spread indicates abundant liquidity.
Role of the Index:
By calculating the "cumulative change" in the spread, it visualizes the direction of capital flow (risk-on vs. risk-off).
Usage (Market Adaptation):
For the US market: It functions using the default settings. Another suitable alternative is FRED:BAA10Y (Moody's Seasoned Baa Corporate Bond Yield Relative to Yield on 10-Year Treasury). Major recessions like the COVID-19 crash (where stock prices drop by nearly 20%) often occur in years ending in "9" or "0" and during the first or second year of a U.S. presidential term. In such cases, it is more effective to gauge the timing of a market bottom reversal by using indicators that offer stronger leading signals for recessions than the standard 10-year/2-year spread—specifically, the spread between 10-year and 3-month Treasury yields (FRED:T10Y3M), which the Federal Reserve prioritizes.
During major recessions like the COVID-19 crash, the FRED:BAMLH0A0HYM2 indicator is too slow to react.
Image
Focus on short-term Treasury yields, to which the Fed is likely to respond quickly (using the FRED:T10Y3M setting).
For the Japanese market: Since it is highly correlated with the U.S. market, I recommend using this as a leading indicator while also monitoring the momentum of the USD/JPY exchange rate and trends in the Nikkei 225 Volatility Index (NI225VI) for supplementary analysis.
2.Intermediate Trend Background Signal (A/D Difference)
Logic:
Uses the SMA of the Advance/Decline (A/D) line to indicate market overheating and trend direction via the background color.
Role:
An indicator that measures market "breadth." Areas with background coloring suggest the market is in an overheated zone with a clear trend.
Operation (Adjustment Method):
Thresholds (-1000, -1500) vary depending on the liquidity of the target market.
If the background color does not appear when you want it to, make the threshold looser (closer to 0).
If there is too much noise, adjust the threshold to be stricter (increase the negative value).
System Usage Workflow
Broad Perspective (Weekly Chart):
Check the capital environment using MGI and assess market "heat" via the background color. When the background turns green or pink, it indicates a phase requiring special attention.
Tactical Decision (Daily Chart):
Check the direction of the VStop line and the price position; consider trend-following trades aligned with the direction seen on the weekly chart.
Temporal Edge (Seasonality Chart):
Check where the current price stands relative to historical anomalies to increase your confidence when buying dips or selling rallies.
Key Points for Use
This system does not provide a single "answer"; rather, it is a tool to assist you in interpreting the current market environment. If you find yourself wondering, "Why did the background color appear but the price didn't follow suit?", try fine-tuning the parameters mentioned above.
Please make investment decisions calmly and at your own risk.
Notes de version
Release Notes – June 28, 2026Revised English wording for better clarity.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.