123 반전 및 Fisher 변환 지표 조합 전략


생성 날짜: 2023-09-13 17:35:36 마지막으로 수정됨: 2023-09-13 17:35:36
복사: 0 클릭수: 856
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이 전략은 ?? 123 역전과 피셔 변환 지표 조합 전략 ?? 이라고 불린다. 이 전략은 123 역전 형태 판단과 피셔 변환 지표를 통합하여, 둘은 공통 신호를 발산할 때 구매 또는 판매한다.

123 역전 형태는 가격이 3일 연속으로 고하간을 형성하고, 3일 종결에 역전 전 2일 경향의 형태를 나타낸다. 통계에 따르면, 123 역전 거래는 높은 수익률을 얻는다.

피셔 변환 지표는 가격에 대한 정형화를 처리하고, 변환 곡선이 돌파한 극한점이 발생했을 때 가격 반전점을 효과적으로 식별할 수 있다.

거래의 논리는 다음과 같습니다.

  1. 123 반전 형태는 구매 신호 또는 판매 신호를 나타냅니다.

  2. 피셔 변환 곡선은 구매 또는 판매 신호를 나타냅니다.

  3. 동방향 신호를 발산할 때, 상응하는 구매 또는 판매 거래를 진행한다.

  4. 이 두 개가 반향 신호를 내면, 공백을 유지하십시오.

이 전략의 장점은 지표 조합이 가격 반전의 시점을 판단하는 정확도를 높일 수 있다는 것입니다. 그러나 매개 변수 최적화는 여전히 중요하며 엄격한 자금 관리가 필요합니다.

전반적으로, 지표 통합 응용 프로그램은 더 포괄적 인 분석 관점을 형성 할 수 있습니다. 그러나 거래자는 여전히 시장 상황에 따라 전략을 조정 할 수있는 충분한 유연성을 유지해야합니다.

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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 28/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
// 	Market prices do not have a Gaussian probability density function
// 	as many traders think. Their probability curve is not bell-shaped.
// 	But trader can create a nearly Gaussian PDF for prices by normalizing
// 	them or creating a normalized indicator such as the relative strength
// 	index and applying the Fisher transform. Such a transformed output 
// 	creates the peak swings as relatively rare events.
// 	Fisher transform formula is: y = 0.5 * ln ((1+x)/(1-x))
// 	The sharp turning points of these peak swings clearly and unambiguously
// 	identify price reversals in a timely manner. 
//
// 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


FTI(Length) =>
    pos = 0
    nValue1 =0.0
    nFish = 0.0
    xHL2 = hl2
    xMaxH = highest(xHL2, Length)
    xMinL = lowest(xHL2,Length)
    nValue1 := 0.33 * 2 * ((xHL2 - xMinL) / (xMaxH - xMinL) - 0.5) + 0.67 * nz(nValue1[1])
    nValue2 = iff(nValue1 > .99,  .999,
	             iff(nValue1 < -.99, -.999, nValue1))
    nFish := 0.5 * log((1 + nValue2) / (1 - nValue2)) + 0.5 * nz(nFish[1])
    pos := iff(nFish > nz(nFish[1]), 1,
     	     iff(nFish < nz(nFish[1]), -1, nz(pos[1], 0)))  
    pos

strategy(title="Combo Backtest 123 Reversal & Fisher Transform Indicator", shorttitle="Combo", overlay = true)
Length = input(15, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
LengthFTI = input(10, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posFTI = FTI(LengthFTI)
pos = iff(posReversal123 == 1 and posFTI == 1 , 1,
	   iff(posReversal123 == -1 and posFTI == -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 )