변화율 거래 전략

저자:차오장, 날짜: 2023-09-28 11:26:44
태그:

전반적인 설명

이 전략은 구매/판매 신호를 결정하기 위해 시간에 따른 변화율을 계산합니다. 이는 거래자가 단기 가격 변동에서 기회를 잡는 데 도움이 될 수 있습니다.

전략 논리

이 전략은 주로 다음의 지표에 기초합니다.

  1. 단기 트렌드를 측정하기 위한 빠른 단순 이동 평균 (전산 14일)
  2. 느린 단순한 이동 평균 (전환 100일): 장기 트렌드를 측정하기 위해
  3. 참조 간단한 이동 평균 (전환 30일): 전체 방향을 결정하기 위해
  4. 변화율: 가격 변동의 크기를 판단하기 위해 뷰백 기간 동안의 최고/최저 가격 (예정 12 바) 을 기준으로 계산됩니다.

입국특정규칙:

  1. 기준 SMA 이하의 가격
  2. 미리 설정된 낮은 ROC 기준 이상의 ROC (예정 2.3%)
  3. 빠른 SMA 상승과 느린 SMA 하락, 잠재적인 교차를 나타냅니다.

출입특정 규칙:

  1. 기준 SMA 이상의 가격
  2. 미리 설정된 높은 ROC 기준 이상의 ROC (예정 4.7%)
  3. 3개의 연속 상승 바
  4. 현재 이익 > 0
  5. 느린 SMA보다 빠른 SMA

포지션 크기는 레버리지에 대한 전체 자금의 비율 (기본 96%) 이다.

이점 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 변동을 감지하기 위해 ROC를 사용하면 더 높은 수익을 위해 상승/하락 움직임을 캡처 할 수 있습니다.

  2. 빠른 / 느린 SMA를 결합하면 낮은 / 높은 점을 더 정확하게 식별 할 수 있습니다.

  3. 참조 SMA는 단기 소음으로 인한 방해를 피하기 위해 전반적인 방향을 제공합니다.

  4. 손익을 줄이고 하향 위험을 줄여줍니다.

  5. 포지션 사이즈의 레버리지는 이윤을 증폭시킵니다.

전체적으로, 전략은 ROC, SMA 및 기타 도구를 효과적으로 가격 변동에 활용합니다. 변동성 시장에서 좋은 결과를 얻을 수 있습니다.

위험 분석

이 전략은 또한 다음과 같은 위험을 가지고 있습니다.

  1. 잘못된 ROC 및 SMA 매개 변수는 신호를 놓치거나 나쁜 거래를 일으킬 수 있습니다. 다른 시장에 최적화가 필요합니다.

  2. 과도한 포지션 크기는 위험을 증가시킵니다. 주문 비율은 테스트되고 조정되어야합니다.

  3. 트레일링 스톱 로스는 불안한 시장에서 조기 종료 될 수 있습니다. 스톱 로스 비율은 조정 될 수 있습니다.

  4. 다양한 시장에서 휘파람에 취약합니다. 트렌드 필터와 리스크 관리를 포함해야 합니다.

  5. 백테스트 과도한 적합성 위험. 안정성은 시장을 통해 실시간 거래를 통해 확인되어야합니다.

위험은 매개 변수 최적화, 포지션 크기, 스톱 로스 조정, 견고성 테스트 등을 통해 관리 될 수 있습니다.

최적화 방향

이 전략은 다음과 같은 측면에서 개선될 수 있습니다.

  1. 신호 정확성을 높이기 위해 변동성, 부피와 같은 다른 기술적 지표를 추가합니다.

  2. 트레이드 빈도를 줄여 화프사 영향을 최소화함으로써 트레이드 수를 최적화합니다.

  3. 핵심 가격 수준에 대한 브레이크오웃 기술을 적용해야 합니다.

  4. 기계 학습을 사용하여 자동으로 매개 변수를 최적화합니다.

  5. 다른 시장과 시간 프레임에 걸쳐 견고성을 테스트합니다.

  6. 주식, 외환 등과 같은 다양한 제품에 대한 전문 매개 변수를 조정합니다.

  7. 실시간 결과를 바탕으로 신호와 위험 통제를 지속적으로 개선합니다.

요약

이 전략은 ROC 및 SMA 분석을 사용하여 단기 오스실레이션 주위에서 거래 기회를 식별합니다. 빠른 변동을 활용하는 데 도움이되지만 적절한 리스크 통제도 필요합니다. 미세한 조정 매개 변수, 위치 사이징, 스톱 손실 및 견고성 테스트는 안정성과 적응력을 향상시킬 수 있습니다. 전략은 정량화 된 거래의 참조 템플릿으로 작용하지만 다른 시장에 맞춤화가 필요합니다.


/*backtest
start: 2022-09-21 00:00:00
end: 2023-09-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// @version=4
// Author: Sonny Parlin (highschool dropout)
// Best if run on 5m timeframe
strategy(shorttitle="ROC+Strategy", title="Rate of Change Strategy",
                                      overlay=true,  currency=currency.USD,
                                      initial_capital=10000)

// Inputs and variables
ss = input(14, minval=10, maxval=50, title="SMA Fast (days)")
ff = input(100, minval=55, maxval=200, title="SMA Slow (days)")
ref = input(30, minval=20, maxval=50, title="SMA Reference (days)")
lowOffset = input(0.023, "ROC Low (%)", minval=0, step=0.01)
highOffset = input(0.047, "ROC High (%)", minval=0, step=0.01)
orderStake = input(0.96, "Order Stake (%)", minval=0, step=0.01)
lookback = input(12, "Lookback Candles", minval=1, step=1) 

// SMA
smaFast = sma(close, ss)
smaSlow = sma(close, ff)
smaRef = sma(close, ref)
ROC = (max(close[lookback],close) - min(close[lookback],close)) / max(close[lookback],close)

// Set up SMA plot but don't show by default
plot(smaFast, "smaFast", color=#00ff00, display = 0)
plot(smaSlow, "smaSlow", color=#ff0000, display = 0)
plot(smaRef, "smaRef", color=#ffffff, display = 0)

// The buy stratey:
// Guard that the low is under our SMA Reference line 
// Guard that the rate of change over the lookback period is greater than our 
// ROC lowOffset %, default is 0.023. (low < smaRef) and (ROC > lowOffset)
// SMA fast is on the rise and SMA slow is falling and they are very likely
// to cross. (rising(smaFast,1)) and (falling(smaSlow, 1)) 
enterLong = (low < smaRef) and (ROC > lowOffset) and (rising(smaFast,1)) and (falling(smaSlow,1)) 

// The sell Strategy:
// Guard that close is higher than our SMA reference line and that the rate of 
// change over the lookback period is greater than our highOffset %, default
// is 0.047. (close > smaRef) and (ROC > highOffset)
// Guard that close has risen by 3 candles in a row (rising(close,3)) 
// Guard that we currently have profit (strategy.openprofit > 0)
// Guard that SMA fast is higher than smaSlow (smaFast > smaSlow)
// If it keeps going up past our close position the trailing stoploss will kick in!
enterShort = (close > smaRef) and (ROC > highOffset) and (rising(close,3)) and (strategy.openprofit > 0) and (smaFast > smaSlow)

// Order size is based on total equity
// Example 1:
// startingEquity = 2000
// close = 47434.93
// orderStake = 0.45
// (2,000 × orderStake) / close = orderSize = 0.0189733599 = approx $900

// Example 2:
// startingEquity = 2000
// close = 1.272
// orderStake = 0.45
// (startingEquity × orderStake) / close = orderSize = 707.5471698113 = approx $900
orderSize = (strategy.equity * orderStake) / close

// Trailing Stoploss
// I'm using 2.62 as my default value, play with this for different results.
longTrailPerc = input(title="Trailing Stoploss (%)",
     type=input.float, minval=0.0, step=0.1, defval=3.62) * 0.01
     
longStopPrice = 0.0

longStopPrice := if (strategy.position_size > 0)
    stopValue = close * (1 - longTrailPerc)
    max(stopValue, longStopPrice[1])
else
    0

if (enterLong)
    strategy.entry("Open Long Position", strategy.long, orderSize, when=strategy.position_size <= 0)
    
if (enterShort)
    strategy.exit(id="Close Long Position", stop=longStopPrice)


//plot(strategy.equity)

더 많은