
A estratégia combina dois indicadores técnicos, o RSI e o Supertrend, para capturar tendências de mercado e identificar potenciais oportunidades de negociação. A principal idéia da estratégia é usar o RSI para julgar o estado de sobrecompra e sobrevenda do mercado, enquanto o indicador Supertrend é usado para confirmar a direção da tendência. A estratégia gera um sinal de compra ou venda quando os indicadores RSI e Supertrend atendem simultaneamente a determinadas condições.
A estratégia de negociação de RSI + Supertrend para acompanhamento de tendências pode efetivamente capturar as tendências do mercado e gerar sinais de negociação através da combinação de dois indicadores técnicos, RSI e Supertrend. A vantagem da estratégia é a clareza lógica, a facilidade de implementação, além de considerar a dinâmica e os fatores de tendência. No entanto, a estratégia também possui alguns riscos, como a frequência de negociação e as limitações da configuração de parâmetros.
/*backtest
start: 2024-05-21 00:00:00
end: 2024-05-28 00:00:00
period: 45m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI + Supertrend Strategy", overlay=true)
// Input parameters
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(58, title="RSI Overbought Level")
rsiOversold = input.int(38, title="RSI Oversold Level")
supertrendLength = input.int(10, title="Supertrend Length")
supertrendMultiplier = input.int(3, title="Supertrend Multiplier")
// Calculate indicators
rsiValue = ta.rsi(close, rsiLength)
[supertrend, _] = ta.supertrend(supertrendLength, supertrendMultiplier)
// Plot Supertrend on main chart
plot(supertrend, color = supertrend < close ? color.green : color.red, linewidth = 2, title="Supertrend")
// Plot RSI
hline(rsiOverbought, "Overbought", color.red)
hline(rsiOversold, "Oversold", color.green)
plot(rsiValue, title="RSI", color=color.blue)
// Strategy
var float entryPrice = na
// Long conditions
longCondition = (rsiValue > rsiOverbought) and (supertrend < close)
// Short conditions
shortCondition = (rsiValue < rsiOversold) and (supertrend > close)
// Exit conditions
longExitCondition = (rsiValue < 50) and (supertrend > close)
shortExitCondition = (rsiValue > 45) and (supertrend < close)
// Execute strategy
if (longCondition)
strategy.entry("Long", strategy.long)
entryPrice := close
if (shortCondition)
strategy.entry("Short", strategy.short)
entryPrice := close
if (longExitCondition and strategy.position_size > 0)
strategy.close("Long")
if (shortExitCondition and strategy.position_size < 0)
strategy.close("Short")
// Date and time range for backtest
startDate = timestamp("2023-01-01 00:00")
endDate = timestamp("2024-01-01 00:00")
if (time < startDate or time > endDate)
strategy.close_all()