다중 요인 반전 양적 거래 전략


생성 날짜: 2023-12-27 15:46:27 마지막으로 수정됨: 2023-12-27 15:46:27
복사: 0 클릭수: 640
avatar of ChaoZhang ChaoZhang
1
집중하다
1619
수행원

다중 요인 반전 양적 거래 전략

개요

이 전략은 123 역전 전략과 심리 라인 전략을 결합하여 다인자 정량 거래 전략을 형성한다. 이 전략은 기술 형태, 시장 심리 등 여러 차원을 종합적으로 고려하여 시장 움직임을 판단할 때 더 정확한 결정을 내릴 수 있다.

원칙

123 역전 전략

123 역전 전략은 하루의 종결 가격과 비교하여, 상승하면, 그리고 느린 K 선이 50보다 낮으면, 더 많이 하고, 하락하면, 그리고 빠른 K 선이 50보다 높으면, 공백을 한다. 이 전략은 단기 역전 특성을 활용하여 이익을 얻는다.

심리전선 전략

심리 라인 전략은 일정한 주기 내의 하락 비율을 통계한다. 만약 하락 비율이 50% 이상인 경우 다수 지배를 나타낸다. 만약 하락 비율이 50% 미만인 경우 공백 지배를 나타낸다. 하락 비율에 따라 시장의 심리면을 판단한다.

이 전략은 위의 두 가지 전략의 결합 신호입니다. 둘은 동방향 신호를 주면 입장을 열고, 다른 방향 신호를 주면 입장을 다.

장점

이 전략은 여러 가지 요인을 결합하여 시장의 흐름을 더 정확하게 판단하고 단일 기술 지표로 인한 잘못된 판단을 피할 수 있습니다. 시장의 심리적 요소를 결합하는 동시에 전략이 더 탄력하고 더 복잡한 상황에 대처할 수 있도록합니다.

위험과 해결

이 전략의 각 요소 매개 변수의 설정은 전략의 성과에 큰 영향을 미칩니다. 불합리한 매개 변수 조합은 전략의 효과를 크게 저하시킬 수 있습니다. 또한, 시장 상황이 급격하게 변하면 전략이 실패로 이어질 수 있습니다. 위험을 줄이기 위해, 우리는 다양한 시장 상황에 대한 많은 피드백을 수행하여 최적의 매개 변수를 찾아야합니다. 또한 포지션 규모를 제어하여 단독 손실이 너무 커지지 않도록해야합니다.

최적화 방향

우리는 기존의 기반에 다른 판단 요소를 추가할 수 있습니다. 예를 들어, 변동률, 거래량과 같은 지표는 더 세 차원 전략 논리를 형성합니다. 또는 기계 학습 알고리즘을 추가하여 전략의 매개 변수를 자율적으로 최적화 할 수 있습니다.

요약하다

이 전략은 기술 형태와 시장 심리 등 여러 요인을 종합적으로 고려하여, 다양한 요인 간의 검증으로 신호의 유효성을 보장한다. 동시에 많은 최적화 공간을 남겨두고 더 뛰어난 성과를 얻을 수 있다. 이것은 장기적으로 추적, 축적 및 최적화 할 가치가있는 최적화 전략이다.

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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 30/04/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
// Psychological line (PSY), as an indicator, is the ratio of the number of 
// rising periods over the total number of periods. It reflects the buying 
// power in relation to the selling power.
// If PSY is above 50%, it indicates that buyers are in control. Likewise, 
// if it is below 50%, it indicates the sellers are in control. If the PSY 
// moves along the 50% area, it indicates balance between the buyers and 
// sellers and therefore there is no direction movement for the market.
//
// 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


PLine(Length) =>
    pos = 0.0
    cof = close > close[1]? 1:0
    xPSY = sum(cof,Length) / Length * 100
    pos:= iff(xPSY > 50, 1,
           iff(xPSY < 50, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Psychological line", 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, "---- Psychological line ----")
LengthPLine = input(20, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posPLine = PLine(LengthPLine)
pos = iff(posReversal123 == 1 and posPLine == 1 , 1,
	   iff(posReversal123 == -1 and posPLine == -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 )