RSI 지표를 기반으로 한 트렌드 풀백 트레이딩 전략


생성 날짜: 2023-09-13 15:33:26 마지막으로 수정됨: 2023-09-13 15:33:26
복사: 0 클릭수: 686
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이 전략은 RSI 지표에 기반한 트렌드 리버스 트레이딩 전략이라고 합니다. 이 전략은 RSI 지표를 사용하여 오버 바이 오버 소드를 판단하고, 최적화 매개 변수 설정과 함께 트렌드 리버스 트레이딩을 수행하여 강력한 트렌드에서 지역 리버스를 포착하는 것을 목표로합니다.

RSI 지표는 가격이 과매매되거나 과매매되는지 판단한다. RSI 70 이상은 과매매를 의미하고, 30 이하는 과매매를 의미한다. 이 전략은 RSI가 96에 도달하면 판매 신호를 발생시키고, RSI가 4로 떨어지면 구매 신호를 발생시킨다. 이러한 파라미터는 최적화 된 설정으로, 전통적인 RSI 파라미터보다 강력한 추세에서 일시적인 반전을 포착하는 데 더 적합하다.

진입 후, 전략은 중지 중지 손실 메커니즘을 사용합니다. 반전 후 RSI가 80으로 올라갈 때 더 많은 주문을 중지하고, RSI가 20으로 내려갈 때 공백을 중지하고, 반발 수익을 효과적으로 잠금합니다. 또한, 진입 후 우선 보증금을 보장하기 위해 추적 중지 손실을 사용합니다.

이 전략의 장점은 RSI 지표의 민감한 judgementesult를 사용하여 트렌드에서 임시 반전과 회전을 캡처하고, 변수 최적화 및 스톱 스톱으로 전략 효과를 향상시키는 데 있습니다. 그러나 어떤 단일 지표도 완벽하지 않으며, 트렌드 및 지지 저항 분석과 함께 사용해야합니다.

일반적으로 RSI 지표는 단순하고 실용적인 과매매 판단 도구입니다. 변수 최적화와 엄격한 위험 관리를 통해 트렌드 회귀 거래의 효과를 높일 수 있습니다. 그러나 거래자는 전략 조정의 유연성을 유지해야하며 다른 시장에는 다른 변수 설정이 필요합니다.

전략 소스 코드
/*backtest
start: 2023-08-13 00:00:00
end: 2023-09-12 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © corderomoraj


//@version=5
strategy("Good Mode RSI v2", overlay=true)

// Parámetros de la estrategia
rsiPeriod = input(2, "RSI Period")
sellLevel = input(96, "Sell Level")
buyLevel = input(4, "Buy Level")
takeProfitLevelSell = input(20, "Take Profit Level Sell")
takeProfitLevelBuy = input(80, "Take Profit Level Buy")
var float trailingStopPrice = na
var float trailingStopOffset = input(100, "Trailing Stop Offset (pips)")

// Capital inicial
initialCapital = 250
positionSize = initialCapital * 0.015

// Condiciones de entrada y salida
rsi = ta.rsi(close, rsiPeriod)

// Condiciones de entrada y salida para la orden de venta
sellCondition = rsi > sellLevel
closeSellCondition = rsi < takeProfitLevelSell

// Condiciones de entrada y salida para la orden de compra
buyCondition = rsi < buyLevel
closeBuyCondition = rsi > takeProfitLevelBuy

// Trailing Stop para las posiciones de venta
if strategy.position_size < 0
    if low < trailingStopPrice
        trailingStopPrice := low
    strategy.exit("Sell", "Sell", trail_offset = trailingStopOffset * syminfo.mintick, trail_price = trailingStopPrice)

// Trailing Stop para las posiciones de compra
if strategy.position_size > 0
    if high > trailingStopPrice
        trailingStopPrice := high
    strategy.exit("Buy", "Buy", trail_offset = trailingStopOffset * syminfo.mintick, trail_price = trailingStopPrice)

// Ejecutar orden de venta
if (sellCondition)
    strategy.entry("Sell", strategy.short, qty = positionSize)
    trailingStopPrice := high

// Cerrar orden de venta
if (closeSellCondition)
    strategy.close("Sell")

// Ejecutar orden de compra
if (buyCondition)
    strategy.entry("Buy", strategy.long, qty = positionSize)
    trailingStopPrice := low

// Cerrar orden de compra
if (closeBuyCondition)
    strategy.close("Buy")