이 글은 평균 회귀와 트렌드 추적 기술을 동시에 사용하는 양자 거래 전략을 자세히 소개합니다. 이 전략은 트렌드 상황에서 역전 거래와 트렌드를 추적하는 동방향 거래를 목표로합니다.
1 전략
이 전략은 주로 간단한 이동 평균과 RSI 지표로 거래 신호를 생성합니다:
가격이 200주기 이동 평균보다 낮을 때, 현재 하향 단계에 있다고 판단한다.
RSI가 20보다 낮을 때 역동적인 평균 회귀 거래를 수행합니다.
가격이 200주기 이동 평균보다 높을 때, 현재 상승 단계에 있다고 판단합니다.
가격이 이동 평균을 넘어서면, 진행되는 트렌드를 추적하는 거래를 수행한다.
평지 조건은 RSI가 80보다 높거나 가격이 이동 평균보다 떨어지는 정도이다.
평균값 회귀와 트렌드 추적을 각각 설정할 수 있는 거래 포지션
이 전략은 평균 회귀와 트렌드 추적 기술을 통합하여 다양한 단계에서 적절한 작업을 수행합니다.
2 전략적 장점
이 전략은 다음과 같은 장점을 가지고 있습니다.
이 두 가지 기술을 결합하면 전략의 적응성을 높일 수 있습니다.
트렌드 시장과 흔들리는 시장에서 거래 기회를 찾을 수 있습니다.
포지션을 조정하여 다양한 모드에서의 위험을 제어할 수 있다.
매개 변수 설정은 간단하고 실행하기 쉽다.
잠재적인 위험
그러나 이 전략에는 다음과 같은 위험도 있습니다.
이동 평균과 RSI와 같은 지표들은 가짜 돌파에 취약합니다.
두 가지 거래 방식의 전환이 늦어질 수 있습니다.
장기적인 수익을 얻기 위해 약간의 인출이 필요합니다.
네 가지 내용
이 글은 평균 회귀와 트렌드 추적 기술을 활용한 양적 거래 전략에 대해 자세히 설명한다. 이 전략은 다양한 시장 단계에서 거래를 할 수 있으며, 적응력을 향상시킵니다. 그러나 지표 실패와 패턴 전환 지연의 위험을 방지해야합니다.
/*backtest
start: 2022-09-07 00:00:00
end: 2023-04-05 00:00:00
period: 1d
basePeriod: 1h
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/
// © I11L
//@version=5
strategy("Mean Reversion and Trendfollowing", overlay=true, pyramiding=1, default_qty_value=100000, initial_capital=100000, default_qty_type=strategy.cash, process_orders_on_close=false, calc_on_every_tick=false)
// Input for the starting date
start_date = input(timestamp("1 Feb 2000 12:00"), title="Starting Date")
enableMeanReversion = input.bool(true)
enableTrendfollowing = input.bool(true)
trendPositionFactor = input.float(1)
meanReversionPositionFactor = input.float(0.5)
// Convert the input string to a timestamp
start_ts = timestamp(year(start_date), month(start_date), dayofmonth(start_date), 0, 0)
// Check if the current bar's time is greater than or equal to the start timestamp
start_condition = time >= start_ts
var tradeOrigin = ""
sma200 = ta.sma(close,200)
rsi2 = ta.rsi(close,2)
isMeanReversionMode = close < sma200 or not(enableTrendfollowing)
isTrendfollowingMode = close > sma200 or not(enableMeanReversion)
isRsiBuy = rsi2 < 20 and enableMeanReversion
isRsiClose = rsi2 > 80 and enableMeanReversion
isSmaBuy = close > sma200 and enableTrendfollowing
isSmaClose = close < sma200 * 0.95 and enableTrendfollowing
isBuy = (isMeanReversionMode and isRsiBuy) or (isTrendfollowingMode and isSmaBuy)
positionSizeFactor = isSmaBuy ? trendPositionFactor : meanReversionPositionFactor
// Only execute the strategy after the starting date
if (start_condition)
if (isBuy and strategy.opentrades == 0)
tradeOrigin := isSmaBuy ? "SMA" : "RSI"
strategy.entry("My Long Entry Id", strategy.long, qty=(strategy.equity / close) * positionSizeFactor, comment=str.tostring(positionSizeFactor))
isClose = tradeOrigin == "SMA" ? isSmaClose : isRsiClose
if (isClose)
strategy.exit("Exit", limit = close)
plot(sma200)
plot(sma200 * 0.95, color=color.orange)