EMA と RSI 戦略 に 続く 傾向

作者: リン・ハーンチャオチャン, 日時: 2023-09-26 15:39:48
タグ:

概要

この戦略は,動向平均値と相対強度指数を完全に活用し,トレンドを特定し,追跡する.トレンドを決定し,適切なエントリー/エグジットタイミングを見つけるには2つの指標のみが必要です.この戦略は,短期的な市場騒音を回避しながら,中長期の価格トレンドを把握することを目指しています.

戦略の論理

この戦略は,異なる期間の3つのEMAを使用しており,EMA-Aは最短期,EMA-Bは中期期,EMA-Cは最長期である.より短いEMA-Aがより長いEMA-Bを超えると,上向きの傾向を示し,したがってロングになります.逆にEMA-AがEMA-Bを下回ると,下向きの傾向を示し,したがってショートになります.偽信号をフィルタリングするために,最も長いEMA-Cも使用します.価格がEMA-Cを破った後にエントリーを検討するだけです.

この戦略は,出口ポイントを特定するためにRSIも使用する.ロングの場合,RSIが70を超えるとポジションを閉じる.ショートの場合,RSIが30を下回るとポジションを終了する.これはトレンド利益をロックし,損失がさらに拡大するのを防ぐ.

利点分析

  • トレンド識別においてEMAの強みを活用する
  • RSI は 入国 と 退出 の タイミング に 役立つ
  • シンプルな戦略で2つの指標のみ
  • 戦略スタイルを調整するためのカスタマイズ可能なパラメータ
  • 初期,中期,後期トレンド段階からの利益

リスク分析

  • 主要なトレンドの引き下げは誤った信号を生む可能性があります
  • 異なる市場における 鞭策に弱い
  • RSI パラメーターが不適切なら 早期出出が原因になる
  • EMA 期間は慎重に選択する必要があります.あまりにも短すぎると騒音に敏感になり,あまりにも長くなった場合,傾向を見逃す可能性があります.

これらのリスクは,RSIパラメータを最適化し,フィルターを追加し,トレンド分析と組み合わせることで軽減できます.

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

  • より良い利益とリスク管理のために RSI パラメータを最適化
  • 異なるEMA期間の組み合わせをテストする
  • 音量または他の確認指標を追加する
  • ストップ・ロスのサイズの ATR を使用する
  • トレンドの中間でのポジションサイズ削減を検討する
  • ブレイクアウト,ボリュームなどでエントリータイミングを最適化
  • 再入国メカニズムを探る

概要

この戦略は,トレンド識別とキャプチャのためのトレンドフォローとオシレーター指標を組み合わせます.単純なパラメータと論理最適化により,シンプルさを保ちながら大幅に改善できます.中長期投資家に適した非常に実践的なトレンドフォローテンプレートです.


/*backtest
start: 2023-08-26 00:00:00
end: 2023-09-25 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/
//@author Alorse

//@version=5
// strategy(title='Tendency EMA + RSI [Alorse]', shorttitle='Tendece EMA + RSI [Alorse]', overlay=true, pyramiding=0, currency=currency.USD, default_qty_type=strategy.percent_of_equity, initial_capital=1000, default_qty_value=20, commission_type=strategy.commission.percent, commission_value=0.01)

// Bollinger Bands
len = input.int(14, minval=1, title='Length', group='RSI')
src = input.source(close, 'Source', group='RSI')
rsi = ta.rsi(src, len)

// Moving Averages
len_a = input.int(10, minval=1, title='EMA A Length', group='Moving Averages')
out_a = ta.ema(close, len_a)
plot(out_a, title='EMA A', color=color.purple)

len_b = input.int(20, minval=1, title='EMA B Length', group='Moving Averages')
out_b = ta.ema(close, len_b)
plot(out_b, title='EMA B', color=color.orange)

len_c = input.int(100, minval=1, title='EMA C Length', group='Moving Averages')
out_c = ta.ema(close, len_c)
plot(out_c, title='EMA B', color=color.green)

// Strategy Conditions
stratGroup = 'Strategy'
showLong = input.bool(true, title='Long entries', group=stratGroup)
showShort = input.bool(false, title='Short entries', group=stratGroup)
closeAfterXBars = input.bool(true, title='Close after X # bars', tooltip='If trade is in profit', group=stratGroup)
xBars = input.int(24, title='# bars')

entryLong = ta.crossover(out_a, out_b) and out_a > out_c and close > open
exitLong = rsi > 70

entryShort = ta.crossunder(out_a, out_b) and out_a < out_c and close < open
exitShort = rsi < 30


bought = strategy.opentrades[0] == 1 and strategy.position_size[0] > strategy.position_size[1]
entry_price = ta.valuewhen(bought, open, 0)
var int nPastBars = 0
if strategy.position_size > 0
    nPastBars := nPastBars + 1
    nPastBars
if strategy.position_size == 0
    nPastBars := 0
    nPastBars
if closeAfterXBars
    exitLong := nPastBars >= xBars and close > entry_price ? true : exitLong
    exitLong
    exitShort := nPastBars >= xBars and close < entry_price ? true : exitShort
    exitShort

// Long Entry
strategy.entry('Long', strategy.long, when=entryLong and showLong)
strategy.close('Long', when=exitLong)

// Short Entry
strategy.entry('Short', strategy.short, when=entryShort and showShort)
strategy.close('Short', when=exitShort)



もっと