
この戦略は,相対的強弱指数 (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")