La robusta estrategia de negociación de promedios móviles dobles combina el poder de los indicadores de índice de fuerza relativa (RSI) y tasa de cambio (ROC) para identificar la dirección de las tendencias a medio y largo plazo.
Esta estrategia utiliza una combinación de indicadores RSI y ROC para determinar las señales de entrada. Cuando los precios se acercan a las áreas de sobrecompra / sobreventa, indica puntos de reversión potenciales y la formación de señales de reversión. Cuando los precios oscilan dentro de estas áreas, sugiere que la tendencia actual puede persistir durante algún tiempo. El indicador ROC juzga la tendencia y el impulso de los precios desde la perspectiva de la tasa de cambio.
Además, la estrategia incorpora filtros de tendencia a medio y largo plazo (SMA) y líneas de stop loss a corto plazo antes de entrar en cualquier operación. Esto asegura que las entradas solo ocurran en la dirección de la tendencia confirmada y sin riesgos de stop loss inminentes en mercados oscilantes.
Los ajustes de entrada flexibles también permiten a los operadores elegir entre solo RSI, solo ROC o una combinación de ambos como activador de entrada.
La mayor ventaja de esta estrategia radica en la combinación de señales de tendencia y de reversión para las decisiones de entrada, teniendo en cuenta tanto la tendencia como los factores estructurales para garantizar un tiempo preciso.
Otra ventaja son los filtros de tendencia incorporados (SMA) y el stop loss a corto plazo, que reducen la probabilidad de quedar atrapados en mercados oscilantes.
Por último, las combinaciones de configuración de múltiples parámetros permiten a los operadores optimizar la estrategia para diferentes productos y entornos de mercado.
El mayor riesgo de la estrategia proviene de la naturaleza rezagada de los indicadores de señal de inversión como RSI y ROC. Cuando las tendencias comienzan a cambiar, estos indicadores a menudo se quedan atrás antes de alcanzar los niveles de umbral establecidos en los parámetros.
Otro riesgo potencial es que en los mercados oscilantes, las configuraciones de los parámetros RSI y ROC pueden volverse demasiado sensibles y generar ciertas señales falsas.
La estrategia se puede optimizar en los siguientes aspectos:
Incorporar más indicadores para el uso combinado como KDJ, MACD para mejorar la precisión de la señal con evaluaciones multidimensionales de la estructura del mercado
Introducir mecanismos de optimización adaptativa en los parámetros RSI y ROC para que los ajustes puedan ajustarse dinámicamente en función de la volatilidad en tiempo real
Refinar la lógica de entrada agregando mecanismos de confirmación cuando las herramientas de tendencia y las herramientas de reversión cumplen simultáneamente con las condiciones, evitando actuar sobre señales falsas en las oscilaciones
Ampliar el rango de pérdida de parada o establecer una pérdida de parada posterior para proporcionar más espacio para las reversiones, reduciendo las ganancias perdidas debido a la agrupación de pérdidas de parada
La robusta estrategia de trading de media móvil doble combina con éxito el diagnóstico de tendencias y los indicadores de reversión para capturar oportunidades estructurales tras la confirmación de tendencias a medio y largo plazo.
/*backtest start: 2024-01-05 00:00:00 end: 2024-02-04 00:00:00 period: 1h 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/ // © GlobalMarketSignals //@version=4 strategy("GMS: RSI & ROC Strategy", overlay=true) LongShort = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"]) RSIroc = input(title="RSI Only, ROC Only, Both?", type=input.string, defval="Both", options=["Both", "RSI Only", "ROC Only"]) RSILength = input(title="RSI Length", type = input.integer ,defval=14) RSIUpper = input(title="RSI Upper Threshold", type = input.float ,defval=70) RSILower = input(title="RSI Lower Threshold", type = input.float ,defval=30) ROCLength = input(title="ROC Length", type = input.integer ,defval=14) ROCUpper = input(title="ROC Upper Threshold", type = input.float ,defval=0.01) ROCLower = input(title="ROC Lower Threshold", type = input.float ,defval=-0.01) 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) //RSI ONLY //Long Side if LongShort =="Long Only" and AboveBelow == "Above" and RSIroc == "RSI Only" 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" and RSIroc == "RSI Only" 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" and RSIroc == "RSI Only" 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" and RSIroc == "RSI Only" 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" and RSIroc == "RSI Only" 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" and RSIroc == "RSI Only" strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit)) strategy.close("LONG", when = close>sma(close,LongExit)) //RSI ONLY //SHORT SIDE if LongShort =="Short Only" and AboveBelow == "Above" and RSIroc == "RSI Only" 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" and RSIroc == "RSI Only" 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" and RSIroc == "RSI Only" 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" and RSIroc == "RSI Only" 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" and RSIroc == "RSI Only" 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" and RSIroc == "RSI Only" strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit)) strategy.close("SHORT", when = close<sma(close,ShortExit)) ///////-----------------///////////// ///////-----------------///////////// ///////-----------------///////////// //ROC ONLY //Long Side if LongShort =="Long Only" and AboveBelow == "Above" and RSIroc == "ROC Only" strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower 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" and RSIroc == "ROC Only" strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower 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" and RSIroc == "ROC Only" strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit)) strategy.close("LONG", when = close>sma(close,LongExit)) if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "ROC Only" strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close>sma(close,TrendLength)) strategy.close("LONG", when = close>sma(close,LongExit)) if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "ROC Only" strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower 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" and RSIroc == "ROC Only" strategy.entry("LONG", true, when = rsi(close,ROCLength)<ROCLower and close< sma(close,LongExit)) strategy.close("LONG", when = close>sma(close,LongExit)) //ROC ONLY //SHORT SIDE if LongShort =="Short Only" and AboveBelow == "Above" and RSIroc == "ROC Only" strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper 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" and RSIroc == "ROC Only" strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper 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" and RSIroc == "ROC Only" strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit)) strategy.close("SHORT", when = close<sma(close,ShortExit)) if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "ROC Only" strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength)) strategy.close("SHORT", when = close<sma(close,ShortExit)) if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "ROC Only" strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper 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" and RSIroc == "ROC Only" strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit)) strategy.close("SHORT", when = close<sma(close,ShortExit)) ///////-----------------///////////// ///////-----------------///////////// ///////-----------------///////////// //BOTH //Long Side if LongShort =="Long Only" and AboveBelow == "Above" and RSIroc == "Both" strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower 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" and RSIroc == "Both" strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower 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" and RSIroc == "Both" strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit)) strategy.close("LONG", when = close>sma(close,LongExit)) if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "Both" strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close>sma(close,TrendLength)) strategy.close("LONG", when = close>sma(close,LongExit)) if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "Both" strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower 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" and RSIroc == "Both" strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit)) strategy.close("LONG", when = close>sma(close,LongExit)) //BOTH //SHORT SIDE if LongShort =="Short Only" and AboveBelow == "Above" and RSIroc == "Both" strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper 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" and RSIroc == "Both" strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper 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" and RSIroc == "Both" strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit)) strategy.close("SHORT", when = close<sma(close,ShortExit)) if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "Both" strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength)) strategy.close("SHORT", when = close<sma(close,ShortExit)) if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "Both" strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper 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" and RSIroc == "Both" strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit)) strategy.close("SHORT", when = close<sma(close,ShortExit))