Strategy vault / Mean reversion
Sell the Rallies Strategy
The "Sell the Rallies" strategy is a carefully crafted trading strategy designed to optimize asset sales during pullbacks in price rallies. Traders following this strategy will benefit from a systematic approach…

Overview
The "Sell the Rallies" strategy is a carefully crafted trading strategy designed to optimize asset sales during pullbacks in price rallies. Traders following this strategy will benefit from a systematic approach backed by clear entry and exit conditions.
Strategy Principle
The strategy employs a combination of technical indicators and well-defined parameters to guide traders through market fluctuations. The strategy's foundation lies in a thorough analysis of historical price data to pinpoint potential reversal points.
The strategy triggers a short position entry when the overall percentage change crosses above a predefined rally value. This crossover condition acts as a robust signal for identifying potential reversal points during price rallies. Traders can leverage this signal to initiate short positions, positioning themselves strategically in anticipation of a downturn.
To safeguard against adverse market movements, the strategy incorporates a meticulous risk management system. The exit conditions are defined by calculated stop-loss and take-profit levels, which are dynamically determined based on the average entry price of the position.
Once a short position is entered, the stop-loss and take-profit levels are calculated. The stop-loss level is determined by multiplying the average entry price of the position by the stop-loss percentage. The take-profit level is calculated by multiplying the average entry price by the take-profit percentage. These risk management levels provide clear guidelines on when to exit a position, ensuring both capital protection and profit realization.
Advantage Analysis
The strategy has the following advantages:
Provides clear entry and exit rules for more definitive trading decisions.
Identifies reversal opportunities using technical indicators for improved decision accuracy.
Dynamically calculates stop-loss and take-profit levels for better risk control.
Systematic approach facilitates tracking and performance evaluation.
Allows parameter optimization for adapting to different market conditions.
Risk Analysis
The strategy also carries the following risks:
Reversal signals may give false signals resulting in losses.
Improper stop-loss and take-profit settings may lead to excessive losses or failure to realize full profits.
Improper parameter settings can lead to poor performance.
The main risk control measures include:
Evaluate signal reliability to avoid false signals.
Test and optimize stop-loss and take-profit parameters.
Assess parameter robustness across different market conditions.
Optimization Directions
The strategy can be optimized in several aspects:
Test more technical indicators to find more reliable reversal signals.
Utilize machine learning methods to dynamically optimize stop-loss and take-profit levels.
Incorporate evaluation of market biases using sentiment indicators etc. to improve signal accuracy.
Optimize position sizing management for trend tracking.
Evaluate stock characteristics to screen for best suited tickers for the strategy.
Conclusion
The Sell the Rallies strategy provides traders with a powerful tool to actively seek ideal reversal shorting opportunities during price rallies. With a robust framework and decisions grounded in meticulous analysis, the strategy enables traders to proactively capitalize on market opportunities. At the same time, the strategy provides customizable parameters allowing traders to tailor-make their own trading strategies. Through rigorous parameter testing and optimization, traders can unlock the strategy's full trading potential.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | true | From Month |
| v_input_2 | 10 | From Day |
| v_input_3 | 2020 | From Year |
| v_input_4 | 2 | Thru Month |
| v_input_5 | 21 | Thru Day |
| v_input_6 | 2024 | Thru Year |
| v_input_7 | true | Lookback Period |
| v_input_8 | 2 | Rally |
| v_input_9 | 2 | Stop Loss (%) |
| v_input_10 | 2 | Take Profit (%) |
Source Pine Script
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Sell the Rallies", overlay=true, initial_capital=212, commission_type=strategy.commission.percent, commission_value=0, pyramiding=2)
// Backtest dates
fromMonth = input(1, "From Month")
fromDay = input(10, "From Day")
fromYear = input(2020, "From Year")
thruMonth = input(2, "Thru Month")
thruDay = input(21, "Thru Day")
thruYear = input(2024, "Thru Year")
// Define window of time for backtest
start = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59)
withinWindow() => true
inp_lkb = input(1, "Lookback Period")
// Calculate percentage change
perc_change(lkb) =>
overall_change = ((close - ta.valuewhen(withinWindow(), close, lkb)) / ta.valuewhen(withinWindow(), close, lkb)) * 100
// Call the function
overall = perc_change(inp_lkb)
// Entry
rally = input(2, "Rally")
if ta.crossover(overall, rally) and withinWindow()
strategy.entry("Short", strategy.short)
// Exit
stopLoss = input(2, "Stop Loss (%)") / 100
takeProfit = input(2, "Take Profit (%)") / 100
shortStopPrice = strategy.position_avg_price * (1 + stopLoss)
shortTakeProfit = strategy.position_avg_price * (1 - takeProfit)
strategy.exit("Exit", "Short", stop=shortStopPrice, limit=shortTakeProfit)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-27. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Sell-the-Rallies-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- 1 2 3 Pattern Quantitative Trading Strategy with EMAs MACD and 4th Candle ExtensionPine Script · Mean reversion · 1h
- 3 10 Oscillator Profile Flagging StrategyPine Script · Mean reversion · 1d
- A Trend Reversal Strategy Based on Moving Averages Price Patterns and VolumePine Script · Mean reversion · 1d
- ATR and EMA based Dynamic Take Profit and Stop Loss Adaptive StrategyPine Script · Mean reversion · 1h
- Adaptive Mean Reversion Trading Strategy Based on Chande Momentum OscillatorPine Script · Mean reversion · 1d
- Adaptive Moving Average Tracking StrategyPine Script · Mean reversion · 1d