Swing 双動平均値と RSI クロスオーバー 戦略

作者: リン・ハーンチャオチャン, 日付: 2024-02-01 11:48:51
タグ:

img

この戦略は,長期と短期間のクロスオーバー取引戦略を構築するために,両動向平均値とRSI指標を統合しています.短期指標で不必要なノイズ取引を回避しながら,中期から長期間のトレンドを把握できます.

戦略の論理

この戦略は,高速移動平均 (EMA 59, EMA 82) とスロー移動平均 (EMA 96, EMA 95) の2つのセットの移動平均を採用している.価格が高速 EMA を越えると長引く.価格が高速 EMA を越えると短引く.一方,RSI インディケーターの過剰購入および過剰販売領域は,取引信号とストップロスの確認に使用される.

具体的には,速いEMAがスローEMAを突破すると,ロングシグナルが生成される.この時点でRSIが30以下 (oversold area) である場合,ロングします.速いEMAがスローEMAを下回ると,ショートシグナルが生成されます.この時点でRSIが70を超えると,ショートします.

デュアル・ムービング・メアディアを使用する利点は,中期から長期間のトレンドの変化をよりよく認識することです.RSIは,偽のブレイクからいくつかのノイズ取引をフィルターします.

利点

  • 双面移動平均値で中長期の傾向を把握する
  • RSI インジケーターによるフィルターノイズ取引
  • トレンドフォローと平均リバース取引を組み合わせる
  • シンプルで明確な論理

リスク分析

  • 主に範囲限定の市場では,移動平均信号は,ウィップソーの対象となる可能性があります.
  • RSIインジケーターも特定の市場条件で失敗します
  • ストップ・ロスの配当は 余りにも緩やかで 余りにも緊密な配当を避けるために 慎重にする必要があります

強化 分野

  • 長いサイクル移動平均の組み合わせを試験する
  • 異なるパラメータの調整を試す.例えば,RSIの過買い/過売り領域の
  • トレーディングボリュームなどの追加のフィルターを追加
  • ストップ・ロスの戦略を最適化し,動的ストップ・ロスをATRに組み込む.

概要

この戦略は,二重移動平均値とRSI指標の平均逆転取引のトレンドフォローを統合している.二重EMAは中長期のトレンド方向を追跡し,RSIは取引シグナルとストップロスの有効性を確認する.これは,ロングとショートとの間のシンプルで実用的なクロスオーバー戦略である.パラメータチューニングと最適化によって異なる市場環境に適応することができる.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Swing Hull/rsi/EMA Strategy", overlay=true,default_qty_type=strategy.cash,default_qty_value=10000,scale=true,initial_capital=10000,currency=currency.USD)

//A Swing trading strategy that use a combination of indicators, rsi for target, hull for overall direction enad ema for entering the martket.
// hull ma copied from syrowof HullMA who copied from mohamed982 :) thanks both
// Performance 

n=input(title="period",defval=500)

n2ma=2*wma(close,round(n/2))
nma=wma(close,n)
diff=n2ma-nma
sqn=round(sqrt(n))

n2ma1=2*wma(close[1],round(n/2))
nma1=wma(close[1],n)
diff1=n2ma1-nma1
sqn1=round(sqrt(n))

n1=wma(diff,sqn)
n2=wma(diff1,sqn)
c=n1>n2?green:red
ma=plot(n1,color=c)



// RSi and Moving averages

length = input( 14 )
overSold = input( 70)
overBought = input( 30)
point = 0.0001
dev= 2

fastLength = input(59)
fastLengthL = input(82)
slowLength = input(96)
slowLengthL = input(95)
price = close

mafast = ema(price, fastLength)
mafastL= ema(price, fastLengthL)
maslow = ema(price, slowLength)
maslowL = ema(price, slowLengthL)
vrsi = rsi(price, length)
cShort =  (crossunder(vrsi, overBought))

condDown = n2 >= n1
condUp = condDown != true
closeLong =  (crossover(vrsi, overSold))
closeShort = cShort 


// Strategy Logic
longCondition = n1> n2
shortCondition = longCondition != true

col =condUp ? lime : condDown ? red : yellow
plot(n1,color=col,linewidth=3)


if (not na(vrsi))
    if shortCondition    
        if (price[0] < maslow[0] and price[1] > mafast[1]) //cross entry
            strategy.entry("SYS-SHORT", strategy.short, comment="short")
strategy.close("SYS-SHORT", when=closeShort) //output logic

if (not na(vrsi))
    if longCondition // swing condition          
        if (price[0] < mafast[0] and price[1] > mafast[1]) //cross entry
            strategy.entry("SYS-LONG", strategy.long, comment="long")
strategy.close("SYS-LONG", when=closeLong) //output logic


// Stop Loss 


sl = input(75)
Stop = sl * 10
Q = 100


strategy.exit("Out Long", "SYS-LONG", qty_percent=Q, loss=Stop)
strategy.exit("Out Short", "SYS-SHORT", qty_percent=Q, loss=Stop)



//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

もっと