TradingView strategy research

Sector rotation strategy: ranking and rebalance rules

A sector rotation strategy changes exposure among economic sectors according to a stated selection rule. A momentum version ranks sector ETFs by past returns and periodically reallocates to the leaders. To test it, define the ETF universe, dividend treatment, ranking timestamp, weights, cash rule and execution costs before observing results. TradingView can help monitor relative performance; a strategy on one chart does not establish the return of a multi-ETF portfolio.

See the decision guide

Choose the sector universe before ranking it

This example uses the 11 equity Select Sector SPDR ETFs listed by State Street. They represent sectors of the S&P 500, so the experiment concerns US large-cap sector exposure. It does not cover the whole global equity market, every industry or every sector fund. SPY is a benchmark and market filter, not a candidate for either sector slot.

  • Freeze ticker identifiers, exchanges, currency, session and data provider with the research record. Do not replace a poorly performing fund after seeing its returns.
  • State Street lists inception dates of June 18, 2018 for XLC and October 7, 2015 for XLRE. Start this fixed-universe test only after every fund has the required observations. Never treat pre-inception prices as tradable ETF history.
  • A historical index proxy or a changing universe is a separate experiment. Record when each instrument became eligible, any closures and sector classification changes. Choosing only funds surviving today leaves selection bias even when the price series are clean.
ETFSector
XLBMaterials
XLCCommunication services
XLEEnergy
XLFFinancials
XLIIndustrials
XLKTechnology
XLPConsumer staples
XLREReal estate
XLUUtilities
XLVHealth care
XLYConsumer discretionary

Separate momentum ranking from an economic-cycle forecast

Momentum rotation asks whether recent sector leaders continue to lead. An economic-cycle approach instead maps economic observations to sector preferences. They require different evidence: a cycle test needs the release time and unrevised value of each economic observation. This page defines the momentum version, so a later recession label cannot alter an earlier allocation.

  • Relative strength means performance compared with another asset or the candidate set here. It does not mean the Relative Strength Index oscillator.
  • A sector can rank first while losing money. The positive-return requirement below is separate from its place in the ranking.
  • Holding two sectors leaves substantial concentration and common equity exposure. A cash rule can miss recoveries and cannot prevent losses before its next decision date.

Freeze the ranking and allocation protocol

Let A(i,m) be the dividend-reinvested, split-adjusted return index for ETF i at the final regular-session close of month m. Use one consistent source and adjustment convention for all ETFs and SPY. The following settings define a custom baseline; none is presented as optimal.

  • Require the full seven-observation sector panel and ten-observation SPY filter before the first decision. If a required value is missing or stale later, mark the decision invalid and make no model rebalance. Carry existing holdings explicitly; do not silently shrink the candidate pool.
  • Repair data gaps before interpreting performance. If an existing holding cannot be valued or traded, record the unresolved position and delay its fill; never replace a missing observation with zero return or assume instant liquidation.
  • Freeze selections after the decision. Do not rerank with next-session prices or assume the final month-end close was an available fill after observing it. If a symbol cannot trade at the intended time, retain the pending order record and use its eventual executable fill.
DecisionRule for this experiment
Observation timeAfter the final regular US trading session of month m has closed and all required closes are available. Save that timestamp and the source snapshot.
Six-month scoreR(i,m) = A(i,m) / A(i,m-6) - 1. Use seven month-end observations, not six daily bars or a partially completed month.
Ranking and tiesSort R from highest to lowest using full stored precision. Resolve an exact tie by ascending ticker name. Display rounding never decides the winner.
Market conditionRequire SPY A(m) to be strictly above the mean of its ten month-end values A(m-9) through A(m), including the completed current month. Equality fails.
Sector selectionIf the market condition passes, select the first two ETFs with R > 0. Each receives a 50% target of post-cost equity. One eligible fund means 50% ETF and 50% cash; none means all cash.
Risk-off allocationIf the market condition fails, target 100% cash. Cash earns 0% in this baseline; a Treasury fund or interest-bearing cash assumption requires a separate return and cost series.
Rebalance and holding periodSubmit reductions at the next regular-session open and purchases when proceeds are available. Record each executable fill. Hold until the following monthly rebalance; weights drift between decisions. There is no intramonth stop in this baseline.
Funding and quantitySell reductions before funding purchases, reserve fees and prohibit borrowing. The arithmetic example permits fractional shares. For whole shares, round purchases down and retain residual cash.

Worked ranking: a tie changes the second slot

These fictional total-return index values illustrate one month-end decision, not actual fund performance. Set every ETF index to 100 at m-6. Assume SPY ends month m at 112 and its ten-month average is 108, so the market condition passes. The values below are exact for this example.

  • For XLK, 112 / 100 - 1 = 0.12. If its starting index had been 105 instead, the score would be about 6.67%, which changes the order. Comparing raw ETF prices is not a return ranking.
  • If SPY instead closes at 108 while its calculated average is also 108, target cash even though XLK leads. If the filter passes but only XLK has a positive return, allocate one 50% slot and keep the other in cash.
  • If XLE is missing its month-end observation, this baseline produces an invalid decision, not an automatic promotion of XLI. That distinction prevents data availability from silently changing the investment rule.
ETFIndex at mSix-month returnDecision
XLK112+12%First slot: 50%
XLE108+8%Second slot: 50%; ticker sorts before XLI
XLI108+8%Outside the two slots
XLC107+7%Outside the two slots
XLF106+6%Outside the two slots
XLY105+5%Outside the two slots
XLV104+4%Outside the two slots
XLB103+3%Outside the two slots
XLP102+2%Outside the two slots
XLRE1000%Fails the positive-return condition
XLU98-2%Fails the positive-return condition

Worked rebalance: charge both purchases and sales

At the execution time, assume existing holdings are worth $60,000 in XLK and $40,000 in XLF, with no cash. The new selection is XLK and XLE. Assume fractional shares, no price movement during execution, no taxes, and an illustrative all-in trading cost of 0.10% of every dollar bought or sold. This rate combines fees and execution friction for the example; it is not a quoted broker charge.

  • Post-cost equity is $99,900, split into $49,950 in each selected ETF. The sales fund the purchase and all $100 of costs. Gross traded value / starting equity is 100%; the half-sum convention would call this 50% turnover. State the convention whenever reporting turnover.
  • If the next holding-period total returns are +2% for XLK and -1% for XLE, ending equity before the next rebalance is $49,950 × 1.02 + $49,950 × 0.99 = $100,399.50. That is +0.3995% relative to the initial $100,000, versus +0.5% without this rebalance cost.
  • Apply costs to the actual changes in holdings, including trims of retained funds. Do not charge a full liquidation and repurchase when only a small rebalance is needed.
  • In a real test, model spread, commission and slippage consistently, including stressed fills. If actual fill prices already contain slippage, do not deduct it again. Tax consequences and liquidity constraints require separate assumptions.
ActionTraded valueCost at 0.10%
Reduce XLK from $60,000 to $49,950$10,050 sold$10.05
Close XLF$40,000 sold$40.00
Open XLE$49,950 bought$49.95
Total$100,000 traded$100.00

Audit dividends, history and the comparison portfolio

TradingView documents dividend adjustment as a total-return view and notes that it is unavailable for some assets. Verify the adjustment of every requested series, not just the chart display. A raw price-return rank can penalize a fund for paying a distribution and change which sector qualifies.

  • Use adjusted series for comparable ranking, but executable market prices for orders. A cash ledger must book actual distributions and any reinvestment consistently. Do not add cash dividends a second time to a return series that already reinvests them.
  • Use ETF returns when testing ETF holdings. Fund expenses already affect fund results; deducting the published expense ratio again double counts that expense. An index proxy has different fees, tracking and investability assumptions.
  • Compare against a declared benchmark such as SPY buy-and-hold over identical dates with the same dividend convention. Also compare an equal-weight version of the same 11-fund universe with its rebalance costs, so the benefit of rotation is not confused with a different starting universe.
  • Reserve later dates before selecting lookback, filter or rebalance frequency. Record all attempted settings, net return, drawdown, turnover and time in cash. A few strong sector episodes do not establish that the ranking rule will persist.
  • Keep the full monthly panel, ranks, invalid decisions, target weights, pretrade weights, orders, fills and cash movements. A list of winning sectors cannot reproduce portfolio equity.

Use Pineify for research and a TradingView monitor

Ask AI Finance Agent to inspect the named ETFs, their reported holdings and sector exposure. Check dates and missing fields in its output against fund disclosures. These research tools can help document the universe; they do not supply a point-in-time portfolio execution record or prove that all historical data are available.

  • Give Pine Script AI Coding Agent the fixed symbol list, return convention, month-end timestamp, tie rule and missing-data policy. Request a monitor that displays confirmed scores, source timestamps, selected slots and invalid-data status. Review the generated code and request syntax validation.
  • TradingView request.security can read other symbols and contexts. That data access does not make ordinary strategy orders trade each requested ETF. Treat any chart-symbol strategy result as a single-symbol simulation; combine holdings, cash and costs in a separately validated portfolio ledger or portfolio backtester.
  • Verify the monitor against the worked tie, risk-off and missing-data cases before using its output. This page includes a rule specification and arithmetic, not a ready-to-run portfolio strategy, brokerage automation or performance claim.
Where Pineify fits

AI Finance Agent

Research the explicit ETF universe and inspect reported holdings and sector exposure. Check source dates and missing data before accepting the research.

Also useful: Pine Script AI Coding Agent. Draft a relative-performance monitor for accessible TradingView data, then review its timing, adjustments and invalid-data behavior.

Research the sector ETF universe

Frequently asked questions

Educational research, not investment advice. The rules, index values and returns are hypothetical and have not been performance-tested. Sector concentration, reversals, gaps and execution costs can cause losses. Historical results do not guarantee future returns.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.