Relative Strength Rotation Strategy [Jayadev Rana] by JayadevRana
By JayadevRana
Performance Metrics
- Author: JayadevRana
- Symbol: BINANCE:BTCUSDT
- Timeframe: 1 hour
Description
WHAT IT ISRelative Strength Rotation Strategy trades a symbol on how it performs against a benchmark rather than on its own price alone. The idea comes from rotation and relative-strength investing: capital flows toward what is outperforming and leaves what is underperforming, and that flow tends to persist for a while. The script builds a relative-strength line, scores it in three complementary ways and rotates into the symbol while the score says it is gaining ground on the benchmark, and out when that advantage fades.HOW IT WORKS1. Benchmark. Leave the benchmark input blank and the script selects one by asset class (a crypto total-cap index for crypto, the dollar index for forex, the S and P 500 index for everything else), or type any symbol. The benchmark close is requested on the chart timeframe without lookahead and forward-filled across bars the benchmark does not trade.2. Relative strength line. RS = natural log of (symbol close / benchmark close). Rising RS means the symbol is outperforming.3. Three scores.- Rotation score (0 to 100): RS momentum over three horizons (default 20, 50 and 100 bars) is each ranked against its own history over the percentile window, and the three ranks are averaged. A high score means RS is accelerating on short, medium and long horizons at once.- Mansfield relative strength: the symbol-to-benchmark ratio divided by its long simple moving average, minus one, in percent. Positive means the symbol is above its normal relative performance.- RS slope z-score: the one-bar change of a linear regression of RS, divided by its standard deviation. It measures how steep the current RS move is compared with the usual.4. Entries. A long opens when the rotation score crosses above the entry level (default 70) while the Mansfield RS is positive, the slope z-score is above its threshold and, optionally, price is above its own EMA. A short opens on the mirrored conditions below 100 minus the entry level. A cooldown prevents immediate re-entry after an exit.5. Exits. The position is closed when the rotation score falls back through the exit level (default 50) or the Mansfield RS flips sign, whichever comes first. A wide ATR-based catastrophic stop protects against gaps. Each optional filter can be switched off.ON THE CHARTBUY and SELL labels mark entries, crosses mark exits, the price EMA and the active ATR stop are drawn, and the background is shaded from red to green by the rotation score. The status table shows the benchmark in use, the score with its three component ranks, Mansfield RS, slope z-score, price versus EMA, position, which side is currently allowed by the filters, and the closed-trade count. Data-window plots expose the score, Mansfield RS, slope z-score and the raw ratio.STRATEGY PROPERTIES USEDInitial capital 10,000. Order size 20% of equity. Commission 0.05% per side. Slippage 2 ticks. Fills on the next bar open. No pyramiding. Adjust to your instrument and account.INPUTSBenchmark: symbol override.Relative strength scoring: three momentum horizons, percentile window, Mansfield average length, slope length.Entries and exits: entry and exit score levels, Mansfield and slope filters, slope threshold, price EMA filter and length, long and short switches, ATR stop multiple, cooldown.Display: status table, background shading.ALERTSThe strategy calls alert() on long entry, short entry and position close.INTENDED USEDaily and 4-hour charts of stocks, sector ETFs, index futures and major crypto pairs against a suitable benchmark. The method is slow by design and aims to hold through sustained periods of relative outperformance; it is not a scalping tool.LIMITATIONSRelative strength is a lagging measure and reverses after the fact. If the benchmark is poorly chosen the signals are meaningless, so check the benchmark row in the table. Benchmarks with a different trading calendar are forward-filled, which flattens RS on bars where the benchmark is closed. The score depends on the percentile window and is undefined until that many bars have loaded. Backtest results vary strongly with the symbol and benchmark pair.Published for study and research only. Not financial advice. Past performance does not guarantee future results.