ADX + RSI戦略


作成日: 2023-09-27 16:27:39 最終変更日: 2023-09-27 16:27:39
コピー: 0 クリック数: 2077
1
フォロー
1617
フォロワー

概要

これはADXとRSIの指標を組み合わせたトレンド追跡戦略である.この戦略は,RSIを判断して超買い状態の超売り状態を判断して取引信号を発信し,ADXを判断して市場傾向を判断し,傾向がはっきりしない取引をフィルタリングし,震動市場の檻を効果的に回避することができる.

戦略原則

  1. 7サイクルRSIで超買いと超売りを判断する
  • RSIが30を下回ると,超売れとされます.
  • RSIが70を超えると,超買いとされます.
  1. ADXでトレンドを判断する
  • ADXが30を超えると,トレンドは明らかだ.
  • ADXが30を下回ると,トレンドが目立たない.
  1. 入場ルール
  • RSIが30未満でADXが30を超えると多めに
  • RSIが70を超え,ADXが30を超えると空白します.
  1. ストップ・ストップ
  • 選択可能な停止停止モードがあり,閉塞停止停止または振動停止停止を選択できます.
  • 終了価格を基準として, 終了のストップ・ストップ・ストープの方法
  • 振動ストップストップは,最近の価格変動の最高最低点で標準化されます.

優位分析

  1. RSI指標は,買い過ぎと売り過ぎを判断し,買いすぎと売りすぎのトラップを減らすのに役立ちます.

  2. ADXは,不確実なトレンドをフィルタリングし,波動的な状況に囚われないようにします.

  3. オプションのストップ・ストップ・モードによりリスクがコントロールできます.

  4. 戦略はシンプルでわかりやすく,初心者向けに活用できます.

  5. 戦略パラメータの最適化スペースは広く,RSI周期,超買い超売り区間,ADX平滑周期などのパラメータを調整することによって最適化できます.

リスク分析

  1. RSIは反調の危険性があり,超買いと超売りシグナルが反調と反転を起こす可能性があります.

  2. ADXはトレンドが遅れていると判断し,トレンド転換点を逃している可能性がある

  3. ストップ・ストップ・ポイントの不合理な設定は損失を招く可能性があります.

  4. 戦略は単純で,過度に最適化されるリスクがある

  5. パーメータを最適化して より良い結果を得る

最適化の方向

  1. RSIのパラメータを最適化し,超買超売の区間を調整し,最適なパラメータの組み合わせを見つけることができます.

  2. 異なる周期のADXをテストし,トレンドを判断するのに最適なパラメータを見つけることができます.

  3. 異なるストップ・ストップ・ロスをテストして,戦略に最も適した設定を見つけることができます.

  4. トレンドフィルターで逆行を避ける

  5. 戦略の優位性を高めるために,他の指標と組み合わせることができる

要約する

この戦略は,RSIとADXの2つのクラシック指標の優位性を統合し,トレンドを効果的に発見し,揺れを回避し,シンプルで実用的なトレンド追跡戦略である.戦略の最適化スペースは大きく,パラメータの組み合わせを調整することによってより良い効果を得ることができる.全体的に,この戦略は,学習アルゴリズム取引の初心者向けの入門戦略として適しています.また,より複雑な戦略システムにモジュールとして統合することができます.

ストラテジーソースコード
/*backtest
start: 2023-09-19 00:00:00
end: 2023-09-26 00:00:00
period: 15m
basePeriod: 5m
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/
// © tweakerID

// This is a strategy that uses the 7 Period RSI to buy when the indicator is shown as oversold (OS) and sells when 
// the index marks overbought (OB). It also uses the ADX to determine whether the trend is ranging or trending
// and filters out the trending trades. Seems to work better for automated trading when the logic is inversed (buying OB 
// and selling the OS) wihout stop loss.

//@version=4
strategy("ADX + RSI Strat", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=100, commission_value=0.04, calc_on_every_tick=false)

direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))


//SL & TP Inputs
i_SL=input(false, title="Use Swing Lo/Hi Stop Loss & Take Profit")
i_SwingLookback=input(20, title="Swing Lo/Hi Lookback")
i_SLExpander=input(defval=0, step=.2, title="SL Expander")
i_TPExpander=input(defval=0, step=.2, title="TP Expander")
i_reverse=input(true, title="Reverse Trades")

//SL & TP Calculations
SwingLow=lowest(i_SwingLookback)
SwingHigh=highest(i_SwingLookback)
bought=strategy.position_size != strategy.position_size[1]
LSL=valuewhen(bought, SwingLow, 0)-((valuewhen(bought, atr(14), 0))*i_SLExpander)
SSL=valuewhen(bought, SwingHigh, 0)+((valuewhen(bought, atr(14), 0))*i_SLExpander)
lTP=strategy.position_avg_price + (strategy.position_avg_price-(valuewhen(bought, SwingLow, 0))+((valuewhen(bought, atr(14), 0))*i_TPExpander))
sTP=strategy.position_avg_price - (valuewhen(bought, SwingHigh, 0)-strategy.position_avg_price)-((valuewhen(bought, atr(14), 0))*i_TPExpander)
islong=strategy.position_size > 0
isshort=strategy.position_size < 0
SL= islong ? LSL : isshort ? SSL : na
TP= islong ? lTP : isshort ? sTP : na

//RSI Calculations
RSI=rsi(close, 7)
OS=input(30, step=5)
OB=input(80, step=5)

//ADX Calculations
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
	up = change(high)
	down = -change(low)
	plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
	minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(plusDM, len) / truerange)
	minus = fixnan(100 * rma(minusDM, len) / truerange)
	[plus, minus]
adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
adxlevel=input(30, step=5)


//Entry Logic
BUY = sig < adxlevel and (RSI < OS) 
SELL = sig < adxlevel and (RSI > OB) 

//Entries
strategy.entry("long", strategy.long, when=i_reverse?SELL:BUY)
strategy.entry("short", strategy.short, when=not i_reverse?SELL:BUY)
//Exits
if i_SL
    strategy.exit("longexit", "long", stop=SL, limit=TP)
    strategy.exit("shortexit", "short", stop=SL, limit=TP)

//Plots
plot(i_SL ? SL : na, color=color.red, style=plot.style_cross, title="SL")
plot(i_SL ? TP : na, color=color.green, style=plot.style_cross, title="TP")
plotshape(BUY ? 1 : na, style=shape.triangleup, location=location.belowbar, color=color.green, title="Bullish Setup")
plotshape(SELL ? 1 : na, style=shape.triangledown, location=location.abovebar, color=color.red, title="Bearish Setup")