
A estratégia de ruptura do RSI é uma estratégia de negociação quantitativa baseada em indicadores de índices relativamente fracos (RSI). A estratégia gera um sinal de negociação quando o RSI quebra esses limites, ou seja, fazendo mais quando o RSI está abaixo de 30 e fazendo menos quando o RSI está acima de 70.
A ideia central da estratégia de ruptura do RSI é usar o indicador RSI para avaliar a tendência de sobrevenda e sobrevenda no mercado. O RSI reflete a tendência recente de forte e fraca, calculada pela relação entre a alta e a baixa média das ações em um período de tempo. Em geral, o RSI abaixo de 30 é considerado um excesso de venda e acima de 70 é considerado um excesso de compra.
A estratégia primeiro define a linha de sobrevenda e a linha de sobrevenda do RSI, assumindo 30 e 70. Em seguida, monitora o funcionamento da linha RSI em tempo real. Quando o RSI atravessa o limite de 70 de cima para baixo, gera um sinal de venda.
Desta forma, a estratégia tenta capturar os pontos de inflexão dos preços das ações durante a sua flutuação, ajustando a posição em tempo hábil quando ocorrem os fenômenos de sobrevenda e sobrecompra, para alcançar os pontos altos e baixos.
A estratégia de ruptura do RSI tem as seguintes vantagens:
Os sinais de operação são simples e claros. Os indicadores RSI são fáceis de calcular e entender, basta observar o limite superior e inferior do limiar definido para a ruptura de sua linha de indicadores.
A estratégia extrai o sinal de negociação do indicador RSI, sem necessidade de intervenção e julgamento humanos, para que a negociação seja facilmente automatizada. Ao mesmo tempo, o sinal de super-compra e super-venda do RSI é mais eficaz, e o retorno da estratégia também mostra ganhos significativos.
Flexível: os traders podem ajustar os parâmetros do RSI, como o valor de queda de um supermercado, para se adaptar às características de diferentes ações e mercados.
A estratégia de ruptura do RSI também apresenta alguns riscos, incluindo:
Quando os indicadores oscilam para cima ou para baixo, muitas vezes são acionados sinais de ruptura de negociação. Nesse momento, a estratégia pode produzir demasiadas negociações ineficazes, o que é prejudicial para obter ganhos estáveis.
Não pode julgar a tendência do mercado. O RSI apenas produz sinais de negociação de um estado de supercompra e supervenda, com fraca capacidade de julgar grandes tendências. A estratégia é fácil de ser presa em situações de turbulência. Pode ser filtrada em conjunto com indicadores de tendência, evitando negociações adversas.
O risco de retração é maior. O RSI frequentemente mostra um comportamento de desvio múltiplo, ou seja, o preço continua a subir e o indicador RSI desce.
A estratégia de ruptura do RSI pode ser otimizada a partir das seguintes dimensões:
Considere vários indicadores em conjunto, evitando as limitações de um único indicador RSI. Por exemplo, a combinação de indicadores de média móvel para determinar a tendência do mercado, ou o uso de indicadores fortes e fracos, indicadores de volume de transação para filtragem combinada de sinais de negociação.
Optimizar os parâmetros do RSI para aumentar a estabilidade da estratégia. Inclui ajustar o limiar de sobrecompra e venda, definir a duração do sinal de negociação, etc. Obter os melhores parâmetros por meio de testes e filtrar uma grande quantidade de sinais inválidos.
Defina condições de stop loss para controlar o risco, como por exemplo, definir um percentual ou ponto de stop loss. Evite que um único prejuízo tenha um impacto excessivo sobre o lucro total.
A estratégia de ruptura do RSI é uma estratégia de quantificação que utiliza o fenômeno de supercompra e supervenda para negociações de reversão. O sinal da estratégia é simples, claro e totalmente quantificado, mas também existe um certo risco de whipsaw e risco de retração.
/*backtest
start: 2023-11-21 00:00:00
end: 2023-12-21 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// @version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Bunghole 2021
strategy(title="My New Strategy", initial_capital = 100000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0, currency = 'USD', overlay=true)
//// Stoploss and Take Profit Parameters
// Enable Long Strategy
enable_long_strategy = input(true, title="Enable Long Strategy", group="SL/TP For Long Strategy",inline="1")
long_stoploss_value = input(defval=50, title='Stoploss %', type=input.float, minval=0.1, group="SL/TP For Long Strategy",inline="2")
long_stoploss_percentage = (close * (long_stoploss_value / 100)) / syminfo.mintick
long_takeprofit_value = input(defval=50, title='Take Profit %', type=input.float, minval=0.1, group="SL/TP For Long Strategy",inline="2")
long_takeprofit_percentage = (close * (long_takeprofit_value / 100)) / syminfo.mintick
// Enable Short Strategy
enable_short_strategy = input(true, title="Enable Short Strategy", group="SL/TP For Short Strategy",inline="3")
short_stoploss_value = input(defval=50, title='Stoploss %', type=input.float, minval=0.1, group= "SL/TP For Short Strategy",inline="4")
short_stoploss_percentage = (close * (short_stoploss_value / 100)) / syminfo.mintick
short_takeprofit_value = input(defval=50, title='Take Profit %', type=input.float, minval=0.1, group="SL/TP For Short Strategy",inline="4")
short_takeprofit_percentage = (close * (short_takeprofit_value / 100)) / syminfo.mintick
// Plot Stoploss & Take Profit Levels
long_stoploss_price = strategy.position_avg_price * (1 - long_stoploss_value/100)
long_takeprofit_price = strategy.position_avg_price * (1 + long_takeprofit_value/100)
short_stoploss_price = strategy.position_avg_price * (1 + short_stoploss_value/100)
short_takeprofit_price = strategy.position_avg_price * (1 - short_takeprofit_value/100)
plot(enable_long_strategy and not enable_short_strategy ? long_stoploss_price: na, color=#ff0000, style=plot.style_linebr, linewidth=2, title="Long SL Level")
plot(enable_long_strategy and not enable_short_strategy ? long_takeprofit_price: na, color=#008000, style=plot.style_linebr, linewidth=2, title="Long TP Level")
plot(enable_short_strategy and not enable_long_strategy ? short_stoploss_price: na, color=#ff0000, style=plot.style_linebr, linewidth=2, title="Short SL Level")
plot(enable_short_strategy and not enable_long_strategy ? short_takeprofit_price: na, color=#008000, style=plot.style_linebr, linewidth=2, title="Short TP Level")
// Date Range
start_date = input(title="Start Date", type=input.integer, defval=1, minval=1, maxval=31, group="Date Range")
start_month = input(title="Start Month", type=input.integer, defval=1, minval=1, maxval=12, group="Date Range")
start_year = input(title="Start Year", type=input.integer, defval=1804, minval=1800, maxval=3000, group="Date Range")
end_date = input(title="End Date", type=input.integer, defval=1, minval=1, maxval=3, group="Date Range")
end_month = input(title="End Month", type=input.integer, defval=1, minval=1, maxval=12, group="Date Range")
end_year = input(title="End Year", type=input.integer, defval=2077, minval=1800, maxval=3000, group="Date Range")
in_date_range = (time >= timestamp(syminfo.timezone, start_year, start_month, start_date, 0, 0)) and (time < timestamp(syminfo.timezone, end_year, end_month, end_date, 0, 0))
//// Inputs **This is where you enter your indicators for your strategy. For example, I added the RSI indicator.**
//RSI
rsi = rsi(close, 14)
rsi_over_sold = rsi < 30
rsi_over_bought = rsi > 70
//// Strategy **This is where you create your strategy. For example, We have or buy and sell signals.**
// Creating Long and Short Strategy
buy_signal = rsi_over_sold
sell_signal = rsi_over_bought
// Long Strategy
if buy_signal and in_date_range and enable_long_strategy == true
strategy.entry("Long", true, when=buy_signal, alert_message="Open Long Position")
strategy.exit("Long SL/TP", from_entry="Long", loss=long_stoploss_percentage, profit=long_takeprofit_percentage, alert_message="Your Long SL/TP Limit As Been Triggered.")
strategy.close("Long", when=sell_signal, alert_message="Close Long Position")
// Short Strategy
if sell_signal and in_date_range and enable_short_strategy == true
strategy.entry("Short", false, when = sell_signal, alert_message="Open Short Position")
strategy.exit("Short SL/TP", from_entry="Short", loss=short_stoploss_percentage, profit=short_takeprofit_percentage, alert_message="Your Short SL/TP Limit As Been Triggered.")
strategy.close("Short", when=buy_signal, alert_message="Close Short Position")