트렌드 리트레이싱 거래 전략

저자:차오장, 날짜: 2023-09-13 15:33:26
태그:

이 전략은 RSI 지표에 기반한 트렌드 리트레이싱 트레이딩 전략 (Trend Retracement Trading Strategy Based on RSI Indicator) 이라고 불립니다. 이는 RSI 지표를 사용하여 과잉 구매 / 과잉 판매 수준을 측정하고 최적화된 매개 변수 설정을 결합하여 견고한 트렌드 내에서 트레이드 풀백 및 로컬 역전을 잡습니다.

RSI 지표는 가격이 과소매 또는 과소매인지 판단합니다. RSI 70 이상은 과소매 상태를 제안하고 30 이하는 과소매입니다. 이 전략은 RSI가 96에 도달하면 판매 신호를 생성하고 RSI가 4 이하로 떨어지면 구매 신호를 생성합니다. 이러한 최적화된 매개 변수는 전통적인 RSI 수준에 비해 강력한 트렌드 내에서 일시적인 반전을 포착하는 데 더 적합합니다.

엔트리 후, 전략은 이윤 취득 및 스톱 로스 메커니즘을 활용합니다. 리버션 후 RSI가 80로 리바운드를 할 때 긴 포지션이 닫히고, RSI가 20으로 떨어지면 짧은 포지션이 닫히고, 효과적으로 리트레이싱 이윤을 잠금합니다. 트레일링 스톱 로스는 엔트리 후 자본 보존을 보장합니다.

이 전략의 장점은 트렌드 역전과 역전으로 이어지는 추론에서 RSI의 민감성을 활용하고 매개 변수 최적화 및 수익 취득/손실 중지로 성능을 향상시키는 것입니다. 그러나 단일 지표는 완벽하지 않으며 트렌드, 지원 및 저항 분석이 결합되어야합니다.

결론적으로, 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")


더 많은