トレンドフォローEMAとRSI戦略


作成日: 2023-09-26 15:39:48 最終変更日: 2023-09-26 15:39:48
コピー: 0 クリック数: 978
1
フォロー
1617
フォロワー

概要

この戦略は,移動平均と比較的強い指標の優位性を充分に活用し,トレンドの識別と追跡を実現する.それは,トレンドの判断とエントリー/エグジットのタイミングの選択を可能にするために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で設定できます.
  • トレンドの中期にポジションを下げる
  • 入場タイミングの最適化,破局前高/低点,または吸量エネルギー
  • 再入学制度への参加を検討

要約する

この戦略は,トレンド追跡と超買い超売り指標を統合し,簡単な2つの指標だけでトレンドの判断とキャプチャを実現できます.パラメータの最適化とルール最適化によって,シンプルなままの効果を大幅に向上させることができます.それは非常に実用的なトレンド追跡戦略のテンプレートであり,中長期の投資家に適用されます.

ストラテジーソースコード
/*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)