Reverse Trading Strategy Based on Overlapping Price Differentials
The main idea of this strategy is to use the overlapping price differentials to judge market trends. It goes long when the differential reverses from negative to positive, and goes short when the differential…

Overview
The main idea of this strategy is to use the overlapping price differentials to judge market trends. It goes long when the differential reverses from negative to positive, and goes short when the differential reverses from positive to negative. It belongs to reverse trading strategies.
Principle
The strategy first calculates the overlapping price differential (Close-Close[1]), which is today's close price minus yesterday's close price, and then calculates the sum of the differentials over the past 30 days. It generates a long signal when the sum reverses from negative to positive, and generates a short signal when the sum reverses from positive to negative. It is a typical reverse trading strategy.
Specifically, the strategy maintains three indicators:
- ff: Sum of price differentials over the past 30 days
- dd1: 15-day weighted moving average of ff
- dd2: 30-day weighted moving average of ff
It generates a long signal when ff changes from negative to positive, i.e. from less than 0 to greater than 0, and dd1 also changes from negative to positive.
It generates a short signal when ff changes from positive to negative, i.e. from greater than 0 to less than 0, and dd1 also changes from positive to negative.
After going long or short, take profit and stop loss lines will be set.
Advantages
The strategy has the following advantages:
- The logic is clear and easy to understand and implement.
- It captures good entry timing at market turning points by utilizing price reversal features.
- False breakouts can be filtered out with the dual confirmation mechanism.
- Customizable parameters adapt to different market environments.
Risks
There are also some risks for the strategy:
- High probability of reversal failure, likely to be stopped out in range-bound markets.
- Improper parameter settings may lead to frequent trading and increased transaction costs.
- Other indicators should be incorporated to filter entries, avoiding chasing tops and bottoms.
The corresponding solutions are:
- Set proper stop loss percentage to control single loss.
- Optimize parameters to find the best combination.
- Add filtering conditions to avoid unnecessary entries.
Optimization Directions
The strategy can be optimized in the following aspects:
- Add volume filter, requiring enlarged volume on breakouts.
- Incorporate trend indicators to avoid countertrend operations.
- Dynamically adjust parameters to adapt to changing market conditions.
- Optimize stop loss mechanism, such as trailing stop loss.
Summary
The strategy judges market turning points by calculating price differential reversals. It is a typical reverse trading strategy. The logic is clear and easy to implement with some practical value. But there are also risks that need to be further optimized to adapt to market changes. Overall, the strategy provides a basic framework for quantitative trading, which can be built upon and extended.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 30 | SUMM |
| v_input_2 | 15 | Signalperiod |
| v_input_3 | 30 | Info |
| v_input_4 | 95 | profit |
| v_input_5 | 95 | loss |
Source Pine Script
/*backtest
start: 2023-12-07 00:00:00
end: 2023-12-14 00:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy(title="Fst",currency="USD",initial_capital=100000)
//Length0 = input(30, title="fastperiod", minval=1)
Length = input(30, title="SUMM")
Length1 = input(15, title="Signalperiod", minval=1)
Length2= input(30, title="Info", minval=1)
profit=input(95, title="profit", minval=1)
loss=input(95, title="loss", minval=1)
//f=iff(close>open,close-open,iff(close>open[1],close[1]-open[1],0))
f=0.0
dd1=0.0
dd2=0.0
ff=0.0
ff0=0.0
f:=close-close[1]
ff:=sum(f,Length)
//ff0:=sum(f,Length0)
dd1:=wma(ff,Length1)
dd2:=wma(ff,Length2)
bull=ff<0 and dd1<0 and ff[1]<dd1 and ff>dd1 and abs(ff)>20
bear=ff>0 and dd1>0 and ff[1]>dd1 and ff<dd1 and abs(ff)>20
if(bull)
strategy.entry("long", strategy.long)
strategy.exit("exit", "long", profit = close*profit/1000, loss=close*loss/1000)
strategy.close("long", when = bear)
plotchar(bull,size=size.small,location=location.bottom)
plot(ff,color=black,linewidth=2)
plot(ff0,color=green,linewidth=2)
plot(wma(ff,Length1),color=red,linewidth=2)
plot(wma(ff,Length2),color=blue,linewidth=2)
plot(wma(ff,Length1)-wma(ff,Length2),color=green,style=columns)
plot(0,linewidth=1,color=black)
plot(500,linewidth=1,color=red)
plot(-500,linewidth=1,color=red)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-15. 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/Reverse-Trading-Strategy-Based-on-Overlapping-Price-Differentials.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
- Adaptive Multi Period Trading Strategy Based on Wave Trend Momentum BreakoutPine Script · Breakout · 2h
- Advanced Multi Pattern Breakout Trading StrategyPine Script · Breakout · 1d
- Dual Thrust StrategyPine Script · Breakout · 10m
- Dynamic Bollinger Bands Breakout Quantitative Trading StrategyPine Script · Breakout · 2d
- Dynamic Dual Moving Average Breakthrough Trading System Dynamic Dual Moving Average Breakthrough Trading SystemPine Script · Breakout · 1d
- Flexible Long Short Trading Strategy Based on Keltner ChannelsPine Script · Breakout · 1d