RSIインジケーターと移動平均インジケーターを使用した定量戦略


作成日: 2024-01-24 14:31:01 最終変更日: 2024-01-24 14:31:01
コピー: 0 クリック数: 715
1
フォロー
1617
フォロワー

RSIインジケーターと移動平均インジケーターを使用した定量戦略

概要

双RSI平均線突破戦略は,RSI指標と平均線指標を同時に使用して取引のタイミングを判断する量的な戦略である.この戦略の核心思想は,RSI指標が超買い超売り領域に達すると,平均線の方向を利用してシグナルをフィルターし,より優良な突破点を探してポジションを構築することである.

戦略原則

  1. ユーザが設定したパラメータに基づいて,RSI指数とシンプル移動平均SMAをそれぞれ計算する.

  2. RSIが設定された超売りライン ((デフォルト30) を越えたとき,LONGの退出平均線を下回った場合,多頭シグナルが生成されます.

  3. RSIが設定された超買線 (デフォルト70) を下を通るとき,SHORTの退出平均線より価格が高くなった場合,空頭シグナルが生成されます.

  4. フィルタリング平均線を選択し,価格がフィルタリング平均線上にある場合にシグナルを発信する.

  5. ポジションの退出は,LONG退出平均線とSHORT退出平均線に従って判断されます.

優位分析

  1. 市場における2つの要因を総合的に考慮して,意思決定の正確性を向上させるための二重指標設計.

  2. RSIの反転特性を合理的に利用し,反転のタイミングを探してください.

  3. 平均線フィルターにより,判断の厳しさが高められ,高低追及が避けられます.

  4. カスタムパラメータを許容し,異なる品種と周期に対して最適化することができる.

  5. シンプルで論理的なデザインで,理解し,修正しやすい.

リスク分析

  1. RSI指標は垂直線を生成しやすいが,密度指標はこれを軽減する.

  2. 大周期下でのRSIは失敗しやすく,パラメータ最適化や他の指標の補助を減らすことができます.

  3. 平均線は遅滞性があり,平均線長を適切に短縮するか,MACDなどの指標を補助する.

  4. 簡単な判断条件により,より多くの指標を導入し,取引信号の効果を保証できます.

最適化の方向

  1. RSIパラメータを最適化したり,Density指標を導入したりすると,偽信号の確率が低下する.

  2. DMI,BOLLなどのトレンドと波動の指標を組み合わせてトレンドと支度を決定します.

  3. MACDなどの指標の代替または配合均線判断を導入する.

  4. ポジション開設条件の論理を追加し,不適切な突破シグナルを防止する.

要約する

双RSI均線突破戦略は,RSI指標を総合的に使用して,超売りと平均線判断のトレンドを判断し,理論的には反転の機会を効果的に捉えることができます. この戦略は,柔軟で簡潔で,使いやすいですが,異なる品種の最適化にも適しています. 推薦に値する量化入門戦略です.

ストラテジーソースコード
/*backtest
start: 2024-01-16 00:00:00
end: 2024-01-23 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Global Market Signals: RSI Strategy.
//@version=4
strategy("GMS: RSI Strategy", overlay=true)

LongShort = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
RSILength = input(title="RSI Length", type = input.integer ,defval=14)
RSIUpper = input(title="Upper Threshold", type = input.float ,defval=70)
RSILower = input(title="Lower Threshold", type = input.float ,defval=30)
LongExit = input(title="Long Exit SMA Length", type = input.integer ,defval=5)
ShortExit = input(title="Short Exit SMA Length", type = input.integer ,defval=5)
AboveBelow = input(title="Trend SMA Filter?", type=input.string, defval="Above", options=["Above", "Below", "Don't Include"])
TrendLength = input(title="Trend SMA Length", type = input.integer ,defval=200)


//Long Side

if LongShort =="Long Only" and AboveBelow == "Above"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close>sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
if LongShort =="Long Only" and AboveBelow == "Below"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close<sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
if LongShort =="Long Only" and AboveBelow == "Don't Include"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
if LongShort =="Both" and AboveBelow == "Above"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close>sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
if LongShort =="Both" and AboveBelow == "Below"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close<sma(close,TrendLength))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
if LongShort =="Both" and AboveBelow == "Don't Include"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
    
//SHORT SIDE

if LongShort =="Short Only" and AboveBelow == "Above"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
if LongShort =="Short Only" and AboveBelow == "Below"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
if LongShort =="Short Only" and AboveBelow == "Don't Include"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
if LongShort =="Both" and AboveBelow == "Above"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
if LongShort =="Both" and AboveBelow == "Below"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
if LongShort =="Both" and AboveBelow == "Don't Include"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit))
    strategy.close("SHORT", when = close<sma(close,ShortExit))