Las operaciones de inversión en el sector de la inversión se clasifican en el grupo de operaciones de inversión.

El autor:¿ Qué pasa?, Fecha: 2024-02-18 16:13:50
Las etiquetas:

img

Resumen general

Esta estrategia de negociación combina el índice de fuerza relativa (RSI) y los indicadores técnicos de fuerza relativa estocástica (RSI) para generar señales comerciales.

Nombre de la estrategia

Las operaciones de inversión en el sector de la inversión se clasifican en el grupo de operaciones de inversión.

Estrategia lógica

La estrategia juzga las condiciones de sobrecompra y sobreventa basadas en los valores del RSI. RSI por debajo de 30 se considera una señal de sobreventa y RSI por encima de 70 se considera una señal de sobrecompra. El indicador RSI estocástico observa la fluctuación de los valores del RSI. RSI estocástico por debajo de 5 es sobreventa y RSI estocástico por encima de 50 es sobrecompra.

La estrategia también incorpora la tendencia del precio de la criptomoneda en marcos de tiempo más altos (por ejemplo, semanal). Solo cuando el RSI de marcos de tiempo más altos está por encima de un umbral (por ejemplo, 45), se activan señales largas. Esto filtra las señales de sobreventa no persistentes cuando la tendencia general es baja.

Las señales de compra y venta deben confirmarse durante varios períodos (por ejemplo, 8 barras) antes de que se genere una señal de negociación real para evitar señales falsas.

Ventajas

  • Método clásico de análisis técnico que utiliza el RSI para identificar los niveles de sobrecompra/sobreventa
  • Incorpora el RSI estocástico para detectar las reversiones del RSI
  • Aplica técnicas de marcos de tiempo múltiples para filtrar señales falsas y mejorar la calidad

Riesgos y soluciones

  • RSI propenso a generar señales falsas
    • Combinar otros indicadores para filtrar señales falsas
    • Aplicar técnicas de confirmación de tendencias
  • La configuración incorrecta del umbral puede producir demasiadas señales
    • Optimice los parámetros para encontrar la mejor combinación
  • Las señales necesitan tiempo de confirmación
    • Periodos de confirmación del saldo - filtrar las señales falsas sin perder oportunidades

Áreas de mejora

  • Prueba más combinaciones de indicadores para señales más fuertes
    • Por ejemplo, incorporar el indicador MACD
  • Utilice métodos de aprendizaje automático para encontrar parámetros óptimos
    • Por ejemplo, algoritmos genéticos/algoritmos evolutivos para la optimización automatizada
  • Añadir estrategias de stop loss para controlar los riesgos de una sola operación
    • Establecer un stop loss cuando el precio rompe el nivel de soporte

Conclusión

La estrategia se basa principalmente en los dos indicadores técnicos clásicos, RSI y RSI estocástico, para generar señales comerciales. Además, la introducción de la confirmación de tendencia desde marcos de tiempo más altos ayuda a filtrar las señales falsas de manera efectiva y mejora la calidad de la señal. Se puede lograr una mejora adicional del rendimiento optimizando parámetros, agregando stop loss y otros medios. La lógica es simple y fácil de entender. Sirve como un buen punto de partida para el comercio cuantitativo.


/*backtest
start: 2023-02-11 00:00:00
end: 2024-02-17 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("RSI and Stochatic Strategy", overlay=true, use_bar_magnifier = false)


/////// Inputs ///////////////

// RSI and SRSI
rsiLength = input(14, title="RSI Length") 
stochLength = input(14, title="Stochastic Length")
kSmooth = input(3, title="K Smooth")
dSmooth = input(3, title="D Smooth")


//////// thresholds ///////////////
st_low = input(5, title="Low SRSI") // stochastic RSI low -- prepare to sell
st_hi = input(50, title="High SRSI") // stochastic RSI high -- prepare to buy
diff = input(5, title="difference") // minimum change in RSI
// inval_diff = input(12, title="difference") // invalidation difference: change in the oposite direction that invalidates rsi falling/rising
rsi_low = input(30, title="Low RSI") // RSI considered low
rsi_hi = input(60, title="High RSI") // RSI considered high
rsi_ht_hi = input(45, title="High higher time frame RSI") // RSI in higher time frame considered high


/// buy trigger duration 
tr_dur = input(8, title="Trigger duration")
low_dur = input(20, title="Monitoring last low")


///////////////// Higher time frame trend ///////////////////
// higher time frame resolution
res2 = input.timeframe("W", title="Higher time-frame")
// Input for the ticker symbol, default is an empty string
// For instance we could monitor BTC higher time frame trend
symbol = input("BTC_USDT:swap", "Input Ticker (leave empty for current)")

// Determine the symbol to use
inputSymbol = symbol == "" ? syminfo.tickerid : symbol
//////////////////////////////////////////////////////////

// Calculate RSI //
rsi = ta.rsi(close, rsiLength)

// Calculate Stochastic RSI //
rsiLowest = ta.lowest(rsi, stochLength)
rsiHighest = ta.highest(rsi, stochLength)
stochRsi = 100 * (rsi - rsiLowest) / (rsiHighest - rsiLowest)

// Apply smoothing
K = ta.sma(stochRsi, kSmooth)
D = ta.sma(K, dSmooth)

// Higher time Frame RSI
cl2 = request.security(inputSymbol, res2, close)
rsi2 = ta.rsi(cl2, 14)

// SRSI BUY/SELL signals 
sell_stoch = (ta.lowest(K, tr_dur) < st_low) or (ta.highest(rsi, tr_dur) < rsi_low)
buy_stoch = ((ta.lowest(K, tr_dur) > st_hi) or (ta.lowest(rsi, tr_dur) > rsi_hi)) and (rsi2 > rsi_ht_hi)

 // valitation / invalidation sell signal
ll = ta.barssince(not sell_stoch)+1
sell_validation = (ta.highest(rsi, ll)>rsi[ll]+diff and rsi < rsi[ll]) or (rsi < rsi[ll]-diff)

// valitation / invalidation buy signal
llb = ta.barssince(not buy_stoch)+1
buy_validation = (ta.lowest(rsi, llb)<rsi[llb]-diff and rsi > rsi[llb]) or (rsi > rsi_hi and rsi - rsi[tr_dur] > 0)

sell_signal = sell_stoch and sell_validation
buy_signal = buy_stoch and buy_validation 

// Define the start date for the strategy
startYear = input(2019, "Start Year")
startMonth = input(1, "Start Month")
startDay = input(1, "Start Day")

// Convert the start date to Unix time
startTime = timestamp(startYear, startMonth, startDay, 00, 00)

// Define the end date for the strategy
endYear = input(2030, "End Year")
endMonth = input(1, "End Month")
endDay = input(1, "End Day")

// Convert the end date to Unix time
endTime = timestamp(endYear, endMonth, endDay, 00, 00)


if true
    if buy_signal
        strategy.entry("buy", strategy.long, comment = "Buy")
    if sell_signal
        strategy.close("buy", "Sell")

Más.