トリプル・スーパートレンドとEMAとADX戦略

作者: リン・ハーンチャオチャン, 日付: 2023-09-18 14:02:12
タグ:

概要

これはトリプルスーパートレンド,EMA,ADXインジケーターを組み合わせた定量的な取引戦略である.トリプルスーパートレンドシステムを用いて取引信号を生成し,EMAとADXをフィルターとして適用し,取引頻度を制御し,信号品質を改善する.

戦略の論理

  • 異なるパラメータを持つ3つのスーパートレンドシステムを使用し,すべての3つのスーパートレンドが方向性について合意するときに取引信号を生成します.

  • EMA をトレンドフィルターとして適用し,EMA の上にある Close の場合だけロングで,EMA の下にある Close の場合だけショートします.

  • ADX をトレンド強度フィルターとして適用し,ADX が値を超えると取引するだけです.

  • 収益性とリスク管理を調整するために再入国オプションを許可する.

具体的には,ロングエントリー条件は,3つのスーパートレンドがすべて上昇し,閉じるがEMA以上であり,ADXが値より高いときである.ショートエントリー条件は,3つのスーパートレンドがすべて下落し,閉じるがEMA以下であり,ADXが値より高いときである.スーパートレンドのいずれかが逆方向になると退出する.

この戦略は,視覚的なトレンド決定を助けるためにスーパートレンドサポートとレジスタンスラインをプロットしています.

利点分析

  • トリプル・スーパートレンドシステムは 偽のブレイクをフィルタリングし 入力精度を向上させます

  • EMAとADXのダブルフィルターは 損失を削減し リスク管理を強化します

  • 再入国オプションは,リスクの優先順位に基づいて収益性を調整することができます.

  • 視覚的な超トレンドラインはトレンドの方向性を決定するのに役立ちます

リスク分析

  • スーパートレンドや他の指標は遅延があり,遅刻入入や早退を引き起こす可能性があります.

  • 過度に厳格なフィルターは 機会を逃す可能性があります

  • Whipsawsは,範囲限定市場での損失を引き起こす可能性があります.

  • 再入国を許すことで 貿易頻度や 流出コストが増加します

これらのリスクは,パラメータ,フィルター,ダイナミックストップの最適化によって軽減できます.不確実な市場状況に対処するために,ポジションサイズと厳格なストップが適用されるべきです.

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

この戦略は,いくつかの側面で最適化することができます:

  • 異なるパラメータの組み合わせをテストし,最適なスーパートレンドとEMA設定を見つけます.

  • 誤った信号を減らすために ADX 限界値を最適化します

  • 波動性,ボリュームなどなどのフィルターを追加します

  • 異なる製品でパラメータを個別に最適化する.

  • リスク管理の改善のために ダイナミックなストップ・ロスのメカニズムを構築する.

  • 機械学習を利用して より良い入出ルールを見つけます

概要

この戦略は,トリプルスーパートレンドシステムの強みを活用し,EMAとADXのダブルフィルターで強化し,シグナル品質を効果的に改善し,リスクを制御する.パラメータ,フィルター,ダイナミックストップのさらなる強化により,その強度と適応性が向上する.トレンド分析と組み合わせると,定量的な取引のための効果的なエントリーと出口シグナルを提供します.


/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©kunjandetroja


//@version=5
strategy('Triple Supertrend with EMA and ADX', overlay=true)

m1 = input.float(1,"ATR Multi",minval = 1,maxval= 6,step=0.5,group='ST 1')
m2 = input.float(2,"ATR Multi",minval = 1,maxval= 6,step=0.5,group='ST 2')
m3 = input.float(3,"ATR Multi",minval = 1,maxval= 6,step=0.5,group='ST 3')
p1 = input.int(10,"ATR Multi",minval = 5,maxval= 25,step=1,group='ST 1')
p2 = input.int(15,"ATR Multi",minval = 5,maxval= 25,step=1,group='ST 2')
p3 = input.int(20,"ATR Multi",minval = 5,maxval= 25,step=1,group='ST 3')
len_EMA = input.int(200,"EMA Len",minval = 5,maxval= 250,step=1)
len_ADX = input.int(14,"ADX Len",minval = 1,maxval= 25,step=1)
len_Di = input.int(14,"Di Len",minval = 1,maxval= 25,step=1)
adx_above = input.float(25,"adx filter",minval = 1,maxval= 50,step=0.5)
var bool long_position = false
adx_filter = input.bool(false, "Add Adx & EMA filter")
renetry = input.bool(true, "Allow Reentry")

f_getColor_Resistance(_dir, _color) =>
    _dir == 1 and _dir == _dir[1] ? _color : na
f_getColor_Support(_dir, _color) =>
    _dir == -1 and _dir == _dir[1] ? _color : na

[superTrend1, dir1] = ta.supertrend(m1, p1)
[superTrend2, dir2] = ta.supertrend(m2, p2)
[superTrend3, dir3] = ta.supertrend(m3, p3)
EMA = ta.ema(close, len_EMA)
[diplus,diminus,adx] = ta.dmi(len_Di,len_ADX)

// ADX Filter
adxup = adx > adx_above and close > EMA
adxdown = adx > adx_above and close < EMA

sum_dir = dir1 + dir2 + dir3

dir_long = if(adx_filter == false)
    sum_dir == -3
else
    sum_dir == -3 and adxup
dir_short = if(adx_filter == false)
    sum_dir == 3
else
    sum_dir == 3 and adxdown
Exit_long = dir1 == 1 and dir1 != dir1[1]
Exit_short = dir1 == -1 and dir1 != dir1[1]

// BuySignal = dir_long and dir_long != dir_long[1]
// SellSignal = dir_short and dir_short != dir_short[1]
// if BuySignal
//     label.new(bar_index, low, 'Long', style=label.style_label_up)
// if SellSignal
//     label.new(bar_index, high, 'Short', style=label.style_label_down)

longenter = if(renetry == false)
    dir_long and long_position == false
else
    dir_long
shortenter = if(renetry == false)
    dir_short and long_position == true
else
    dir_short
if longenter
    long_position := true
if shortenter
    long_position := false

strategy.entry('BUY', strategy.long, when=longenter)
strategy.entry('SELL', strategy.short, when=shortenter)   
strategy.close('BUY', Exit_long)
strategy.close('SELL', Exit_short)

buy1 = ta.barssince(dir_long)
sell1 = ta.barssince(dir_short)

colR1 = f_getColor_Resistance(dir1, color.red)
colS1 = f_getColor_Support(dir1, color.green)

colR2 = f_getColor_Resistance(dir2, color.orange)
colS2 = f_getColor_Support(dir2, color.yellow)

colR3 = f_getColor_Resistance(dir3, color.blue)
colS3 = f_getColor_Support(dir3, color.maroon)

plot(superTrend1, 'R1', colR1, linewidth=2)
plot(superTrend1, 'S1', colS1, linewidth=2)

plot(superTrend2, 'R1', colR2, linewidth=2)
plot(superTrend2, 'S1', colS2, linewidth=2)

plot(superTrend3, 'R1', colR3, linewidth=2)
plot(superTrend3, 'S1', colS3, linewidth=2)

// // Intraday only
// var int new_day = na
// var int new_month = na
// var int new_year = na
// var int close_trades_after_time_of_day = na

// if dayofmonth != dayofmonth[1]
//     new_day := dayofmonth
// if month != month[1]
//     new_month := month
// if year != year[1]
//     new_year := year
// close_trades_after_time_of_day := timestamp(new_year,new_month,new_day,15,15)

// strategy.close_all(time > close_trades_after_time_of_day) 


もっと