다중 요인 양적 거래 전략

저자:차오장, 날짜: 2023-12-27 15:46:27
태그:

img

전반적인 설명

이 전략은 123 역전 전략과 심리적 라인 전략을 결합하여 다중 요인 양적 거래 전략을 형성합니다. 기술 패턴, 시장 심리학 및 기타 요인을 포괄적으로 고려함으로써 전략은 시장 추세를 결정 할 때 더 정확한 판단을 할 수 있습니다.

원칙

123 역전 전략

123 역전 전략은 하루의 종료 가격이 전날과 비교하여 상승하고 느린 K 라인이 50보다 낮으면 장기간; 떨어지고 빠른 K 라인이 50보다 높으면 단기간에 수익을 창출하는 특성을 활용합니다.

심리적 라인 전략

심리적 라인 전략은 특정 주기에 걸쳐 상승과 하락의 비율을 계산합니다. 상승이 50% 이상이라면, 황소들이 시장을 통제한다는 것을 나타냅니다. 상승이 50% 미만이라면, 곰들이 시장을 통제한다는 것을 나타냅니다. 상승과 하락의 비율에 따라 시장 심리학에 대한 판단을 내립니다.

이 전략은 위의 두 가지 전략의 신호를 결합합니다. 두 가지 전략이 같은 방향으로 신호를 내면 포지션을 열고 다른 방향으로 신호를 내면 포지션을 닫습니다.

장점

이 전략은 여러 가지 요인을 결합하여 단일 기술 지표로 인한 잘못된 판단을 피하여 시장 트렌드에 대한 더 정확한 판단을 할 수 있습니다. 동시에 시장 심리학의 조합은 복잡한 트렌드 변화에 대처할 수 있도록 전략을 더 탄력하게 만듭니다.

위험 과 해결책

전략의 각 요소에 대한 매개 변수 설정은 전략 성능에 더 큰 영향을 미칠 것입니다. 불합리한 매개 변수 조합은 전략의 효과를 크게 줄일 수 있습니다. 또한 트렌드의 급격한 변화는 전략의 실패를 초래할 수 있습니다. 위험을 줄이기 위해 최적의 매개 변수 설정을 찾기 위해 다양한 시장 조건을 백테스트해야합니다. 또한 단일 손실이 너무 크지 않도록 하기 위해 포지션 크기를 제어하십시오.

최적화 방향

기존의 기초에 따라, 우리는 더 3차원 전략 논리를 형성하기 위해 변동성 및 볼륨과 같은 다른 판단 요인을 추가 할 수 있습니다. 또는 자동 매개 변수 적응 최적화를 달성하기 위해 기계 학습 알고리즘을 추가 할 수 있습니다. 이것들은이 전략의 추가 최적화 방향이 될 것입니다.

요약

이 전략은 기술 패턴과 시장 심리학과 같은 여러 요인을 포괄적으로 고려합니다. 다른 요인 사이의 검증은 신호의 유효성을 보장합니다. 동시에 최적화에 충분한 공간을 남겨두고 우수한 성능을 달성 할 것으로 예상됩니다. 이것은 장기 추적, 축적 및 최적화에 가치가있는 고품질의 양적 전략입니다.


/*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 )

더 많은