Hanyue - 複数のEMA、ATR、RSIに基づくトレンドフォロー取引戦略

EMA ATR RSI
作成日: 2024-05-14 16:37:52 最終変更日: 2024-05-14 16:37:52
コピー: 1 クリック数: 601
1
フォロー
1617
フォロワー

Hanyue - 複数のEMA、ATR、RSIに基づくトレンドフォロー取引戦略

概要

この戦略は,3つの異なる周期の指数移動平均線 (EMA) を使って市場のトレンドを判断し,相対的に強い指数 (RSI) と平均実際の波幅 (ATR) を組み合わせて,エントリーポイントとストロップポイントを決定する.価格が3つのEMAが形成する通路を突破し,RSIも移動平均線を突破すると,戦略は倉庫開きシグナルを誘発する.同時に,ATRは,ポジションの規模を制御し,ストップポイントを設定するために使用され,収益リスク比率は (RRR) はストップポイントを決定するために使用されます.この戦略の主要な優点は,単純で有効であり,市場トレンドに順応して取引することができ,そして厳しい風格制御によって潜在的な損失を制限します.

戦略原則

  1. 市場全体の傾向を判断するために,3つの異なる周期 (短期,中期,長期) のEMAを計算します.
  2. RSI指標は,トレンドの強さと持続性を確認するために使用され,RSIが移動平均線を突破すると,トレンドが変化したことを示す.
  3. 価格とEMAチャネルとの関係とRSI信号を組み合わせて,開倉信号を生成します.価格がEMAチャネルを突破し,RSIも移動平均を突破すると,トレンドの方向に沿って開倉します.
  4. ATRは,各取引のリスクの限界を制御するために,ポジションの規模とストップロスを決定します.
  5. 戦略の収益性を確保するために,既定の利益リスク (例えば1.5:1) に基づいてストップを設定します.

優位分析

  1. シンプルで効果的: この戦略は,いくつかの一般的な技術指標のみを使用し,論理は明確で,理解し,実行しやすい.
  2. トレンドフォロー: EMAチャネルとRSIの組み合わせにより,戦略は市場のトレンドに順応して取引し,より大きな価格変動を捕捉することができます.
  3. リスク管理:ATRを使用して,ストップ・ロスを設定し,ポジションの規模を制御し,取引毎のリスクの限界を効果的に制限します.
  4. 柔軟性:戦略パラメータ (EMA周期,RSI周期,ATR倍数など) は,異なる市場と取引スタイルに応じて調整され,パフォーマンスを最適化できます.

リスク分析

  1. パラメータ最適化: 戦略のパフォーマンスは,パラメータの選択に大きく依存し,不適切なパラメータ設定は,戦略の失敗や不良なパフォーマンスを引き起こす可能性があります.
  2. 市場リスク:突発的な出来事や極端な状況において,特にトレンドの逆転や震動の市場において,戦略は大きな損失を被る可能性があります.
  3. 超模倣:パラメータ最適化の過程で過去データを過剰に模倣すると,実際の取引において戦略がうまく機能しない可能性があります.

改善する方向

  1. 動態パラメータ:市場の状況の変化に応じて動態調整策のパラメータ,例えばトレンドが明瞭であるときにより長いEMAサイクルを使用し,震市場ではより短いサイクルを使用する.
  2. 他の指標を組み合わせる:開倉信号の信頼性と正確性を高めるために,他の技術指標 (ブリン帯,MACDなど) を導入する.
  3. 市場情緒への参加: 市場情緒指標 (恐怖・貪欲指数など) を組み合わせて,戦略を調整するリスクの口と倉庫管理.
  4. マルチタイムフレーム分析: 市場のトレンドやシグナルを異なる時間枠で分析し,より全面的な市場見通しとより安定した取引決定を得る.

結論から言うと

この戦略は,EMA,RSI,ATRなどの複数の一般的な技術指標を組み合わせて,シンプルで効果的なトレンドフォロー取引システムを構築している.市場トレンドを判断するためにEMAチャネルを使用し,トレンドの強さを確認するためにRSIを使用し,リスクを制御するためにATRを使用している.戦略の優点は,そのシンプルさと適応性であり,異なる市場条件に合わせてトレンド取引を行うことができる.しかし,戦略の現在の表は,基準の選択に大きく依存しており,不適切なパラメータの設定は,戦略の失敗または不良なパフォーマンスを引き起こす可能性があります.さらに,突発的事件または極端な状況下では,戦略はより大きなリスクにさらされる可能性があります.

ストラテジーソースコード
/*backtest
start: 2024-04-01 00:00:00
end: 2024-04-30 23:59:59
period: 1h
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/
// © hatnxkld

//@version=4
strategy("Win ha", overlay=true)

ss2 = input("0300-1700", title = "Khung thời gian")

t2 = time(timeframe.period,ss2)
c2 = #cacae6

bgcolor(t2 ? c2 : na, transp = 70)


//3ema
emangan=input(title="Ema ngắn", defval = 12)
ngan=ema(close, emangan)
a= plot(ngan, title="EMA ngắn", color=color.yellow)
ematb=input(title="Ema trung bình", defval = 100)
tb=ema(close, ematb)
b= plot(tb, title="EMA trung bình", color=color.blue)
//emadai=input(title="Ema dai", defval = 288)
//dai=ema(close,emadai)
//c= plot(dai, title="EMA dai", color=color.red)




// nhập hệ số nhân ATR
i=input(title="Hệ số nhân với ATR", defval=1.25)

// RSI
rsi=rsi(close, emangan)
marsi=sma(rsi, emangan)

// Kênh keltler
//heso=input(defval=1, title="Hệ số Kênh Keltler")
//atr=atr(emangan)
//tren=ngan+atr*heso
//d=plot(tren, title="Kênh trên", color=color.white)
//duoi=ngan-atr*heso
//e=plot(duoi, title="Kênh dưới", color=color.white)
//fill(d,e, color=color.rgb(48, 58, 53))

ban = ( close[1]>open[1] and (high[1]-close[1])>(close[1]-low[1]) and open>close and close<low[1]   ) 


//or (    open[1] > close[1] and (high[1]-open[1])>(open[1]-low[1]) and (open[1]-close[1])>(close[1]-low[1]) and open>close and close <low[1]     )   )  //and time(timeframe.period,"2200-1300")
//and (close[1]-open[1])>(open[1]-low[1]) 
//high > ngan and close < ngan and ngan<tb and 
// and time(timeframe.period,"1000-2300")
bgcolor(color = ban ? color.rgb(235, 106, 123) : na)
//bgcolor(color.rgb(82, 255, 154),transp = 100, offset = 1, show_last = 2)
//and time(timeframe.period,"2300-1500") and ((open>ngan and close<ngan) or (open>tren and close<tren))
plotshape(ban , style=shape.arrowdown, location=location.abovebar, color=#ff00ff, size=size.tiny, textcolor=color.rgb(255, 59, 213))
alertcondition(ban, "Ban", "Ban")

mua=  (  open[1]>close[1] and (close[1]-low[1])>(high[1]-close[1]) and close > open and close > high[1]  )  //and time(timeframe.period,"2200-1300")


//or  (  close[1]>open[1] and (open[1]-low[1]) > (high[1]-open[1]) and (close[1]-open[1])>(high[1]-close[1]) and close>open and close>high[1]      ) )
//and (open[1]-close[1])>(high[1]-open[1])
//low < ngan and close > ngan and ngan>tb and
//or  (  close[1]>open[1] and (open[1]-low[1]) > (high[1]-open[1]) and (close[1]-open[1])>(high[1]-close[1]) and close>open and close>high[1]      )

// and time(timeframe.period,"1000-2300")
bgcolor(color= mua? color.rgb(108, 231, 139):na)
//and time(timeframe.period,"2300-1500") and ((open<ngan and close>ngan)or (open<duoi and close>duoi) )
plotshape(mua , style=shape.arrowup, location=location.belowbar, color=#00ff6a, size=size.tiny, textcolor=color.rgb(83, 253, 60))
alertcondition(mua , "Mua", "Mua")


//len1 = ban==true and (high-low)>2*atr
//plotshape(len1 , style=shape.flag, location=location.abovebar, color=#ff00ff, size=size.tiny, title="Sell Signal", text="Xuong 1", textcolor=color.rgb(255, 59, 213))

//bann= ban==true and rsi < marsi and marsi[2]>marsi[1]
//plotshape(bann , style=shape.labeldown, location=location.abovebar, color=#ff00ff, size=size.tiny, title="Sell Signal", text="BAN 2", textcolor=color.rgb(240, 234, 239))

//bannn = mua==true and rsi>marsi and marsi[2]<marsi[1]
//plotshape(bannn , style=shape.labelup, location=location.belowbar, color=#00ff6a, size=size.tiny, title="Buy Signal", text="Mua 2", textcolor=color.rgb(237, 241, 236))

//a1= ban==true and (high - low)<atr 
//plotshape(a1 , style=shape.xcross, location=location.bottom, color=#00ff6a, size=size.tiny, title="Sell", text="<atr", textcolor=color.rgb(240, 95, 76))

//a2 = ban ==true and (high - low)>atr and (high - low)<(2*atr) 
//plotshape(a2 , style=shape.xcross, location=location.bottom, color=#00ff6a, size=size.tiny, title="Sell", text="<2atr", textcolor=color.rgb(237, 241, 236))

//a3= ban==true and (high - low)>(2*atr) 
//plotshape(a3 , style=shape.xcross, location=location.bottom, color=#00ff6a, size=size.tiny, title="Sell", text=">2atr", textcolor=color.rgb(234, 252, 74))


//b1= mua==true and (high - low)<atr 
//plotshape(b1 , style=shape.xcross, location=location.bottom, color=#00ff6a, size=size.tiny, title="Buy", text="<atr", textcolor=color.rgb(237, 241, 236))

//b2 = mua ==true and (high - low)>atr and (high - low)<(2*atr) 
//plotshape(b2 , style=shape.xcross, location=location.bottom, color=#00ff6a, size=size.tiny, title="Buy", text="<2atr", textcolor=color.rgb(237, 241, 236))

//b3= mua==true and (high - low)>(2*atr) 
//plotshape(b3 , style=shape.xcross, location=location.bottom, color=#00ff6a, size=size.tiny, title="Buy", text=">2atr", textcolor=color.rgb(237, 241, 236))

// Đặt SL TP ENTRY
risk= input(title="Rủi ro % per Trade", defval=0.5)
rr= input(title="RR", defval=1.5)
onlylong= input(defval=false)
onlyshort=input(defval=false)

stlong = mua and strategy.position_size<=0 ? low[1]:na
stoplong= fixnan(stlong)

stshort = ban and strategy.position_size>=0 ? high[1]:na
stopshort= fixnan(stshort)

enlong = mua and strategy.position_size<=0 ? close:na
entrylong =fixnan(enlong)

enshort = ban and strategy.position_size>=0 ? close:na
entryshort = fixnan(enshort)

amountL = risk/100* strategy.initial_capital / (entrylong - stoplong)
amountS = risk/100* strategy.initial_capital / (stopshort - entryshort)

TPlong= mua and strategy.position_size<=0? entrylong + (entrylong -stoplong)*rr:na
takeprofitlong =fixnan(TPlong)
TPshort = ban and strategy.position_size>=0? entryshort - (stopshort - entryshort)*rr:na 
takeprofitshort = fixnan(TPshort)

strategy.entry("Long", strategy.long , when = enlong and not onlyshort, qty= amountL )
strategy.exit("exitL", "Long", stop = stoplong, limit= takeprofitlong)

strategy.entry("Short", strategy.short , when = enshort and not onlylong, qty= amountS )
strategy.exit("exitS", "Short", stop = stopshort, limit= takeprofitshort)