トレンドフィルターに基づくQQEクロスオーバー取引戦略

作者: リン・ハーンチャオチャン, 日付: 2024-01-25 11:34:58
タグ:

img

概要

トレンドフィルターに基づいた急速QQEクロスオーバー取引戦略は,トレンド方向フィルタリングのために移動平均値と急速QQEクロスを使用するトレンドフォローする取引戦略である.QQEまたは定量的な定量評価は相対強度指数に基づいているが,追加の変換としてスムージングテクニックを使用する.3つのクロスを選択することができます (すべてデフォルトで選択されます):

  • RSI信号の横断はZERO (XZERO)
  • RSI信号が高速RSI線 (XQQE) を横断する
  • RSI 信号がRSI 値チャネルを外す (BUY/SELL)

(BUY/SELL) 警告は,選択的に移動平均値でフィルタリングできます.

  • BUY アラートでは,Close は快速MAと快速MA (EMA8) >中間MA (EMA20) >遅いMA (SMA50) の上にある必要があります.
  • SELL アラートでは, Close は快速MA (EMA8) < 中間MA (EMA20) < 遅いMA (SMA50) 以下の値でなければならない.

そして/または方向フィルター:

  • BUYアラートでは,スローMA (SMA50) の上を閉じるし,ダイレクトMA (EMA20) は緑色でなければならない.
  • SELL アラートでは,スローMA (SMA50) の下に Close が表示され,ダイレクトMA (EMA20) は赤色で表示される必要があります.

XZEROとXQQEはフィルタリングには含まれていませんが,待機中のBUY/SELLアラート,特にXZEROを表示するために使用されます.

この戦略は,どの通貨ペアでも,ほとんどのチャートタイムフレームでも有効です.

戦略原則

この戦略の主なアイデアは,高速QQE指標の方向交差を取引信号として利用し,動平均の組み合わせを通じて騒々しい取引信号をフィルタリングしてトレンド方向を把握することです.

具体的には,戦略は以下の指標とシグナルを使用します.

QQE 速度の指標: これは,RSIをより敏感で迅速にするための追加のスムージングを伴うRSIベースの指標です.指標は3つの線で構成されています. 中央線はRSIの指数関数移動平均線,上部線は中間線 + 急速なATR * 要素,下部線は中間線 - 急速なATR * 要素です. RSIが上部線を超えると,それは販売信号です. RSIが下部線を下回ると,それは購入信号です.

ゼロライン交差点: RSI の 中央線がゼロ線を横切ったときに信号を生成する. 上向きクロスオーバーは買い信号,下向きクロスオーバーは売る信号である.これらの信号はトレンド変化の序幕を示している.

チャンネルブレイク: RSI の 中央線が設定された値チャネルに入るときに信号を生成する.上部のチャネルを突破することは販売信号であり,下部のチャネルを突破することは購入信号である.これらはより強いトレンド信号である.

移動平均のコンボ: 移動平均線は,高速 (8期),中間 (20期),遅い (50期) の組み合わせを使用する. 3つの線が:高速 > 中間 > 遅いとして配置された場合,それは上向きの傾向である.高速 < 中間 < 遅いとして配置された場合,それは下向きの傾向である. コンボは全体的なトレンド方向を決定するために使用されます.

トレンド方向フィルター: 閉じる価格がスロー・ムービング・平均値以上で,中間移動平均値 (20期) が上向きであるときのみ購入信号が生成される (期間中の最高価格>最低価格).閉じる価格がスロー・ムービング・平均値 (20期) の下向きであるときのみ販売信号が生成される.これはいくつかの逆偽信号をフィルタリングすることができます.

QQE指標のクロスオーバー・シグナルと移動平均値のトレンドフィルタリングを組み合わせることで,主要タイムフレームトレンドの短期的な逆転点を把握し,比較的完全な取引システムを形成する.同時に,トレンドのターニングポイントをできるだけ早く把握するために,指標パラメータは比較的敏感に設定されている.

概要すると,これは中期と長期の傾向を追跡し,短期の逆転のタイミングを把握するために高速指標を使用し,移動平均フィルタリングを使用して,方向性に反する取引のリスクを軽減し,その結果収益を最大化するための戦略です.

戦略 の 利点

  • 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

もっと