2つの移動平均逆転取引戦略

作者: リン・ハーンチャオチャン,日付: 2024-01-15 12:35:29
タグ:

img

概要

双動平均逆転取引戦略は,ボリンジャー帯逆転取引戦略と双指数動平均取引戦略を組み合わせて,包括的な信号判断取引戦略を設計する.株式,フォレックス,暗号通貨などの市場で使用することができます.

戦略の原則

戦略は2つの部分からなる.

  1. Bollinger Bands の逆転取引戦略

    ボリンジャー・バンド指標から2つの線 - %K線と%D線を使用します. 閉じる価格が前日の閉じる価格より2日連続で低く,%K線が%D線の上にある場合,ロングに移動します. 閉じる価格が前日の閉じる価格より2日連続で高く,%K線が%D線以下にある場合,ショートに移動します.

  2. 二重指数移動平均戦略

    20 日および 20 日*2 の二重指数関数移動平均値を計算する.価格が二重移動平均値を超えたり下回ったときに取引信号が生成される.

組み合わせられた信号判断のルール: 両方の戦略からの取引信号が一致する場合にのみ実際の取引信号が生成されます.

利点分析

この組み合わせ戦略の最大の利点は,高い信頼性と少数の誤った信号です. なぜなら,2つの異なるタイプの戦略からの信号が同時にトリガーされる必要があるからです. これは,単一の戦略で現れる誤った信号の一部をフィルターします.

さらに,逆転とトレンド戦略を組み合わせることで,短期的な逆転と中期的なトレンドの両方を把握できます.

リスク分析

この戦略の主なリスクは,市場が長期的に振動しているとき,両戦略が一貫した信号を生成できず,無効な市場状況が生じる可能性があることです.この時点で,トレーダーはこの戦略の使用を一時停止し,明確なトレンドが形成されるのを待つ必要があります.

さらに,中長期指標として,二重移動平均は,短期的な逆転が急速に起こると失敗する可能性があります.これは,トレーダーがより多くの指標でより広範な市場動向を判断することを必要とします.

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

戦略は以下の方法で最適化できます.

  1. ストップ・ロスの価格,ストップ・ロスの価格の範囲など,より多くのパラメータを追加して,戦略をより制御できるようにします.

  2. 複数のフィルター基準を形成し,より騒々しい取引を排除するためにより多くの指標を追加します.例えば,MACD,KDおよび他の指標と組み合わせます.

  3. ボリンジャー期,移動平均期など指標パラメータを最適化して,最適なパラメータの組み合わせを見つけます.

  4. この戦略の有効性を 異なる製品 (株式,外為,暗号等) でテストし,最も適したものを選択します.

結論

ダブル移動平均逆転戦略は,逆転とトレンド戦略を組み合わせることで比較的信頼性の高い組み合わせた取引信号を生成する. 証券の価格の短期逆転と中期トレンドの両方に興味を持つトレーダーに適しています. しかし,戦略は長期の範囲に限定された市場で失敗する可能性があることに注意してください. パラメータを最適化し,より多くの指標を追加することで,この戦略の実用性はさらに強化できます.


/*backtest
start: 2023-01-08 00:00:00
end: 2024-01-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 12/04/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.
//
// Secon strategy
// This indicator plots 2/20 exponential moving average. For the Mov 
// Avg X 2/20 Indicator, the EMA bar will be painted when the Alert criteria is met.
// Please, use it only for learning or paper trading. Do not for real trading.
//
// 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

EMA2_20(MA_Length, MA_xPrice) =>
    xXA = ema(MA_xPrice, MA_Length)
    nHH = max(high, high[1])
    nLL = min(low, low[1])
    nXS = iff((nLL > xXA)or(nHH < xXA), nLL, nHH)
    pos = 0.0
    pos := iff(nXS > close[1] , -1, iff(nXS < close[1] , 1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal and 2/20 EMA", shorttitle="Combo Backtest", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
MA_Length = input(20, minval=1)
reverse = input(false, title="Trade reverse")
MA_xPrice = close
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posEMA2_20 = EMA2_20(MA_Length, MA_xPrice)
pos = iff(posReversal123 == 1 and posEMA2_20 == 1 , 1,
	   iff(posReversal123 == -1 and posEMA2_20 == -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 ) 

もっと