This article introduces a quantitative trading strategy based on a percentage threshold. The strategy determines the timing of buying and selling by setting a percentage threshold and selecting an appropriate time period. When the price rises or falls above or below the specified percentage threshold relative to the previous closing price, it triggers a buy or sell signal. This strategy can be flexibly adjusted according to the user’s risk preferences and market conditions, and is suitable for trading various financial instruments.
The core of this strategy is to generate trading signals based on the percentage change in price. First, the user needs to set a percentage threshold, which represents the magnitude of price change relative to the previous closing price. At the same time, the user also needs to choose a time period, such as 1 minute, 1 hour, 1 day, etc., to calculate the high, low, and closing prices within that time frame. The strategy monitors market prices in real-time. When the highest price of the current time period exceeds the previous closing price plus the threshold, it triggers a buy signal; when the lowest price of the current time period falls below the previous closing price minus the threshold, it triggers a sell signal. If a sell signal is triggered while holding a long position, the strategy closes the long position; if a buy signal is triggered while holding a short position, the strategy closes the short position. In this way, the strategy can make timely trades when price fluctuations are large to capture potential profits.
This article introduces a quantitative trading strategy based on a percentage threshold, which automatically generates buy and sell signals by setting a percentage threshold for price changes and a time period. The strategy is simple to operate, highly flexible, and widely applicable, but also faces risks such as market volatility, parameter settings, and overfitting. By incorporating stop-loss and take-profit mechanisms, dynamically adjusting parameters, and combining with other technical indicators, the strategy’s performance can be further optimized to enhance its effectiveness in actual trading.
/*backtest start: 2023-05-28 00:00:00 end: 2024-06-02 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("GBS Percentage", overlay=true) // Define input options for percentage settings and timeframe percentage = input.float(1.04, title="Percentage Threshold", minval=0.01, step=0.01) / 100 timeframe = input.timeframe("D", title="Timeframe", options=["1", "3", "5", "15", "30", "60", "240", "D", "W", "M"]) // Calculate high, low, and close of the selected timeframe high_timeframe = request.security(syminfo.tickerid, timeframe, high) low_timeframe = request.security(syminfo.tickerid, timeframe, low) close_timeframe = request.security(syminfo.tickerid, timeframe, close) // Calculate the percentage threshold based on the previous close threshold = close_timeframe[1] * percentage // Define conditions for Buy and Sell buyCondition = high_timeframe > (close_timeframe[1] + threshold) sellCondition = low_timeframe < (close_timeframe[1] - threshold) // Entry and exit rules if (buyCondition) strategy.entry("Buy", strategy.long) if (sellCondition) strategy.entry("Sell", strategy.short) // Close the positions based on the conditions if (sellCondition) strategy.close("Buy") if (buyCondition) strategy.close("Sell") // Plot Buy and Sell signals on the chart plotshape(series=buyCondition, title="Buy Entry", color=color.green, style=shape.triangleup, location=location.belowbar) plotshape(series=sellCondition, title="Sell Entry", color=color.red, style=shape.triangledown, location=location.abovebar) // Plot the equity curve of the strategy plot(strategy.equity, title="Equity", color=color.blue, linewidth=2)