该策略利用相对强弱指数(RSI)来判断市场的超卖状态,当RSI低于设定的超卖阈值时产生买入信号,同时设置止损(Stop Loss)和止盈(Take Profit)来控制风险和锁定利润。该策略只做多,不做空。
该策略通过RSI指标来捕捉市场的超卖反转机会,同时设置了固定的止损止盈来控制风险。策略逻辑简单清晰,适合新手使用。但是该策略也存在一定的局限性,如对趋势把握能力较弱,信号可靠性有待提高等。因此,在实际应用中,可以考虑从趋势判断、止损止盈优化、指标组合等方面对策略进行优化和改进,以获得更稳健的交易表现。
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Estratégia com RSI (Apenas Compras)", overlay=true)
// Parâmetros de entrada
rsiLength = input.int(14, title="Período do RSI")
oversold = input.int(30, title="Nível de Sobrevenda (RSI)")
stopLossPercent = input.float(2.0, title="Stop Loss (%)")
takeProfitPercent = input.float(5.0, title="Take Profit (%)")
// Cálculo do RSI
rsi = ta.rsi(close, rsiLength)
// Sinal de Compra
buySignal = ta.crossover(rsi, oversold)
// Plotando o sinal de compra
plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, title="Compra", text="Buy")
// Variáveis para Stop Loss e Take Profit
var float longStop = na
var float longTake = na
// Entrando na posição de compra
if (buySignal)
entryPrice = close
longStop := entryPrice * (1 - stopLossPercent / 100)
longTake := entryPrice * (1 + takeProfitPercent / 100)
strategy.entry("Compra", strategy.long)
label.new(x=bar_index, y=low, text="Compra", style=label.style_label_up, color=color.green)
// Gerenciamento de Stop Loss e Take Profit
if (strategy.position_size > 0)
if (close <= longStop)
strategy.close("Compra", comment="Stop Loss")
label.new(x=bar_index, y=low, text="Stop Loss", style=label.style_label_down, color=color.red)
if (close >= longTake)
strategy.close("Compra", comment="Take Profit")
label.new(x=bar_index, y=high, text="Take Profit", style=label.style_label_up, color=color.green)
// Plotando as linhas de Stop Loss e Take Profit
plot(longStop, color=color.red, linewidth=1, title="Stop Loss Long")
plot(longTake, color=color.green, linewidth=1, title="Take Profit Long")