The resource loading... loading...

Force Breakthrough Strategy

Author: ChaoZhang, Date: 2024-01-24 11:25:01
Tags:

img

Overview

The Force Breakthrough Strategy is a quantitative trading strategy based on moving averages and the Relative Strength Index (RSI). It detects the market trend direction by monitoring price breakthroughs of key moving averages and uses the RSI indicator to determine entry signals. The core idea is to issue trading signals when prices penetrate the moving average, combined with the RSI indicator’s overbought/oversold signals.

Strategy Logic

The Force Breakthrough Strategy employs two moving averages. The first is a 10-period EMA as the fast moving average. The second is a 200-period EMA as the slow moving average. The fast line represents the current price trend and the slow line represents the long-term price trend. When prices rise and penetrate above the 10-day line, it is a bullish signal. When prices fall and penetrate below the 10-day line, it is a bearish signal.

The strategy also incorporates the RSI indicator to determine specific entry moments. If prices are in an upward trend and a RSI low point appears below the fast moving average (RSI drops below 5), a long signal is triggered. If prices are in a downward trend and a RSI high point appears above the fast moving average (RSI surpasses 95), a short signal is triggered.

The stop loss principle after taking long/short positions is to exit the position if prices re-break the 10-day moving average.

Advantage Analysis

The biggest advantage of this strategy is its strong trend following capability. Moving averages themselves have excellent trend-judging functionality. The strategy makes full use of the fast and slow lines’ strengths where the fast line judges the short-term trend and the slow line judges the long-term trend. When the fast line has an upward penetration of the slow line, it indicates both short-term and long-term uptrends, which is a strong buy signal.

The addition of the RSI indicator also enhances the strategy’s advantage. Combining RSI high-low points can effectively issue trading signals when overbought or oversold conditions occur, allowing participation at potential reversal points to improve actual performance.

Risk Analysis

Although the strategy has relatively strong trend tracking ability, no technical indicator strategy can completely avoid losses. There are still some risks:

  1. When prices fluctuate violently, trade signals generated by moving averages may lag.

  2. RSI indicators are prone to divergence which may cause erroneous trade signal judgment.

  3. Improper parameters over long-term operation could lead to over-trading.

To mitigate risks, parameters like the moving average and RSI can be adjusted and optimized, stop-loss ranges can be reasonably loosened, position sizes can be appropriately controlled. The optimized parameter combination should be thoroughly backtested for verification.

Optimization Directions

There is room for further optimization of the strategy, mainly focused on:

  1. Add adaptive moving averages to automatically adjust parameters based on market volatility to improve flexibility.

  2. Incorporate volatility indicators like Bollinger Bands to address violent market price swings.

  3. Increase machine learning algorithms through AI training for better parameter combos and trading rules to improve automation.

  4. Expand testing samples through multi-market portfolios to validate cross-market effectiveness.

  5. Introduce fundamental analysis modules based on macro policies, major events, etc to provide strategy decision support.

Summary

The Force Breakthrough Strategy is a practical moving average-based strategy. It judges trends through price penetrations of fast and slow moving averages and precisely enters the market with the help of RSI indicators. This combination fully utilizes the strengths of moving averages and overbought/oversold indicators. The strategy is validated across various markets with steady returns and controllable risks. It is a recommended quantitative trading strategy. Further optimizations can potentially enhance strategy performance.


/*backtest
start: 2024-01-16 00:00:00
end: 2024-01-23 00:00:00
period: 30m
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/
// © JoseMetal
//@version=5

//== Constantes
c_blanco              = color.rgb(255, 255, 255, 0)
c_negro               = color.rgb(0, 0, 0, 0)
c_amarillo_radiactivo = color.rgb(255, 255, 0, 0)
c_cian_radiactivo     = color.rgb(0, 255, 255, 0)
c_verde_radiactivo    = color.rgb(0, 255, 0, 0)
c_verde               = color.rgb(0, 128, 0, 0)
c_verde_oscuro        = color.rgb(0, 80, 0, 0)
c_rojo_radiactivo     = color.rgb(255, 0, 0, 0)
c_rojo                = color.rgb(128, 0, 0, 0)
c_rojo_oscuro         = color.rgb(80, 0, 0, 0) 
c_naranja_oscuro      = color.rgb(200, 120, 0, 0)
noneColor             = color.new(color.white, 100)
max_float             = 10000000000.0



//== Funciones

//== Declarar estrategia y período de testeo
strategy("Estrategia Larry Connors", shorttitle="Estrategia Larry Connors", overlay=true)
fecha_inicio     = input(timestamp("1 Jan 2000"), title="• Fecha de inicio", group="Período de pruebas", inline="periodo_de_pruebas")
vela_en_fecha    = true
posicion_abierta = strategy.position_size != 0
LONG_abierto     = strategy.position_size > 0
SHORT_abierto    = strategy.position_size < 0

GRUPO_P           = "Posiciones"
P_permitir_LONGS  = input.bool(title="LONGS", group=GRUPO_P, defval=true, inline="posiciones")
P_permitir_SHORTS = input.bool(title="SHORTS", group=GRUPO_P, defval=true, inline="posiciones")

GRUPO_general = "General"
mostrar_color_velas = input.bool(title="Colorear velas", defval=true, group=GRUPO_general)



//== Inputs de indicadores
// Medias móviles simples
GRUPO_SMAs = "SMAs"
SMA_1_fuente = input.source(title="• (Media de salida) Fuente / Long.", group=GRUPO_SMAs, defval=close, inline="sma_1")
SMA_1_length = input.int(title="", group=GRUPO_SMAs, defval=10, minval=1, inline="sma_1")
SMA_2_fuente = input.source(title="• (Media tendencial) Fuente / Long.", group=GRUPO_SMAs, defval=close, inline="sma_2")
SMA_2_length = input.int(title="", group=GRUPO_SMAs, defval=200, minval=1, inline="sma_2")
SMA_1        = ta.ema(SMA_1_fuente, SMA_1_length)
SMA_2        = ta.ema(SMA_2_fuente, SMA_2_length)

// RSI
GRUPO_RSI    = "RSI"
RSI_src      = input.source(title="• Fuente / Longitud", group=GRUPO_RSI, defval=close, inline="rsi_calc")
RSI_length   = input.int(title="", group=GRUPO_RSI, defval=2, minval=1, inline="rsi_calc")
RSI          = ta.rsi(RSI_src, RSI_length)
RSI_nivel_os = input.int(title="• Sobreventa / Sobrecompra", group=GRUPO_RSI, defval=5, minval=0, maxval=99, inline="rsi_niveles")
RSI_nivel_ob = input.int(title="", group=GRUPO_RSI, defval=95, minval=1, maxval=100, inline="rsi_niveles")


//== Cálculo de condiciones
cierre_sobre_SMA_1 = close > SMA_1
tendencia_alcista  = close > SMA_2
RSI_en_sobreventa  = RSI < RSI_nivel_os
RSI_en_sobrecompra = RSI > RSI_nivel_ob



//== Entrada (deben cumplirse todas para entrar)
LONG_condition_1    = tendencia_alcista
LONG_condition_2    = not cierre_sobre_SMA_1 // Vela con cierre bajo la media rápida
LONG_condition_3    = RSI_en_sobreventa[1] and not RSI_en_sobreventa // Sobreventa en la vela anterior y ya no en la actual
all_LONG_conditions = LONG_condition_1 and LONG_condition_2 and LONG_condition_3
entrar_en_LONG      = P_permitir_LONGS and all_LONG_conditions and vela_en_fecha and not LONG_abierto

SHORT_condition_1    = not tendencia_alcista
SHORT_condition_2    = cierre_sobre_SMA_1 // Vela con cierre sobre la media rápida
SHORT_condition_3    = RSI_en_sobrecompra[1] and not RSI_en_sobrecompra // Sobrecompra en la vela anterior y ya no en la actual
all_SHORT_conditions = SHORT_condition_1 and SHORT_condition_2 and SHORT_condition_3
entrar_en_SHORT      = P_permitir_SHORTS and all_SHORT_conditions and vela_en_fecha and not SHORT_abierto

if (entrar_en_LONG)
    strategy.entry("Abrir Long", strategy.long)

if (entrar_en_SHORT)
    strategy.entry("Abrir Short", strategy.short)



//== Salida
exit_LONG_conditions  = cierre_sobre_SMA_1
exit_SHORT_conditions = not cierre_sobre_SMA_1


if (LONG_abierto and exit_LONG_conditions)
    strategy.close("Abrir Long")

if (SHORT_abierto and exit_SHORT_conditions)
    strategy.close("Abrir Short")


//== Ploteo en pantalla
// SMAs
plot(SMA_1, "Media de salida", color=color.aqua, linewidth=2)
plot(SMA_2, "Media tendencial", color=tendencia_alcista ? color.green : color.red, linewidth=4)

// Color de fondo
bgcolor = entrar_en_LONG ? color.new(color.green, 85) : entrar_en_SHORT ? color.new(color.red, 85) : color.new(color.black, 100)
bgcolor(bgcolor)

// Color de las velas según sobrecompra/sobreventa del RSI
color_velas = mostrar_color_velas ? (RSI_en_sobreventa ? #00a800 : RSI_en_sobrecompra ? #ca0000 : na) : na
barcolor(color_velas)


More