
이 전략은 상대적으로 강하고 약한 지수 (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")