
평균 회귀 동력 전략은 단기 가격 평균을 추적하는 트렌드 거래 전략이다. 그것은 평균 회귀 지표와 동력 지표를 결합하여 시장의 중기 경향에 대한 판단을 구현한다.
이 전략은 우선 가격의 평균 회귀선과 표준 차이를 계산한다. 그리고 상위 임계와 하위 임계 파라미터를 결합하여 잘 설정된 마이너스를 사용하여 가격이 평균 회귀선과 표준 차이를 넘어서는지 계산한다. 넘어서면 거래 신호가 발생한다.
다중 헤드 신호의 경우, 가격의 평균 회귀선보다 낮은 표준차, 클로즈 가격의 LENGTH 주기 SMA 평균선보다 낮은, 그리고 TREND SMA 평균선보다 높은, 이 세 가지 조건을 충족하면 다방향의 포지션을 열 수 있습니다. 매매 조건은 가격의 LENGTH 주기 SMA 평균선입니다.
공백 신호의 경우, 값이 평균 회귀선보다 높은 표준 차차, 클로즈 가격이 LENGTH 주기 SMA 평균선보다 높고, TREND SMA 평균선보다 낮은 것이 필요하며, 이 세 가지 조건을 충족하면 공백 방향의 입장을 열 수 있습니다. 평점 조건은 가격 아래 LENGTH 주기 SMA 평균선입니다.
이 전략은 퍼센트 수익 목표와 퍼센트 중지 손실을 결합하여 스톱 스톱 손실 관리를 수행합니다.
Exit 방식은 이동 평균을 뚫거나 선형 회귀를 뚫을 수 있다.
다방위 쌍방 거래, 트렌드 필터, 스톱 스톱 손실 등의 조합을 통해 시장의 중기 경향에 대한 판단과 추적이 가능해졌다.
평균 회귀 지표는 가격의 가치 중심에서 벗어난지 여부를 효과적으로 판단할 수 있습니다.
동력 지표 SMA는 단기 시장 소음을 필터링합니다.
다중방향 거래, 모든 트렌드 기회를 포착할 수 있다.
스톱패스 메커니즘은 위험을 효과적으로 통제할 수 있습니다.
선택 가능한 Exit 방식, 시장 환경에 적응할 수 있는 유연성
전체적인 트렌드 트레이딩 전략으로 중기 트렌드를 파악할 수 있습니다.
평균 회귀 지표는 변수 설정에 민감하며, 값을 잘못 설정하면 잘못된 신호가 발생할 수 있다.
대규모 지진이 발생했을 때 너무 빈번하게 중단될 수 있습니다.
트레이딩 빈도가 너무 높을 수 있으며 트레이딩 비용과 슬라이드 포인트 위험을 증가시킬 수 있습니다.
거래 품종이 유동성이 부족할 때 슬라이드 포인트 제어가 바람직하지 않을 수 있습니다.
다중공간 거래의 위험성, 신중한 자금 관리
이러한 위험은 변수 최적화, 스톱로스 방식 조정, 자금 관리 등의 방법으로 제어할 수 있다.
평균 회귀와 동력 지표의 파라미터를 최적화하여 다른 품종의 특성에 더 적합하게 설정
트렌드를 판단하는 지표를 늘리고, 트렌드를 식별하는 능력을 향상시킵니다.
시장의 큰 변동에 대응할 수 있도록 손실을 막는 전략을 최적화
포지션 관리 모듈을 추가하여 시장 조건에 따라 포지션 크기를 조정합니다.
최대 회수 제어, 순수 곡선 제어 등과 같은 더 많은 풍력 제어 모듈을 추가합니다.
전략 변수를 자동으로 최적화하기 위해 기계 학습 방법을 고려하십시오.
요약하자면, 평균값 회귀동량 전략은 단순하고 효과적인 지표 디자인을 통해 중기값 회귀 트렌드를 포착합니다. 전략은 강한 적응성과 보편성을 가지고 있지만, 또한 위험이 있습니다. 지속적으로 최적화하고 다른 전략을 조합하여 더 나은 성과를 얻을 수 있습니다.
/*backtest
start: 2023-10-15 00:00:00
end: 2023-11-14 00:00:00
period: 1h
basePeriod: 15m
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/
// © GlobalMarketSignals
//@version=4
strategy("GMS: Mean Reversion Strategy", overlay=true)
LongShort = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
Lookback = input(title="Length", type=input.integer, defval=10, minval=0)
LThr1 = input(title="Upper threshold", type=input.float, defval=1, minval=0)
LThr = input(title="Lower threshold", type=input.float, defval=-1, maxval=0)
src = input(title="Source", type=input.source, defval=close)
LongShort2 = input(title="Linear Regression Exit or Moving Average Exit?", type=input.string, defval="MA", options=["LR", "MA"])
SMAlenL = input(title="MA/LR Exit Length", type = input.integer ,defval=10)
SMALen2 = input(title="Trend SMA Length", type = input.integer ,defval=200)
AboveBelow = input(title="Above or Below Trend SMA?", type=input.string, defval="Above", options=["Above", "Below", "Don't Include"])
PTbutton = input(title="Profit Target On/Off", type=input.bool, defval=true)
ProfitTarget = input(title="Profit Target %", type=input.float, defval=1, step=0.1, minval=0)
SLbutton = input(title="Stop Loss On/Off", type=input.bool, defval=true)
StopLoss = input(title="Stop Loss %", type=input.float, defval=-1, step=0.1, maxval=0)
x = (src-linreg(src,Lookback,0))/(stdev(src,Lookback))
plot(linreg(src,Lookback,0))
//PROFIT TARGET & STOPLOSS
if PTbutton == true and SLbutton == true
strategy.exit("EXIT", profit=((close*(ProfitTarget*0.01))/syminfo.mintick), loss=((close*(StopLoss*-0.01))/syminfo.mintick))
else
if PTbutton == true and SLbutton == false
strategy.exit("PT EXIT", profit=((close*(ProfitTarget*0.01))/syminfo.mintick))
else
if PTbutton == false and SLbutton == true
strategy.exit("SL EXIT", loss=((close*(StopLoss*-0.01))/syminfo.mintick))
else
strategy.cancel("PT EXIT")
////////////////////////
//MOVING AVERAGE EXIT//
//////////////////////
if LongShort=="Long Only" and AboveBelow=="Above" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close>sma(close,SMALen2))
strategy.close("LONG", when = close>sma(close,SMAlenL))
if LongShort=="Long Only" and AboveBelow=="Below" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close<sma(close,SMALen2))
strategy.close("LONG", when = close>sma(close,SMAlenL))
if LongShort=="Long Only" and AboveBelow=="Don't Include" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) )
strategy.close("LONG", when = close>sma(close,SMAlenL))
///////
if LongShort=="Short Only" and AboveBelow=="Above" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close>sma(close,SMALen2))
strategy.close("SHORT", when = close<sma(close,SMAlenL))
if LongShort=="Short Only" and AboveBelow=="Below" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close<sma(close,SMALen2))
strategy.close("SHORT", when = close<sma(close,SMAlenL))
if LongShort=="Short Only" and AboveBelow=="Don't Include" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) )
strategy.close("SHORT", when = close<sma(close,SMAlenL))
//////
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close>sma(close,SMALen2))
strategy.close("LONG", when = close>sma(close,SMAlenL))
if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close<sma(close,SMALen2))
strategy.close("LONG", when = close>sma(close,SMAlenL))
if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) )
strategy.close("LONG", when = close>sma(close,SMAlenL))
///////
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close>sma(close,SMALen2))
strategy.close("SHORT", when = close<sma(close,SMAlenL))
if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close<sma(close,SMALen2))
strategy.close("SHORT", when = close<sma(close,SMAlenL))
if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) )
strategy.close("SHORT", when = close<sma(close,SMAlenL))
/////////////////
//LIN REG EXIT//
///////////////
if LongShort=="Long Only" and AboveBelow=="Above" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
if LongShort=="Long Only" and AboveBelow=="Below" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
if LongShort=="Long Only" and AboveBelow=="Don't Include" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) )
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
///////
if LongShort=="Short Only" and AboveBelow=="Above" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
if LongShort=="Short Only" and AboveBelow=="Below" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
if LongShort=="Short Only" and AboveBelow=="Don't Include" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) )
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
//////
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) )
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
///////
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) )
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))