더블 이동 평균 아비트라지 전략


생성 날짜: 2023-11-24 14:21:06 마지막으로 수정됨: 2023-11-24 14:21:06
복사: 0 클릭수: 771
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

더블 이동 평균 아비트라지 전략

개요

이 전략은 쌍평선 형태를 이용한 중매운동을 하는 전략이다. 이 전략은 123 형태 반전과 제한 거래량 요소 ((FVE) 의 두 가지 자 전략을 결합하여, 둘 다 동시에 구매 또는 판매 신호를 발송할 때 중매운동을 한다.

전략 원칙

123 형태 역전

이 하위 전략은 울프 젠센의 “어떻게 내가 선물 시장에서 수익을 3배로 올릴 수 있는가”라는 책에서 유래했다. 이 하위 전략은 다음과 같은 조건에서 신호를 발산한다:

  • 2일 연속으로 상승하고 9일 연속으로 50이하로 떨어질 때, 더 많은 것을 해라.
  • 2일 연속으로 하락하고 9일째로 엑스스토치 지표가 50보다 높을 때, 공백을 다.

유한 거래량 요소 (FVE)

FVE는 순수한 거래량 지표이다. 그것은 가격의 상승과 거래량의 크기에 따라 자금이 유입되거나 유출되는지를 판단한다.

최근 두 개의 바의 FVE 지표가 동시에 상승하거나 하락할 때 신호를 낸다.

우위 분석

이 전략은 시장의 추세와 자본의 흐름을 판단하는 두 가지 지표와 결합하여 잘못된 신호를 효과적으로 방지 할 수 있습니다. 그리고 두 가지 하위 전략 모두 약간의 역전적 특성을 가지고 있으므로 수익을 얻기 위해 중매 작업을 수행 할 수 있습니다.

또한, 쌍평평선 형태가 나타나면, 단기 및 중기 경향을 일관되게 나타내고, 따라서 더 강한 안정성을 갖는다.

위험 분석

이 전략은 평평선 형태에 의존하며, 시장이 흔들릴 때, 잘못된 신호가 발생하여 손실이 발생할 수 있다. 또한, 역전 실패는 일반적인 위험이다.

적절한 매개 변수를 조정하여 전략을 더 안정적으로 만들 수 있으며, 위험을 제어하기 위해 스톱로스를 설정할 수 있다.

최적화 방향

더 많은 종류의 평균선 지표를 테스트하여 최적의 매칭을 찾을 수 있다. 또한 다른 보조 판단 지표, 예를 들어 강약 지표, 변동률 지표 등이 잘못된 신호를 피하기 위해 도입될 수 있다.

또한, 시장 상황에 따라 동적으로 매개 변수를 조정하여 전략을 더 적응시킬 수 있는 방법을 연구할 수 있다. 또한, 매개 변수를 스스로 적응할 수 있도록 기계 학습과 신경 네트워크 알고리즘을 탐구할 수 있다.

요약하다

이 쌍평선위탁전략은 두 가지 반전방향 지표를 통합하여 판단하여 위험을 어느 정도 피할 수 있다. 그러나 평선형태에 의존하기 때문에 전략을 더 안정적으로 만들기 위해 추가적인 최적화가 필요하다. 전체적으로 이 전략은 단선위탁 거래에 대한 기초적인 프레임워크를 제공하고 있으며, 더 많은 연구를 할 가치가 있다.

전략 소스 코드
/*backtest
start: 2023-10-24 00:00:00
end: 2023-11-23 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 25/08/2020
// This is combo strategies for get a cumulative signal. 
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The 
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close 
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. 
// The strategy sells at market, if close price is lower than the previous close price 
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// The FVE is a pure volume indicator. Unlike most of the other indicators 
// (except OBV), price change doesn?t come into the equation for the FVE (price 
// is not multiplied by volume), but is only used to determine whether money is 
// flowing in or out of the stock. This is contrary to the current trend in the 
// design of modern money flow indicators. The author decided against a price-volume 
// indicator for the following reasons:
// - A pure volume indicator has more power to contradict.
// - The number of buyers or sellers (which is assessed by volume) will be the same, 
//     regardless of the price fluctuation.
// - Price-volume indicators tend to spike excessively at breakouts or breakdowns.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
    vFast = sma(stoch(close, high, low, Length), KSmoothing) 
    vSlow = sma(vFast, DLength)
    pos = 0.0
    pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
	         iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) 
	pos


FVE(Period,Factor) =>
    pos = 0
    nRes = 0.0
    xhl2 = hl2
    xhlc3 = hlc3
    xClose = close
    xVolume = volume
    xSMAV = sma(xVolume, Period)
    nMF = xClose - xhl2 + xhlc3 - xhlc3[1]
    nVlm = iff(nMF > Factor * xClose / 100,  xVolume, 
             iff(nMF < -Factor * xClose / 100, -xVolume, 0))
    nRes := nz(nRes[1],0) + ((nVlm / xSMAV) / Period) * 100
    pos := iff(nRes > nRes[1] and nRes > nRes[2], 1,
             iff(nRes < nRes[1] and nRes < nRes[2], -1, nz(pos[1], 0)))   
    pos

strategy(title="Combo Backtest 123 Reversal & Finite Volume Elements (FVE)", shorttitle="Combo", overlay = true)
Length = input(15, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
Period = input(18, minval=1)
Factor = input(0.6, minval=0.1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posFVE = FVE(Period,Factor)
pos = iff(posReversal123 == 1 and posFVE == 1 , 1,
	   iff(posReversal123 == -1 and posFVE == -1, -1, 0)) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1 , 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )