Sell the Rallies Strategy

Author: ChaoZhang, Date: 2024-02-27 14:18:57



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:

  1. Provides clear entry and exit rules for more definitive trading decisions.

  2. Identifies reversal opportunities using technical indicators for improved decision accuracy.

  3. Dynamically calculates stop-loss and take-profit levels for better risk control.

  4. Systematic approach facilitates tracking and performance evaluation.

  5. Allows parameter optimization for adapting to different market conditions.

Risk Analysis

The strategy also carries the following risks:

  1. Reversal signals may give false signals resulting in losses.

  2. Improper stop-loss and take-profit settings may lead to excessive losses or failure to realize full profits.

  3. Improper parameter settings can lead to poor performance.

The main risk control measures include:

  1. Evaluate signal reliability to avoid false signals.

  2. Test and optimize stop-loss and take-profit parameters.

  3. Assess parameter robustness across different market conditions.

Optimization Directions

The strategy can be optimized in several aspects:

  1. Test more technical indicators to find more reliable reversal signals.

  2. Utilize machine learning methods to dynamically optimize stop-loss and take-profit levels.

  3. Incorporate evaluation of market biases using sentiment indicators etc. to improve signal accuracy.

  4. Optimize position sizing management for trend tracking.

  5. Evaluate stock characteristics to screen for best suited tickers for the strategy.


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.

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"}]

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)