OPEN-SOURCE SCRIPT
Sector Rotation (Zeiierman)

█ Overview
Sector Rotation (Zeiierman) is a relative strength rotation tool designed to compare multiple sectors against a selected benchmark and visualize how leadership shifts across the market over time.
Instead of viewing sector performance as isolated price charts, the script converts each sector into a normalized RS-Ratio and RS-Momentum reading, then plots them inside a four-quadrant rotation map.
The result is a clean visual framework for identifying which sectors are Leading, Weakening, Lagging, or Recovering relative to the broader market.

█ How It Works
⚪ Relative Strength Rotation Engine
Each sector is measured against a benchmark symbol, such as VTI or SPY, by dividing the sector’s price by the benchmark price.
Pine Script®
This relative strength ratio is normalized into an RS-Ratio value centered around 100. A second momentum calculation measures the rate of change of that RS-Ratio and normalizes it into RS-Momentum, also centered around 100.
Pine Script®
Together, these two values create the X and Y coordinates for each sector:
• RS-Ratio above 100 → relative strength is above average
• RS-Ratio below 100 → relative strength is below average
• RS-Momentum above 100 → relative momentum is improving
• RS-Momentum below 100 → relative momentum is weakening
⚪ Four-Quadrant Rotation Map
The chart is divided into four market rotation phases:
Pine Script®
• Leading → strong relative strength and rising momentum
• Weakening → strong relative strength but falling momentum
• Lagging → weak relative strength and falling momentum
• Recovering → weak relative strength but improving momentum
This allows traders to quickly understand where each sector currently sits in the rotation cycle.
⚪ Sector Trails and Movement Direction
Each sector keeps a synchronized historical trail of recent RS-Ratio and RS-Momentum points.
Pine Script®
The newest point is displayed as the sector head marker, while older points form a fading tail behind it. This makes it easier to see not only where a sector is now, but also how it has been rotating over recent samples.
The table also shows each sector’s current heading, such as RS improving, RS weakening, momentum rising, or momentum falling.
Pine Script®
⚪ Top-Ranked Sector Filtering
The script includes an optional ranking system that can display only the most important sector rotations.
Sectors can be ranked by:
• Fastest movement
• Movement toward Leading
• Movement toward Recovering
• Movement toward Lagging
• Movement toward Weakening
Pine Script®
When enabled, only the top-ranked sectors are shown on the chart and in the table, helping reduce clutter and focus attention on the most actionable rotations.
Pine Script®
█ How to Use
⚪ Identify Sector Leadership
Look for sectors positioned in the Leading quadrant. These sectors have both strong relative strength and improving momentum compared to the benchmark. Sectors moving into Leading from Recovering can signal early leadership development.
⚪ Watch Weakening Sectors
Sectors in the Weakening quadrant still have above-average relative strength, but their momentum is declining. This can indicate that prior leaders are beginning to lose strength.
⚪ Track Recovering Rotations
Sectors in the Recovering quadrant have below-average relative strength but improving momentum. These areas may represent early rotation opportunities before relative strength fully turns positive.
⚪ Avoid or Monitor Lagging Sectors
Sectors in the Lagging quadrant show both weak relative strength and weak momentum. These sectors are typically underperforming the benchmark and may remain weak until momentum begins to improve.
⚪ Example: Ranked by Fastest Movement
In this example, the ranking mode is set to Fastest Movement with Only Show Top Ranked enabled and Top X = 5.
The indicator measures how quickly each sector is moving through the rotation cycle by comparing the change in its RS-Ratio and RS-Momentum values between samples. Sectors with the largest movement are ranked highest and displayed on the chart.
As a result, only the five sectors showing the strongest relative movement are visible. In this case, all five sectors are positioned inside the Recovering quadrant, indicating that relative momentum has turned positive while relative strength remains slightly below average.
The upward and rightward trajectory of the trails suggests these sectors are improving versus the benchmark and may continue rotating toward the Leading quadrant if current momentum persists.

⚪ Example: Top 5 Sectors Ranked Toward Leading
In this example, the ranking mode is set to Toward Leading with Only Show Top Ranked enabled and Top X = 5.
Rather than ranking sectors by raw speed, the indicator prioritizes sectors moving most directly toward the Leading quadrant, where both relative strength and relative momentum are above the 100 baseline.
Technology currently holds the highest rank, as it has already entered the Leading quadrant with both RS-Ratio and RS-Momentum above 100. Its trail shows a strong and sustained rotation from weaker relative conditions into market leadership, making it the strongest candidate according to the selected ranking method.
Discretionary and Financials are positioned inside the Recovering quadrant. Although they have not yet reached leadership status, their improving momentum and trajectory toward the upper-right portion of the chart suggest continued relative improvement versus the benchmark.
Meanwhile, Staples and Real Estate remain in the Lagging quadrant. However, they are still included in the ranking because their recent movement is directed toward the Leading quadrant, indicating potential early-stage rotation despite their current relative weakness.
This ranking mode is particularly useful for identifying sectors that are not necessarily the strongest today, but are showing the most meaningful progress toward future leadership. By focusing on directional rotation rather than speed alone, traders can often spot emerging leaders before they fully establish themselves in the Leading quadrant.

⚪ Example: Top 5 Sectors Ranked Toward Recovering
In this example, the ranking mode is set to Toward Recovering with Only Show Top Ranked enabled and Top X = 5.
This ranking method prioritizes sectors moving most directly toward the Recovering quadrant, where relative strength remains below average but relative momentum is improving. The goal is to identify sectors that may be emerging from periods of relative underperformance and beginning a new rotation cycle.
Communication Services holds the highest rank in this example. Its trail shows a strong upward movement from the Lagging quadrant into Recovering, indicating a significant improvement in relative momentum while still trading below the relative strength baseline.
Consumer Staples and Real Estate also display characteristics of sectors transitioning toward recovery. Their recent movement suggests momentum is improving despite their relative strength remaining below average.
Technology appears in the Leading quadrant, while Energy remains in Lagging. Although they occupy different quadrants, both are included because their recent directional movement aligns with the path toward the Recovering quadrant based on the ranking algorithm.
This ranking mode is particularly useful for traders seeking early rotation opportunities. Rather than focusing on sectors that are already leading, it highlights areas of the market where momentum is beginning to improve and where relative strength may eventually follow if the recovery continues.

⚪ Example: Top 5 Sectors Ranked Toward Lagging
In this example, the ranking mode is set to Toward Lagging with Only Show Top Ranked enabled and Top X = 5.
This ranking method prioritizes sectors moving most directly toward the Lagging quadrant, where both relative strength and relative momentum fall below the 100 baseline. It helps identify sectors that are losing leadership, weakening relative to the benchmark, or entering periods of sustained underperformance.
Technology and Health Care are currently positioned inside the Weakening quadrant. Both sectors still maintain above-average relative strength, but their declining momentum suggests they are rotating away from leadership and moving closer toward Lagging conditions.
Meanwhile, Staples, Utilities, and Real Estate remain within the Recovering quadrant. Although momentum is still positive, their relative strength remains below average. Their inclusion in the ranking reflects the direction of their recent movement rather than their current location, indicating they are rotating toward weaker relative conditions.
The trails highlight this transition clearly, with several sectors showing movement away from stronger quadrants and toward areas associated with declining performance.
This ranking mode is useful for identifying sectors that may be losing institutional sponsorship, weakening relative to the broader market, or approaching the later stages of the relative strength cycle. Traders can use it to spot deteriorating leadership and monitor sectors that may continue underperforming if current trends persist.

⚪ Example: Top 5 Sectors Ranked Toward Weakening
In this example, the ranking mode is set to Toward Weakening with Only Show Top Ranked enabled and Top X = 5.
This ranking method prioritizes sectors moving most directly toward the Weakening quadrant, where relative strength remains above average but relative momentum has begun to deteriorate. These sectors often represent former leaders that are losing momentum before potentially transitioning into the Lagging quadrant.
Technology holds the highest rank in this example. While its relative strength remains above the 100 baseline, its momentum has fallen below 100, placing it firmly inside the Weakening quadrant. Its recent trail illustrates a loss of momentum despite previously strong relative performance, making it a textbook example of a sector rotating away from leadership.
Health Care remains in the Leading quadrant but is also ranked highly because its recent movement is directed toward Weakening. Although it continues to outperform the benchmark, the decline in momentum suggests its leadership position may be starting to fade.
Materials is already positioned within the Weakening quadrant, while Energy and Real Estate remain in Recovering. Their inclusion reflects the direction of their recent movement rather than their current location, indicating they are rotating toward conditions associated with weakening relative performance.
This ranking mode is useful for identifying sectors that may be nearing the end of their leadership cycle. Traders often monitor these sectors for signs of continued momentum deterioration, profit-taking activity, or a potential transition into the Lagging quadrant if relative strength begins to weaken further.

█ Settings
-----------------
Disclaimer
The content provided in my scripts, indicators, ideas, algorithms, and systems is for educational and informational purposes only. It does not constitute financial advice, investment recommendations, or a solicitation to buy or sell any financial instruments. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.
All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
Sector Rotation (Zeiierman) is a relative strength rotation tool designed to compare multiple sectors against a selected benchmark and visualize how leadership shifts across the market over time.
Instead of viewing sector performance as isolated price charts, the script converts each sector into a normalized RS-Ratio and RS-Momentum reading, then plots them inside a four-quadrant rotation map.
The result is a clean visual framework for identifying which sectors are Leading, Weakening, Lagging, or Recovering relative to the broader market.
█ How It Works
⚪ Relative Strength Rotation Engine
Each sector is measured against a benchmark symbol, such as VTI or SPY, by dividing the sector’s price by the benchmark price.
This relative strength ratio is normalized into an RS-Ratio value centered around 100. A second momentum calculation measures the rate of change of that RS-Ratio and normalizes it into RS-Momentum, also centered around 100.
Together, these two values create the X and Y coordinates for each sector:
• RS-Ratio above 100 → relative strength is above average
• RS-Ratio below 100 → relative strength is below average
• RS-Momentum above 100 → relative momentum is improving
• RS-Momentum below 100 → relative momentum is weakening
⚪ Four-Quadrant Rotation Map
The chart is divided into four market rotation phases:
• Leading → strong relative strength and rising momentum
• Weakening → strong relative strength but falling momentum
• Lagging → weak relative strength and falling momentum
• Recovering → weak relative strength but improving momentum
This allows traders to quickly understand where each sector currently sits in the rotation cycle.
⚪ Sector Trails and Movement Direction
Each sector keeps a synchronized historical trail of recent RS-Ratio and RS-Momentum points.
The newest point is displayed as the sector head marker, while older points form a fading tail behind it. This makes it easier to see not only where a sector is now, but also how it has been rotating over recent samples.
The table also shows each sector’s current heading, such as RS improving, RS weakening, momentum rising, or momentum falling.
⚪ Top-Ranked Sector Filtering
The script includes an optional ranking system that can display only the most important sector rotations.
Sectors can be ranked by:
• Fastest movement
• Movement toward Leading
• Movement toward Recovering
• Movement toward Lagging
• Movement toward Weakening
When enabled, only the top-ranked sectors are shown on the chart and in the table, helping reduce clutter and focus attention on the most actionable rotations.
█ How to Use
⚪ Identify Sector Leadership
Look for sectors positioned in the Leading quadrant. These sectors have both strong relative strength and improving momentum compared to the benchmark. Sectors moving into Leading from Recovering can signal early leadership development.
⚪ Watch Weakening Sectors
Sectors in the Weakening quadrant still have above-average relative strength, but their momentum is declining. This can indicate that prior leaders are beginning to lose strength.
⚪ Track Recovering Rotations
Sectors in the Recovering quadrant have below-average relative strength but improving momentum. These areas may represent early rotation opportunities before relative strength fully turns positive.
⚪ Avoid or Monitor Lagging Sectors
Sectors in the Lagging quadrant show both weak relative strength and weak momentum. These sectors are typically underperforming the benchmark and may remain weak until momentum begins to improve.
⚪ Example: Ranked by Fastest Movement
In this example, the ranking mode is set to Fastest Movement with Only Show Top Ranked enabled and Top X = 5.
The indicator measures how quickly each sector is moving through the rotation cycle by comparing the change in its RS-Ratio and RS-Momentum values between samples. Sectors with the largest movement are ranked highest and displayed on the chart.
As a result, only the five sectors showing the strongest relative movement are visible. In this case, all five sectors are positioned inside the Recovering quadrant, indicating that relative momentum has turned positive while relative strength remains slightly below average.
The upward and rightward trajectory of the trails suggests these sectors are improving versus the benchmark and may continue rotating toward the Leading quadrant if current momentum persists.
⚪ Example: Top 5 Sectors Ranked Toward Leading
In this example, the ranking mode is set to Toward Leading with Only Show Top Ranked enabled and Top X = 5.
Rather than ranking sectors by raw speed, the indicator prioritizes sectors moving most directly toward the Leading quadrant, where both relative strength and relative momentum are above the 100 baseline.
Technology currently holds the highest rank, as it has already entered the Leading quadrant with both RS-Ratio and RS-Momentum above 100. Its trail shows a strong and sustained rotation from weaker relative conditions into market leadership, making it the strongest candidate according to the selected ranking method.
Discretionary and Financials are positioned inside the Recovering quadrant. Although they have not yet reached leadership status, their improving momentum and trajectory toward the upper-right portion of the chart suggest continued relative improvement versus the benchmark.
Meanwhile, Staples and Real Estate remain in the Lagging quadrant. However, they are still included in the ranking because their recent movement is directed toward the Leading quadrant, indicating potential early-stage rotation despite their current relative weakness.
This ranking mode is particularly useful for identifying sectors that are not necessarily the strongest today, but are showing the most meaningful progress toward future leadership. By focusing on directional rotation rather than speed alone, traders can often spot emerging leaders before they fully establish themselves in the Leading quadrant.
⚪ Example: Top 5 Sectors Ranked Toward Recovering
In this example, the ranking mode is set to Toward Recovering with Only Show Top Ranked enabled and Top X = 5.
This ranking method prioritizes sectors moving most directly toward the Recovering quadrant, where relative strength remains below average but relative momentum is improving. The goal is to identify sectors that may be emerging from periods of relative underperformance and beginning a new rotation cycle.
Communication Services holds the highest rank in this example. Its trail shows a strong upward movement from the Lagging quadrant into Recovering, indicating a significant improvement in relative momentum while still trading below the relative strength baseline.
Consumer Staples and Real Estate also display characteristics of sectors transitioning toward recovery. Their recent movement suggests momentum is improving despite their relative strength remaining below average.
Technology appears in the Leading quadrant, while Energy remains in Lagging. Although they occupy different quadrants, both are included because their recent directional movement aligns with the path toward the Recovering quadrant based on the ranking algorithm.
This ranking mode is particularly useful for traders seeking early rotation opportunities. Rather than focusing on sectors that are already leading, it highlights areas of the market where momentum is beginning to improve and where relative strength may eventually follow if the recovery continues.
⚪ Example: Top 5 Sectors Ranked Toward Lagging
In this example, the ranking mode is set to Toward Lagging with Only Show Top Ranked enabled and Top X = 5.
This ranking method prioritizes sectors moving most directly toward the Lagging quadrant, where both relative strength and relative momentum fall below the 100 baseline. It helps identify sectors that are losing leadership, weakening relative to the benchmark, or entering periods of sustained underperformance.
Technology and Health Care are currently positioned inside the Weakening quadrant. Both sectors still maintain above-average relative strength, but their declining momentum suggests they are rotating away from leadership and moving closer toward Lagging conditions.
Meanwhile, Staples, Utilities, and Real Estate remain within the Recovering quadrant. Although momentum is still positive, their relative strength remains below average. Their inclusion in the ranking reflects the direction of their recent movement rather than their current location, indicating they are rotating toward weaker relative conditions.
The trails highlight this transition clearly, with several sectors showing movement away from stronger quadrants and toward areas associated with declining performance.
This ranking mode is useful for identifying sectors that may be losing institutional sponsorship, weakening relative to the broader market, or approaching the later stages of the relative strength cycle. Traders can use it to spot deteriorating leadership and monitor sectors that may continue underperforming if current trends persist.
⚪ Example: Top 5 Sectors Ranked Toward Weakening
In this example, the ranking mode is set to Toward Weakening with Only Show Top Ranked enabled and Top X = 5.
This ranking method prioritizes sectors moving most directly toward the Weakening quadrant, where relative strength remains above average but relative momentum has begun to deteriorate. These sectors often represent former leaders that are losing momentum before potentially transitioning into the Lagging quadrant.
Technology holds the highest rank in this example. While its relative strength remains above the 100 baseline, its momentum has fallen below 100, placing it firmly inside the Weakening quadrant. Its recent trail illustrates a loss of momentum despite previously strong relative performance, making it a textbook example of a sector rotating away from leadership.
Health Care remains in the Leading quadrant but is also ranked highly because its recent movement is directed toward Weakening. Although it continues to outperform the benchmark, the decline in momentum suggests its leadership position may be starting to fade.
Materials is already positioned within the Weakening quadrant, while Energy and Real Estate remain in Recovering. Their inclusion reflects the direction of their recent movement rather than their current location, indicating they are rotating toward conditions associated with weakening relative performance.
This ranking mode is useful for identifying sectors that may be nearing the end of their leadership cycle. Traders often monitor these sectors for signs of continued momentum deterioration, profit-taking activity, or a potential transition into the Lagging quadrant if relative strength begins to weaken further.
█ Settings
- Benchmark: Selects the symbol each sector is compared against.
- Calculation Timeframe: Defines the timeframe used for all relative strength and momentum calculations.
- RS-Ratio Lookback: Controls the normalization period for relative strength.
- RS-Momentum Lookback: Controls how quickly momentum responds to changes in RS-Ratio.
- Tail Length: Sets how many historical samples are shown behind each sector.
- Sample Every N Bars: Controls how frequently new trail points are recorded.
- Show Sector Table: Shows or hides the summary table with phase, heading, RS, and momentum values.
- Only Show Top Ranked: Enables filtering so only the strongest ranked sectors are displayed.
- Top X: Defines how many ranked sectors remain visible.
- Rank By: Selects how sectors are ranked, either by speed or movement toward a selected quadrant.
- Sector Inputs: Allows each sector to be enabled, disabled, customized, or replaced with another symbol.
- Canvas Width: Controls the horizontal size of the rotation map.
- Canvas Height: Controls the vertical size of the rotation map.
- Symmetric Bounds Around 100: Keeps the chart balanced around the 100 baseline.
- Minimum Axis Span: Prevents small movements from being visually exaggerated.
-----------------
Disclaimer
The content provided in my scripts, indicators, ideas, algorithms, and systems is for educational and informational purposes only. It does not constitute financial advice, investment recommendations, or a solicitation to buy or sell any financial instruments. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.
All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Access my indicators at: zeiierman.com
Join Our Free Discord: discord.gg/zeiiermantrading
Join Our Free Discord: discord.gg/zeiiermantrading
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Access my indicators at: zeiierman.com
Join Our Free Discord: discord.gg/zeiiermantrading
Join Our Free Discord: discord.gg/zeiiermantrading
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.