
RSI 트렌드 리버스 전략은 상대적으로 약한 지수 (RSI) 와 평균 실제 파도 (ATR) 를 기반으로 한 정량 거래 전략이다. 이 전략은 동적으로 정지 스톱 로드 (TP/SL) 를 조정하여 빠른 시장 변동에 적응하여 트렌드 리버스 기회를 포착한다. 이 전략은 RSI를 중심으로 ATR과 함께 변동성을 측정하고 다음 두 가지의 적응 동적 영역을 구축하여 입지를 평정하는 기초로 사용한다. 이 전략은 독립적으로 사용할 수 있으며 다른 전략의 정지 스톱 로드 모듈로도 사용할 수 있다.
RSI 트렌드 반전 전략의 핵심은 동적인 정지/단지 손해역의 구성에 있다. 우선, 사용자 정의된 highest_custom 및 lowest_custom 함수를 사용하여 지난 교차 이후의 최고 가격과 최저 가격을 찾아 파동대 기반을 형성한다. 그 다음, 각각 RSI와 ATR의 길이를 계산하고, 다음과 같이 계산한다:
이 중 multiplier는 사용자 정의 된 파장의 확장 인자를 낸다. 가격이 위쪽으로 돌파하면 더 많이 하고, 하향으로 돌파하면 더 적게 한다. 또한 이 두 대의 색상은 가격의 상대적인 파장의 위치에 따라 변하는 것을 관찰하기 쉽다.
RSI 트렌드 리버스 전략은 RSI와 ATR을 사용하여 자기 적응 영역을 구축하여 시장 변화에 신속하게 대응할 수 있습니다. 이 전략의 논리는 명확하고 적용 범위가 넓으며 양자 거래자의 강력한 도구로 사용할 수 있습니다. 그러나 실제 사용에서는 여전히 파라미터 선택 및 위험 제어에 주의를 기울이고 전체 성능을 향상시키기 위해 다른 지표 신호 포지션과 함께 사용하는 것이 좋습니다.
/*backtest
start: 2023-04-22 00:00:00
end: 2024-04-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI Trend Reversal", overlay=true, max_bars_back = 4999, calc_on_every_tick = false)
//INPUTS
rsi_length = input.int(title = "Lenght", defval = 8)
rsi_mult = input.float(title = "Multiplier", defval = 1.5, step = .05)
lookback = input.int(title = "Delay to prevent idealization", defval = 1)
sltp = input.float(title = "Minimum Difference", defval = 10)
src = input.source(title = "Source Input", defval = close)
//PARAMETERS INITILIZATION
hclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, src)
//FUNCTION INITILIZATION
highest_custom(src, length) =>
x = src
for i = 0 to length
if src[i] > x
x := src[i]
x
lowest_custom(src, length) =>
x = src
for i = 0 to length
if src[i] < x
x := src[i]
x
rsilev(src, length, mult, sltp) =>
sl = (100 - sltp) / 100
tp = (100 + sltp) / 100
var bool crossup = na
var bool crossdown = na
var float dir = na
dir_change = ta.change(dir)
var float BearGuy = 0
BullGuy = ta.barssince(crossup or crossdown)
if na(BullGuy)
BearGuy += 1
else
BearGuy := BullGuy
var float upper = na
var float lower = na
rsilower = ta.rsi(src, length)
rsiupper = math.abs(ta.rsi(src, length) - 100)
atr = ta.atr(length) / src
lower := highest_custom(math.max(highest_custom(highest_custom(src, BearGuy) * (1 - (atr + ((1 / (rsilower) * mult)))), BearGuy), src * sl), BearGuy)
upper := lowest_custom(math.min(lowest_custom(lowest_custom(src, BearGuy) * (1 + (atr + ((1 / (rsiupper) * mult)))), BearGuy), src * tp), BearGuy)
var float thresh = na
if na(thresh)
thresh := lower
if na(dir)
dir := 1
if crossdown
dir := -1
if crossup
dir := 1
if dir == 1
thresh := lower
if dir == -1
thresh := upper
crossup := ta.crossover(src, thresh)
crossdown := ta.crossunder(src, thresh)
thresh
rsiclose = rsilev(hclose, rsi_length, rsi_mult, sltp)
//PLOTTING
var color col = color.lime
if hclose > rsiclose
col := color.lime
if hclose < rsiclose
col := color.red
plot(rsiclose, linewidth = 2, color = col)
//STRATEGY
buy = ta.crossover(hclose, rsiclose)
sell = ta.crossunder(hclose, rsiclose)
if buy[lookback]
strategy.entry("long", strategy.long)
if sell[lookback]
strategy.entry("Short", strategy.short)