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.
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:
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.
The strategy has the following advantages:
There are also some risks for the strategy:
The corresponding solutions are:
The strategy can be optimized in the following aspects:
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.
/*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)