트렌드 필터 기반의 빠른 QQE 크로스오버 거래 전략

저자:차오장, 날짜: 2024-01-25 11:34:58
태그:

img

전반적인 설명

트렌드 필터를 기반으로 한 빠른 QQE 크로스오버 거래 전략은 트렌드 방향 필터링을 위해 이동 평균과 빠른 QQE 크로스를 사용하는 트렌드 다음 거래 전략이다. QQE 또는 질적 양적 추정은 상대 강도 지수에 기반하지만 추가 변환으로 평형화 기술을 사용합니다. 세 개의 크로스를 선택할 수 있습니다 (모든 것이 기본적으로 선택됩니다):

  • RSI 신호가 NERO (XZERO) 를 통과합니다.
  • RSI 신호가 빨라 RSIatr 라인 (XQQE) 을 통과합니다.
  • RSI 임계 채널을 벗어나는 RSI 신호 (BUY/SELL)

(BUY/SELL) 알림은 선택적으로 이동 평균에 의해 필터링될 수 있습니다.

  • BUY 알레르트를 위해 Close는 빠른 MA와 빠른 MA (EMA8) > 중간 MA (EMA20) > 느린 MA (SMA50) 이상여야 합니다.
  • SELL 경고의 경우 Close는 빠른 MA와 빠른 MA (EMA8) < 중간 MA (EMA20) < 느린 MA (SMA50) 이어야 합니다.

또는 방향 필터:

  • BUY 알림의 경우 Close는 느린 MA (SMA50) 이상이고 방향 MA (EMA20) 는 초록색이어야 합니다.
  • SELL 알림의 경우 Close는 느린 MA (SMA50) 이 밑에 있고 방향 MA (EMA20) 는 빨간색이어야 합니다.

XZERO와 XQQE는 필터링에 포함되지 않습니다. 대기 중인 BUY/SELL 알림을 표시하는 데 사용됩니다. 특히 XZERO입니다.

이 전략은 모든 통화 쌍과 대부분의 차트 시간 프레임에서 작동해야합니다.

전략 원칙

이 전략의 핵심 아이디어는 빠른 QQE 지표의 방향 교차를 거래 신호로 사용하고 흐르는 평균의 조합을 통해 시끄러운 거래 신호를 필터링하여 트렌드 방향을 파악하는 것입니다.

특히 전략은 다음의 지표와 신호를 사용합니다.

빠른 QQE 표시기: 이것은 RSI 기반의 지표로 더 민감하고 빠르도록 추가 매끄럽게 합니다. 지표는 세 줄로 구성됩니다. 중간선은 RSI의 기하급수적인 이동 평균, 상선은 중간선 + 빠른 ATR * 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인 인

제로 라인 크로스오버: RSI의 중간선이 제로선을 넘을 때 신호를 생성합니다. 상향 크로스오버는 구매 신호이며 하향 크로스오버는 판매 신호입니다. 이 신호는 트렌드 변화의 전개를 나타냅니다.

채널 파업: RSI의 중간 선이 설정된 임계 채널에 들어갈 때 신호를 생성합니다. 상단 채널을 깨는 것은 판매 신호이며 하단 채널을 깨는 것은 구매 신호입니다. 이것들은 더 강한 트렌드 신호입니다.

이동 평균 조합: 빠른 (8 기간), 중간 (20 기간) 및 느린 (50 기간) 이동 평균의 조합을 사용하십시오. 세 줄이: 빠른 > 중간 > 느린으로 배치되면 상승 추세입니다. 빠른 < 중간 < 느린으로 배치되면 하락 추세입니다. 콤보는 전체 트렌드 방향을 결정하는 데 사용됩니다.

트렌드 방향 필터: 매매 신호는 닫기 가격이 느린 이동 평균보다 높고 중간 이동 평균 (20 기간) 이 상승할 때만 생성됩니다. 닫기 가격이 느린 이동 평균보다 낮고 중간 이동 평균 (20 기간) 이 하향할 때만 판매 신호가 생성됩니다. 이것은 일부 역으로 가짜 신호를 필터링 할 수 있습니다.

빠른 QQE 지표에서 크로스오버 신호를 사용하여 이동 평균에서 트렌드 필터링을 결합함으로써, 주요 시간 프레임 트렌드에 대한 단기 반전 지점을 포착하여 비교적 완전한 거래 시스템을 형성합니다. 동시에, 지표 매개 변수는 트렌드의 전환점을 가능한 한 빨리 포착하기 위해 상대적으로 민감하게 설정됩니다.

요약하자면, 이것은 중장기 트렌드를 추적하고, 엔트리/엑시트 (entry/exit) 에 대한 단기 반전의 시기를 파악하기 위해 빠른 지표를 사용하고, 방향에 반대되는 거래의 위험을 줄이고 수익을 극대화하기 위해 이동 평균 필터링을 활용하는 전략입니다.

전략 의 장점

  • 빠르게 반전 신호를 캡처하기 위해 빠르고 민감한 QQE 표시기를 사용합니다
  • 큰 사이클 방향을 결정하고 트렌드에 반하는 거래를 피하기 위해 여러 이동 평균을 적용합니다.
  • 이윤 기회를 높이기 위해 조합으로 사용할 수 있는 여러 개의 크로스 신호를 포함합니다.
  • 다양한 제품 및 시간 프레임에 최적화 할 수있는 조정 가능한 매개 변수
  • 지표의 자체 채널 브레이크아웃 신호를 사용 하 여 별도의 채널을 그리는 대신, 매개 변수 의존도를 피
  • 큰 트렌드 사이클 하에서 매우 잘 단기 반전 움직임을 포착 할 수 있습니다
  • 단순하고 명확한 개념, 이해하기 쉽고 실행하기 쉽습니다

전략 의 위험

이 전략에는 몇 가지 잠재적인 위험도 있습니다.

  • 빠른 지표는 이동 평균에 의해 완전히 필터링 될 수없는 잘못된 신호를 생성하는 경향이 있습니다. 잘못된 방향을 추적 할 위험이 있습니다.
  • 큰 사이클 트렌드 반전이 발생하면, 리버스 무역 신호가 형성되는 경향이 있으며 이는 위험을 초래합니다.
  • 자금 관리 요인, 과도한 거래 및 손실 위험은 고려되지 않습니다.
  • 스톱 로즈가 없어 손실 증가 위험이 크다
  • 백테스트 데이터 적응 위험, 실제 성능은 아직 확인되지 않았습니다

대책 및 해결책은 다음과 같습니다.

  • 이동 평균 매개 변수를 조정, 추세를 결정하기 위해 더 많은 사이클 길이를 사용
  • 콤보 필터링을 위해 MACD, 편견 등과 같은 다른 지표를 추가
  • 단일 거래 손실 크기를 제어하기 위해 스톱 로스 전략을 추가하십시오.
  • 실제 돈 테스트, 매개 변수를 최적화

최적화 방향

이 전략은 더 이상 최적화 할 수 있습니다.

  1. QQE 지표의 빠르고 느린 라인 매개 변수를 최적화하여 최적의 매개 변수 조합을 찾습니다.
  2. 최적 필터링 성능을 찾기 위해 더 많은 이동 평균 콤보를 테스트
  3. 보조 신호 필터링을 위해 MACD와 같은 다른 지표를 추가하십시오.
  4. 포지션 크기를 최적화하기 위해 자금 관리 전략을 적용하십시오.
  5. 거래당 하향 위험을 제어하기 위한 스톱 로스 전략을 설정
  6. 다양한 제품에 기반한 매개 변수를 최적화
  7. 단기적 역류에 의해 오해되지 않도록 더 긴 시간 프레임에 대한 경향을 결정

매개 변수 최적화, 더 많은 지표를 결합하고 실행 가능한 돈 및 위험 관리 관행의 도움을 받아 이 전략의 성능을 실제 거래에 향상시킬 수 있습니다.

결론

전체적으로 트렌드 필터를 기반으로 한 빠른 QQE 크로스오버 거래 전략은 매우 상당한 선택이다. 그것의 강점은 주요 트렌드를 결정하고 가능한 한 많은 이동 평균을 사용하여 빠르게 반전 거래 기회를 포착하는 데 있습니다. 지표 매개 변수 및 필터링 기준의 최적화와 엄격한 돈 관리와 함께이 전략은 비교적 안정적인 투자 수익을 창출 할 수 있습니다.

물론 위험은 무시할 수 없다. 전략의 실용성과 신뢰성을 보장하기 위해 실제 돈 테스트와 지속적인 최적화 조정이 필요하다. 결론적으로, 투자자들이 장기적인 연습을 연구하고 추적하는 것이 가치가 있다. 알고리즘 거래 기술의 발전으로 빠른 지표와 트렌드 필터링에 기반한 이러한 유형의 전략은 더 많은 개선과 확산을 볼 것으로 믿어진다.


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

//@version=2
//
// Title:   [STRATEGY][UL]QQE Cross v1.1
// Author:  JustUncleL
// Date:    22-Oct-2016
// Version: v1.1
//
// Description:
//  A trend following trading Strategy that uses fast QQE crosses with Moving Averages
//  for trend direction filtering. QQE or Qualitative Quantitative Estimation is based 
//  on the relative strength index, but uses a smoothing technique as an additional 
//  transformation. Three crosses can be selected (all selected by default): 
//    - RSI signal crossing ZERO (XZERO)
//    - RSI signal crossing Fast RSIatr line (XQQE)
//    - RSI signal exiting the RSI Threshhold Channel (BUY/SELL)
//  The (BUY/SELL) alerts can be optionally filtered by the Moving averages:
//    - For BUY alert the Close must be above the fast MA and 
//        fast MA (EMA8) > medium MA (EMA20) > slow MA (SMA50).
//    - For SELL alert the Close must be below the fast MA and
//        fast MA (EMA8) < medium MA (EMA20) < slow MA (SMA50).
//  and/or directional filter:
//    - For BUY alert the Close must be above the slow MA (SMA50) and the
//      directional MA (EMA20) must be green.
//    - For SELL alert the Close must be below the slow MA (SMA50) and the
//      directional MA (EMA20) must be red.
//. The XZERO and XQQE are not included in the filtering, they are used to indicate
//  pending BUY/SELL alerts, particularly the XZERO. 
//
//  This Strategy should work on any currency pair and most chart timeframes.
//  *** USE AT YOUR OWN RISK ***
//  
// 
//
// Mofidifications:
//  1.1 - Added Target Profit option, cleaned up the risk management code.
//        Changed Trade Close to EMA20 direction change instead of opposite BUY/SELL
//        signal, which will be earlier, this means stop loss setting should not be
//        required when an AutoTrader is available.
//        Modified code to prevent potential repaint issues.
//  1.0 - original
//
// References:
//  Some Code borrowed from:
//  - "Scalp Jockey - MTF MA Cross Visual Strategizer by JayRogers"
//  - "QQE MT4 by glaz"
//  - "Strategy Code Example by JayRogers"  
//  Inspiration from:
//  - http://www.forexstrategiesresources.com/binary-options-strategies-ii/189-aurora-binary-trading/
//  - http://www.forexstrategiesresources.com/metatrader-4-trading-systems-v/652-qqe-smoothed-trading/
//  - http://dewinforex.com/forex-indicators/qqe-indicator-not-quite-grail-but-accurately-defines-trend-and-flat.html
//

strategy(title='[STRATEGY][UL]QQE Cross v1.1', pyramiding=0, overlay=true )


// - INPUTS START
// Fast MA - type, source, length
type1   = input(defval="EMA", title="Fast MA Type: SMA, EMA, WMA, VWMA, SMMA, DEMA, TEMA, HullMA, ZEMA ( case sensitive )")
len1    = input(defval=8, title="Fast - Length", minval=1)
// Medium Fast MA - type, source, length
type2   = input(defval="EMA", title="Medium Fast MA Type: SMA, EMA, WMA, VWMA, SMMA, DEMA, TEMA, HullMA, ZEMA ( case sensitive )")
len2    = input(defval=20, title="Medium Fast - Length", minval=1)
// Slow MA - type, source, length
type3   = input(defval="SMA", title="Slow MA Type: SMA, EMA, WMA, VWMA, SMMA, DEMA, TEMA, HullMA, LSMA, ZEMA ( case sensitive )")
len3    = input(defval=50, title="Slow Length", minval=1)
//
// QQE rsi Length, Smoothing, fast ATR factor, source
RSILen  = input(6,title='RSI Length')
SF      = input(3,title='RSI Smoothing Factor')
QQE     = input(2.618,title='Fast QQE Factor')
threshhold = input(10, title="RSI Threshhold")
//
sQQEx   = input(false,title="Show QQE Signal crosses")
sQQEz   = input(false,title="Show QQE Zero crosses")
//
filter  = input(false,title="Use Moving Average Filter")
dfilter = input(true, title="Use Trend Directional Filter" )
RSIsrc  = input(close,title="Source")
srcclose= RSIsrc

// - INPUTS END

// - FUNCTIONS

// Returns MA input selection variant, default to SMA if blank or typo.
variant(type, src, len) =>
    v1 = sma(src, len)                                                  // Simple
    v2 = ema(src, len)                                                  // Exponential
    v3 = wma(src, len)                                                  // Weighted
    v4 = vwma(src, len)                                                 // Volume Weighted
    v5 = na(v5[1]) ? sma(src, len) : (v5[1] * (len - 1) + src) / len    // Smoothed
    v6 = 2 * v2 - ema(v2, len)                                          // Double Exponential
    v7 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len)               // Triple Exponential
    v8 = wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))   // Hull
    ema1 = ema(src, len)
    ema2 = ema(ema1, len)
    v10 = ema1+(ema1-ema2)                                              // Zero Lag Exponential
    // return variant, defaults to SMA if input invalid.
    type=="EMA"?v2 : type=="WMA"?v3 : type=="VWMA"?v4 : type=="SMMA"?v5 : type=="DEMA"?v6 : type=="TEMA"?v7 : type=="HullMA"?v8 : type=="ZEMA"?v10 : v1

// - FUNCTIONS END

// - Fast ATR QQE
//
Wilders_Period = RSILen * 2 - 1
//
Rsi = rsi(RSIsrc,RSILen)
RSIndex = ema(Rsi, SF)
AtrRsi = abs(RSIndex[1] - RSIndex)
MaAtrRsi = ema(AtrRsi, Wilders_Period)
DeltaFastAtrRsi = ema(MaAtrRsi,Wilders_Period) * QQE
//
newshortband=  RSIndex + DeltaFastAtrRsi
newlongband= RSIndex - DeltaFastAtrRsi
longband=RSIndex[1] > longband[1] and RSIndex > longband[1] ? max(longband[1],newlongband) : newlongband
shortband=RSIndex[1] < shortband[1] and  RSIndex < shortband[1] ? min(shortband[1],newshortband) : newshortband
trend=cross(RSIndex, shortband[1])? 1 : cross(longband[1], RSIndex) ? -1 : nz(trend[1],1)
FastAtrRsiTL = trend==1 ? longband : shortband


// - SERIES VARIABLES
// MA's
ma_fast    = variant(type1, srcclose, len1)
ma_medium  = variant(type2, srcclose, len2)
ma_slow    = variant(type3, srcclose, len3)
// Get Direction From Medium Moving Average
direction = rising(ma_medium,3) ? 1 : falling(ma_medium,3) ? -1 : 0
//
// Find all the QQE Crosses
QQExshort = sQQEx and crossover(FastAtrRsiTL, RSIndex)
QQExlong  = sQQEx and crossunder(FastAtrRsiTL, RSIndex)
// Zero cross
QQEzlong = sQQEz and crossover(RSIndex,50)
QQEzshort  = sQQEz and crossunder(RSIndex,50)
//  
// Thresh Hold channel Crosses give the BUY/SELL alerts.
QQEclong = RSIndex>(50+threshhold) ? na(QQEclong[1]) ? 1 : QQEclong[1]+1 : 0
QQEcshort = RSIndex<(50-threshhold) ? na(QQEcshort[1]) ? 1 : QQEcshort[1]+1 : 0

//
// Check Filtering.
QQEflong = (not filter or (srcclose>ma_fast and ma_medium>ma_slow and ma_fast>ma_medium)) and 
  (not dfilter or (direction>0 and srcclose>ma_slow))
QQEfshort = (not filter or (srcclose<ma_fast and ma_medium<ma_slow and ma_fast<ma_medium)) and
  (not dfilter or (direction<0 and srcclose<ma_slow))
//
// Get final BUY / SELL alert determination
buy = QQEclong>0 and QQEflong ? na(buy[1]) ? 1 : buy[1]+1 : 0
sell= QQEcshort>0 and QQEfshort ? na(sell[1]) ? 1 : sell[1]+1 : 0

// - SERIES VARIABLES END

// - PLOTTING
// Ma's
plot(ma_fast, title="MA Fast", color=olive, linewidth=2, transp=20)
plot(ma_medium, title="MA Medium Fast", color=direction<0?red:green, linewidth=3, transp=0)
plot(ma_slow, title="MA Slow", color=blue, linewidth=2, transp=20)
// QQE crosses
plotshape(QQExlong and buy!=1, title="QQE Cross Over", style=shape.triangleup, location=location.belowbar, text="XQQE", color=blue, transp=20, size=size.tiny)
plotshape(QQExshort and sell!=1, title="QQE Cross Under", style=shape.triangledown, location=location.abovebar, text="XQQE", color=black, transp=20, size=size.tiny)
// Signal crosses zero line
plotshape(QQEzlong and buy!=1 and not QQExlong, title="QQE Zero Cross Over", style=shape.triangleup, location=location.belowbar, text="XZERO", color=aqua, transp=20, size=size.tiny)
plotshape(QQEzshort and sell!=1 and not QQExshort, title="QQE Zero Cross Under", style=shape.triangledown, location=location.abovebar, text="XZERO", color=fuchsia, transp=20, size=size.tiny)

// - PLOTTING END

// Create alert for cross, shunt back 1 if source is not 'open', this should prevent repaint issue.
//shunt = RSIsrc == open ? 0 : 1
shunt = 0
c_alert = (buy[shunt]==1 or sell[shunt]==1)
//alertcondition(c_alert, title="QQECROSS Alert", message="QQECROSS Alert")
// show only when alert condition is met and bar closed.
plotshape(c_alert,title= "Alert Indicator Closed", location=location.bottom, color=sell[shunt]==1?red:green, transp=0, style=shape.circle)


//  Strategy: (Thanks to JayRogers)
// === STRATEGY RELATED INPUTS ===
//tradeInvert     = input(defval = false, title = "Invert Trade Direction?")
// the risk management inputs
inpTakeProfit   = input(defval = 0, title = "Take Profit Points", minval = 0)
inpStopLoss     = input(defval = 0, title = "Stop Loss Points", minval = 0)
inpTrailStop    = input(defval = 100, title = "Trailing Stop Loss Points", minval = 0)
inpTrailOffset  = input(defval = 0, title = "Trailing Stop Loss Offset Points", minval = 0)

// === RISK MANAGEMENT VALUE PREP ===
// if an input is less than 1, assuming not wanted so we assign 'na' value to disable it.
useTakeProfit   = inpTakeProfit  >= 1 ? inpTakeProfit  : na
useStopLoss     = inpStopLoss    >= 1 ? inpStopLoss    : na
useTrailStop    = inpTrailStop   >= 1 ? inpTrailStop   : na
useTrailOffset  = inpTrailOffset >= 1 ? inpTrailOffset : na

// === STRATEGY - LONG POSITION EXECUTION ===
strategy.entry(id = "Buy", long = true, when = buy[shunt]==1 )// use function or simple condition to decide when to get in
strategy.close(id = "Buy", when = direction[shunt]!=direction[shunt+1])// ...and when to get out

// === STRATEGY - SHORT POSITION EXECUTION ===
strategy.entry(id = "Sell", long = false, when = sell[shunt]==1)
strategy.close(id = "Sell", when = direction[shunt]!=direction[shunt+1])

// === STRATEGY RISK MANAGEMENT EXECUTION ===
// finally, make use of all the earlier values we got prepped
strategy.exit("Exit Buy", from_entry = "Buy", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
strategy.exit("Exit Sell", from_entry = "Sell", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)

//eof

더 많은