반전 브레이크아웃 밴드패스 컴보 전략

저자:차오장, 날짜: 2024-02-01 10:45:12
태그:

img

전반적인 설명

이것은 두 가지 요인 - 역전 및 대역 패스 (bandpass) 에 의해 구동되는 콤보 전략으로, 다중 요인 덮개를 달성하고 다른 시장 조건에 적응합니다.

전략 논리

이 전략은 두 가지 하위 전략으로 구성됩니다.

  1. 123 역전 전략: 닫기 가격이 2일 연속 하락할 때, 오늘의 닫기가 이전 2일 최저 가격을 뚫고, 9일 스토카스틱 오시레이터의 빠른 선이 느린 선 위에 넘어가면, 장거리. 닫기 가격이 2일 연속 상승할 때, 오늘의 닫기가 전 2일 최저 가격 아래로 떨어지고, 빠른 선이 느린 선 아래로 넘어가면, 단거리.

  2. 대역 간격 필터: 특정 기간 동안 대역 간격 지표를 계산하고, 한계 이상의 경우 장거리, 그 이하의 경우 단기화합니다.

결합된 신호는 두 전략 모두 긴 신호를 내면 긴 포지션을 취하고, 두 전략 모두 짧은 신호를 내면 짧은 포지션을 취하고, 그렇지 않으면 모든 포지션을 삭제합니다.

장점

  • 이중적인 요소에 의해 움직이고, 다양한 시장 조건에 적응하고, 모든 체제에서 수익을 창출합니다.
  • 123 반전 시장에서 반전 기회를 포착합니다
  • 대역 패스 필터 트렌드 트렌드 시장
  • 결합 신호는 오류 거래를 확인하고 방지합니다.

위험성

  • 부적절한 매개 변수는 과잉 거래로 이어질 수 있습니다.
  • 불안한 시장에서 여러 손실이 발생할 수 있습니다.
  • 거래 비용은 모니터링 해야 합니다.

강화

  • 대역 간격 필터 매개 변수를 조정하여 대역 간격 계산을 최적화합니다
  • 긴 / 짧은 반전 식별을 최적화하기 위해 123 반전 매개 변수를 조정
  • 단일 트레이드에서 스톱 로스를 제어 로스로 추가합니다.

요약

이 전략은 다중 요인 중심의 양적 거래를 달성하기 위해 역전 및 트렌드 요인을 통합합니다. 이중 요인 검증은 잘못된 거래의 가능성을 줄여 다양한 시장에서 전략을 잘 수행하게합니다. 매개 변수 조정 및 중지 손실에 대한 추가 개선은 전략의 안정성과 수익성을 향상시킵니다.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 21/05/2019
// This is combo strategies for get 
// a cumulative signal. Result signal will return 1 if two strategies 
// is long, -1 if all strategies is short and 0 if signals of strategies is not equal.
//
// 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 related article is copyrighted material from
// Stocks & Commodities Mar 2010
// You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
//
// 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


Bandpass_Filter(Length, Delta, TriggerLevel) =>
    xPrice = hl2
    beta = cos(3.14 * (360 / Length) / 180)
    gamma = 1 / cos(3.14 * (720 * Delta / Length) / 180)
    alpha = gamma - sqrt(gamma * gamma - 1)
    BP = 0.0
    pos = 0.0
    BP := 0.5 * (1 - alpha) * (xPrice - xPrice[2]) + beta * (1 + alpha) * nz(BP[1]) - alpha * nz(BP[2])
    pos := iff(BP > TriggerLevel, 1,
	       iff(BP <= TriggerLevel, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Bandpass Filter", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
LengthBF = input(20, minval=1)
Delta = input(0.5)
TriggerLevel = input(0)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posBandpass_Filter = Bandpass_Filter(LengthBF, Delta, TriggerLevel)
pos = iff(posReversal123 == 1 and posBandpass_Filter == 1 , 1,
	   iff(posReversal123 == -1 and posBandpass_Filter == -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 ? red: possig == 1 ? green : blue ) 

더 많은