コンボ・トレード戦略 123 リバースとMACDに基づく

作者: リン・ハーンチャオチャン開催日:2023年9月19日17時30分
タグ:

概要

この戦略は, 123 の逆転パターンと MACD インジケーターを組み合わせて,フィルタリングを通じてより強い取引信号を生成する. 123 の逆転は短期的な逆転機会を捉え,MACD は中長期のトレンドガイドを提供します. コンボ信号は高確率の取引設定を効果的に発見することができます.

戦略の論理

  1. 123 逆転戦略は,過去2日間がダウン日であり,今日の閉店が上昇し,ストキャスティックは値以下で,過去2日間が上昇し,今日がダウン日であり,ストキャスティックは値以上で,売却します.

  2. MACD戦略は,高速MAが遅いMAよりも高くなったときに長く,高速MAが遅いMAよりも低くなったときに短くなります.

  3. 取引は両戦略が一致する場合にのみ行われます.そうでなければ,取引方向が変更されることがあります.

利点分析

主な利点:

  1. コンボ信号は 偽の脱出を効果的にフィルタリングし 勝利率を向上させる

  2. 123は短期的な逆転を記録し,MACDは中長期的傾向の方向性を判断します.

  3. 123でストカスティックはトレンド逆転後 過度な取引を避けます

  4. 2つの戦略は異なるタスクを共有し 相互に検証し 過度に最適化しないのです

  5. 簡単にロング/ショートに切り替えて,様々な市場環境に適応できます.

リスク分析

主なリスク:

  1. コンボ信号は保守的で 良い機会を逃しているかもしれません

  2. 逆転は突然の出来事に 容易になり 失敗しやすい

  3. ストップロスの欠如は 戦略を大きな損失にさらします

  4. ダブルフィルタリングは,トレンドトレードが欠けている可能性があります.

  5. パラメータの最適化がないため,デフォルト値はすべての機器に適合しない可能性があります.

オプティマイゼーションの方向性

改善:

  1. 最適値を見つけるために異なるパラメータの組み合わせをテストする.

  2. ストップ・ロスは,取引ごとにコントロール・ロスを追加します.

  3. 信号の質を向上させるため,より多くのフィルター指標を組み込む.

  4. 自動パラメータ最適化のための機械学習モデルを導入する.

  5. 信頼性を評価するために,より多くの取引手段をテストします.

  6. 市場の条件に基づいて 変数セットを切り替える

概要

総合的に,二重信号を組み合わせると,単一の戦略と比較して過剰な最適化が避けられます.より多くのフィルター,ストップ損失などの追加により,堅牢で実践的な定量的な取引戦略になり得ます.


/*backtest
start: 2023-09-11 00:00:00
end: 2023-09-14 02:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 24/07/2020
// 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
// This is one of the techniques described by William Blau in his book
// "Momentum, Direction and Divergence" (1995). If you like to learn more,
// we advise you to read this book. His book focuses on three key aspects
// of trading: momentum, direction and divergence. Blau, who was an electrical
// engineer before becoming a trader, thoroughly examines the relationship 
// between price and momentum in step-by-step examples. From this grounding,
// he then looks at the deficiencies in other oscillators and introduces some
// innovative techniques, including a fresh twist on Stochastics. On directional 
// issues, he analyzes the intricacies of ADX and offers a unique approach to help 
// define trending and non-trending periods.
// Blau`s indicator is like usual MACD, but it plots opposite of meaningof
// stndard MACD indicator.  
//
// 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

fADX(Len) =>
    up = change(high)
    down = -change(low)
    trur = rma(tr, Len)
    plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, Len) / trur)
    minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, Len) / trur)
    sum = plus + minus 
    100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), Len)

EMACD(r,SmthLen,LengthMACD) =>
    pos = 0
    source = close
    fastMA = ema(source, r)
    slowMA = ema(source, LengthMACD)
    xmacd = fastMA - slowMA
    xMA_MACD = ema(xmacd, SmthLen)
    pos := iff(xmacd < xMA_MACD, -1,
    	     iff(xmacd > xMA_MACD, 1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Ergodic MACD", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
r = input(14, minval=1)
LengthMACD = input(21, minval=1)
SmthLen = input(5, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posEMACD = EMACD(r,SmthLen,LengthMACD)
pos = iff(posReversal123 == 1 and posEMACD == 1 , 1,
	   iff(posReversal123 == -1 and posEMACD == -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 )

もっと