반전 및 자금 흐름 조합 전략


생성 날짜: 2023-09-17 22:37:54 마지막으로 수정됨: 2023-09-17 22:58:03
복사: 0 클릭수: 651
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이 전략은 123개의 반전 형태와 자금 유동량 지표를 결합하여 트렌드 추적과 반전 거래를 구현한다.

전략 원칙

우선, 123 역전 형태를 통해 가격 역전점을 판단한다. 구체적으로, 만약 상반기 2일 종전 가격이 하락하면, 3일 종전 가격이 상승하고, 무작위 지표가 하락값보다 낮으면, 구매 신호를 발생시킨다; 만약 상반기 2일 종전 가격이 상승하면, 3일 종전 가격이 하락하고, 무작위 지표가 하락값보다 높으면, 판매 신호를 발생시킨다.

다음으로, 빠른 선과 느린 선의 자금 유동량 지표를 계산한다. 빠른 선은 근래의 자금 유동량의 지수 이동 평균으로 구성되며, 느린 선은 더 긴 주기의 지수 이동 평균이다. 빠른 선이 느린 선보다 높으면, 자금 유입으로 판단하여 구매 신호를 생성한다. 반대로 판매 신호를 생성한다.

마지막으로, 123 반전 형태와 자금 유동성 지표의 신호를 결합하여, 두 신호가 일치하면 거래 신호를 생성한다.

우위 분석

  • 여러 신호를 조합하여 신호의 신뢰도를 높일 수 있다.
  • 123 반전 형태는 반전점을 잡을 수 있고, 자금 유동량 지표는 자금 흐름을 판단한다.
  • 다양한 품종과 주기의 성능을 최적화하기 위해 매개 변수를 조정할 수 있다.
  • 이 중 하나의 신호만 사용해서 거래할 수 있다.

위험 분석

  • 123 회전 형태는 잘못된 신호를 생성할 수 있다.
  • 하지만, 이 모든 것은 금융시스템이 제대로 작동하지 않고 있다는 것을 보여준다.
  • 다중 신호 조합, 전략 논리는 상대적으로 복잡하다.
  • 과잉 거래를 방지하기 위해 최적화해야 합니다.

역형의 신뢰성을 높이고, 자금 유동량 지표의 민감성을 설정하고, 손해 중지 논리를 추가함으로써 위험을 제어할 수 있다.

최적화 방향

  • 다양한 변수 조합을 테스트하여 최적의 변수를 찾습니다.
  • 구매 및 판매 하락값을 조정하여 잘못된 거래의 가능성을 줄여줍니다.
  • 다른 기술 지표를 추가하여 신호 품질을 향상시킵니다.
  • 단독 손실을 통제하기 위해 손해 방지 장치에 가입하십시오.
  • 자금 관리 전략을 최적화하고 전반적인 위험 틈을 통제하십시오.

요약하다

이 전략은 역전 거래와 트렌드 추적의 장점을 통합하여 시장 전환점을 효과적으로 식별 할 수 있습니다. 그러나 변수 조정과 위험 통제에 주의를 기울여야하며 트렌드를 추적하면서 너무 많은 잘못된 신호를 방지해야합니다. 잘 사용하면 효율적인 거래 전략 중 하나가 될 수 있습니다.

전략 소스 코드
/*backtest
start: 2023-08-17 00:00:00
end: 2023-09-16 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 24/02/2021
// 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
//    Indicator plots Money Flow Indicator (Chaikin). This indicator looks 
//    to improve on Larry William's Accumulation Distribution formula that 
//    compared the closing price with the opening price. In the early 1970's, 
//    opening prices for stocks stopped being transmitted by the exchanges. 
//    This made it difficult to calculate Williams' formula. The Chaikin 
//    Oscillator uses the average price of the bar calculated as follows 
//    (High + Low) /2 instead of the Open.
//    The indicator subtracts a 10 period exponential moving average of the 
//    AccumDist function from a 3 period exponential moving average of the 
//    AccumDist function.  
//
// 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


MFI(Fast,Slow) =>
    pos = 0.0
    lenMax = max(Fast, Slow)
    lenMin = min(Fast, Slow)
    xDiv = (high - low) * volume
    SumMax = sum(iff(xDiv > 0, (close - open) / (high - low) * volume , 0) , lenMax)
    SumMin = sum(iff(xDiv > 0, (close - open) / (high - low) * volume , 0) , lenMin)
    emaMax = ema(SumMax, lenMax)
    emaMin = ema(SumMin, lenMin)
    nRes = emaMax - emaMin
    pos:= iff(nRes > 0, 1,
           iff(nRes < 0, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Money Flow Indicator", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
line2 = input(true, "---- Money Flow ----")
Fast = input(3, minval=1)
Slow = input(10, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posMFI = MFI(Fast,Slow)
pos = iff(posReversal123 == 1 and posMFI == 1 , 1,
	   iff(posReversal123 == -1 and posMFI == -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 )