El RSI y la estrategia de ruptura de la media móvil

El autor:¿ Qué pasa?, Fecha: 2024-01-24 14:31:01
Las etiquetas:

img

Resumen general

La RSI y la estrategia de ruptura de promedios móviles es una estrategia cuantitativa que utiliza tanto el indicador RSI como las líneas de promedio móvil para determinar oportunidades comerciales.

Estrategia lógica

  1. Calcular el indicador RSI y las líneas de promedio móvil simple basándose en parámetros definidos por el usuario.

  2. Cuando el RSI cruza por encima de la línea de sobreventa (default 30), se genera una señal larga si el precio está por debajo de la media móvil de salida LONG.

  3. Cuando el RSI cruza por debajo de la línea de sobrecompra (default 70), se genera una señal corta si el precio está por encima de la media móvil de salida corta.

  4. Los usuarios pueden elegir filtrar señales basadas en una línea de tendencia de promedio móvil.

  5. Las salidas se determinan por las líneas de media móvil de salida LONG y SHORT.

Análisis de ventajas

  1. El diseño de dos indicadores mejora la precisión al incorporar dos factores principales del mercado.

  2. Utiliza la característica de la inversión media del RSI de manera efectiva para localizar los puntos de inflexión.

  3. El filtro adicional con promedios móviles aumenta el rigor lógico para evitar perseguir los tops y los bottoms.

  4. Los parámetros personalizables permiten optimizaciones en diferentes productos y plazos.

  5. La lógica simple hace que sea fácil de entender y modificar.

Análisis de riesgos

  1. Los whipssaws son comunes con RSI, el indicador de densidad podría ayudar.

  2. El RSI tiende a fallar en períodos de tiempo más largos, los parámetros se pueden ajustar o pueden ayudar indicadores adicionales.

  3. Los promedios móviles tienen un efecto de retraso, las longitudes podrían acortarse o indicadores como el MACD pueden ayudar.

  4. Deben introducirse más indicadores para validar las señales debido a la lógica básica.

Direcciones de optimización

  1. Optimizar los parámetros del RSI o introducir el indicador de densidad para reducir las señales falsas.

  2. Incorporar indicadores de tendencia y volatilidad como DMI y BOLL para localizar tendencias y soportes.

  3. Introducir el MACD para reemplazar o complementar los juicios de la media móvil.

  4. Añadir más condiciones lógicas en las señales de entrada para evitar breakouts desfavorables.

Conclusión

La RSI y la estrategia de ruptura de promedios móviles combinan la detección de sobrecompra sobreventa de RSI y la determinación de tendencias de promedios móviles para capitalizar las oportunidades de inversión de la media teóricamente. La estrategia es intuitiva y fácil de usar para principiantes, y se puede optimizar en diferentes productos, por lo que es una estrategia cuantitativa inicial recomendada. Se podrían introducir más indicadores auxiliares para validar aún más las señales y mejorar la rentabilidad.


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





Más.