Strategy vault / Mean reversion
Hedging Oscillation Reversal Strategy
The Hedging Oscillation Reversal strategy is a short-term trading strategy that identifies market reversal points using multiple indicators such as Bollinger Bands, Envelope Lines, ADX and Stochastics to take hedging…

Overview
The Hedging Oscillation Reversal strategy is a short-term trading strategy that identifies market reversal points using multiple indicators such as Bollinger Bands, Envelope Lines, ADX and Stochastics to take hedging positions around the reversal points. This strategy mainly uses Bollinger Bands and Envelope Lines to determine whether prices are excessively extended to confirm trading signals, while using ADX to determine trend strength and Stochastics to determine overbought/oversold areas, in order to establish hedging positions around reversal points.
Strategy Principle
The Hedging Oscillation Reversal strategy is based on the following judgment rules:
When the closing price exceeds the upper rail of the Bollinger Bands and also exceeds the upper rail of the Envelope Lines, it indicates that prices may be in an overbought state. At this point, if ADX is less than 30, it means that the trend strength is not strong. Meanwhile, if Stochastics is greater than 50, it means it is in an overbought area. Thus, short positions can be considered.
When the closing price is below the lower rail of the Bollinger Bands and also below the lower rail of the Envelope Lines, it indicates that prices may be in an oversold area. At this point, if ADX is less than 30, it means that the trend strength is not strong. Meanwhile, if Stochastics is less than 50, it means it is in an oversold area. Thus, long positions can be considered.
The stop loss exit condition for short positions is that the closing price is below the lower rail of the Bollinger Bands or the lower rail of the Envelope Lines, or Stochastics is less than 50.
The stop loss exit condition for long positions is that the closing price is above the upper rail of the Bollinger Bands or the upper rail of the Envelope Lines, or Stochastics is greater than 50.
Through these judgment rules, we can establish hedging positions around reversal points and profit from short-term price oscillations.
Advantage Analysis
This Hedging Oscillation Reversal strategy has the following advantages:
Using multiple indicators for judgment can effectively confirm trading signals and avoid false breakouts.
Trading around trend reversal points has a relatively high success rate.
Adopting a hedging operation method can effectively control risks.
The high trading frequency is suitable for short-term operations.
The source of income mainly comes from price fluctuations, not entirely dependent on trend reversals.
Risk Analysis
This Hedging Oscillation Reversal strategy also has some risks that need attention:
There is still a probability of reversal failure, which will lead to greater losses.
Frequent trading is prone to over-optimization.
Failure to grasp the reversal timing accurately may lead to enlarged losses.
There is a probability of trend mutations that need to be guarded against.
In response to these risks, we need to optimize indicator parameters, strictly control stop losses, and combine trend and fundamental analysis to determine the general direction.
Optimization Directions
This Hedging Oscillation Reversal strategy can also be optimized in the following directions:
Optimize indicator parameters to improve trading signal quality.
Increase fundamental factor judgments to avoid trading against the trend.
Incorporate V-shaped reversal pattern recognition to improve success rate.
Dynamically adjust the stop loss range.
Optimize capital management to strictly control single transaction loss.
Summary
The Hedging Oscillation Reversal strategy takes hedging positions around reversal points based on multiple indicator judgments, which has the advantages of high trading frequency and easy risk control. However, the risks of reversal trading cannot be ignored. We need to continuously optimize the strategy, strictly follow the trading rules, and make full use of this efficient short-term trading strategy.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_int_1 | 20 | Length BB |
| v_input_1_close | 0 | Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_float_1 | 2 | StdDev BB |
| v_input_int_2 | 20 | Length Envelope |
| v_input_2 | true | percent |
| v_input_3 | false | exponential |
| v_input_4 | 14 | ADX Smoothing |
| v_input_5 | 14 | DI Length |
| v_input_int_3 | 50 | %K Length |
| v_input_int_4 | 20 | %K Smoothing |
Source Pine Script
/*backtest
start: 2023-12-12 00:00:00
end: 2023-12-19 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © exlux99
//@version=5
strategy("Contrarian Scalping Counter Trend",overlay=true)
//bollinger bands
length = input.int(20, minval=1, title="Length BB")
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev BB")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
//envelope
len = input.int(20, title="Length Envelope", minval=1)
percent = input(1.0)
exponential = input(false)
envelope = exponential ? ta.ema(src, len) : ta.sma(src, len)
k = percent/100.0
upper_env = envelope * (1 + k)
lower_env = envelope * (1 - k)
//adx
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
//stochastic
periodK = input.int(50, title="%K Length", minval=1)
smoothK = input.int(20, title="%K Smoothing", minval=1)
stock = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
short=close> upper and close >upper_env and sig < 30 and stock > 50
long=close< lower and close <lower_env and sig < 30 and stock < 50
short_exit= close < lower or close<lower_env or stock <50
long_exit=close > lower or close>lower_env or stock >50
strategy.entry("short",strategy.short,when=short)
strategy.close("short",when=short_exit)
strategy.entry("long",strategy.long,when=long)
strategy.close('long',when=long_exit)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-20. 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/Hedging-Oscillation-Reversal-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
- Intraday Single Candle Indicator Combo Short Term Trading StrategyPine Script · Mean reversion · 1d
- Multi factor Quantitative Trading Strategy 440526Pine Script · Mean reversion · 4h
- Advanced 15 Minute Chart Trading Signal StrategyPine Script · Mean reversion · 3h
- Reversal Trading Strategy with Bollinger Bands RSI ADX and ATRPine Script · Mean reversion · 1h
- Dual Indicator Slight Reversal Trading StrategyPine Script · Mean reversion · 15m
- Multi Factor Strategy CombinationPine Script · Mean reversion · 1m