RSI et stratégie de rupture des moyennes mobiles

Auteur:ChaoZhang est là., Date: 2024-01-24 14:31:01 Je vous en prie.
Les étiquettes:

img

Résumé

L'indicateur RSI et la stratégie de rupture des moyennes mobiles est une stratégie quantitative qui utilise à la fois l'indicateur RSI et les lignes moyennes mobiles pour déterminer les opportunités de trading.

La logique de la stratégie

  1. Calculer l'indicateur RSI et les lignes de moyenne mobile simple sur la base de paramètres définis par l'utilisateur.

  2. Lorsque le RSI franchit la ligne de survente (par défaut 30), un signal long est généré si le prix est inférieur à la moyenne mobile de sortie LONG.

  3. Lorsque le RSI traverse en dessous de la ligne de surachat (défaut 70), un signal court est généré si le prix est supérieur à la moyenne mobile de sortie SHORT.

  4. Les utilisateurs peuvent choisir de filtrer les signaux en fonction d'une ligne de moyenne mobile de tendance.

  5. Les sorties sont déterminées par les lignes de sortie LONG et SHORT Moving Average.

Analyse des avantages

  1. La conception à double indicateur améliore la précision en intégrant deux facteurs majeurs du marché.

  2. Utilise efficacement la caractéristique d'inversion moyenne du RSI pour localiser les points tournants.

  3. Un filtre supplémentaire avec des moyennes mobiles augmente la rigueur logique pour éviter de poursuivre les sommets et les bas.

  4. Les paramètres personnalisables permettent des optimisations sur différents produits et délais.

  5. La logique simple le rend facile à comprendre et à modifier.

Analyse des risques

  1. Les fouets sont fréquents avec le RSI, l'indicateur de densité pourrait aider.

  2. L'indicateur RSI a tendance à échouer sur des délais plus longs, les paramètres peuvent être ajustés ou des indicateurs supplémentaires peuvent aider.

  3. Les moyennes mobiles ont un effet de retard, les longueurs peuvent être raccourcies ou des indicateurs comme le MACD peuvent aider.

  4. Il convient d'introduire davantage d'indicateurs pour valider les signaux en raison de la logique de base.

Directions d'optimisation

  1. Optimiser les paramètres RSI ou introduire un indicateur de densité pour réduire les faux signaux.

  2. Incorporer des indicateurs de tendance et de volatilité tels que DMI et BOLL pour localiser les tendances et les soutiens.

  3. Introduire le MACD pour remplacer ou compléter les jugements de la moyenne mobile.

  4. Ajouter plus de conditions logiques sur les signaux d'entrée pour éviter les évasions défavorables.

Conclusion

La stratégie de rupture de l'indice de volatilité et de la moyenne mobile combine la détection de la survente de l'indice de volatilité et la détermination de la tendance des moyennes mobiles pour capitaliser sur les opportunités d'inversion de la moyenne théoriquement.


/*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))
    
    
    
    
    
    
   





Plus de