트리플 슈퍼 트렌드 및 스톡 RSI 전략

저자:차오장, 날짜: 2023-12-06 14:29:00
태그:

img

전반적인 설명

트리플 슈퍼트렌드와 스톡 RSI 전략은 슈퍼트렌드 지표와 스톡 RSI 지표의 과반 구매/대판 신호를 결합한 다중 시간 프레임 트렌드 트렌드 트렌드 전략이다. 이 전략은 시장 트렌드를 결정하기 위해 서로 다른 매개 변수 설정을 가진 세 개의 슈퍼트렌드 지표를 활용하고 스톡 RSI 신호를 결합하여 무역 신호를 필터링한다. 특히 두 가지 빠른 슈퍼트렌드 지표가 동시에 구매/판매 신호를 제공하면 스톡 RSI 지표가 확인되면 대응하는 긴/단 포지션이 취해질 것이다.

전략 논리

트리플 슈퍼트렌드 및 스톡 RSI 전략의 핵심 논리는 다른 매개 변수와 스톡 RSI 지표를 결합하여 거래 신호 필터링을 통해 신호 품질을 향상시키고 잘못된 신호를 줄이는 것입니다.

우선, 전략은 주요 시장 트렌드를 결정하기 위해 다양한 매개 변수 설정을 가진 세 개의 슈퍼 트렌드 지표를 채택합니다. 세 개의 슈퍼 트렌드 지표는 다른 수준에서 트렌드 변화를 포착하기 위해 빠른 시간 프레임에서 느린 시간 프레임까지의 매개 변수를 가지고 있습니다. 가장 빠르고 두 번째로 빠른 슈퍼 트렌드 지표가 동시에 구매 / 판매 신호를 제공하면 신호가 어느 정도 신뢰성을 가지고 있다는 사전 판단을합니다.

두 번째로, 스톡 RSI 지표는 시그널이 발생했을 때 시장이 극도로 과잉 구매되거나 과잉 판매되었는지 여부를 결정하기 위해 도입됩니다. 스톡 RSI 지표는 RSI와 스톡라스틱 지표의 강점을 결합하여 과잉 구매 / 과잉 판매 시장 조건에 대한 효과적인 판단을 가능하게합니다. 가장 빠르고 두 번째로 빠른 슈퍼 트렌드 신호가 스톡 RSI 신호와 일치하면 최종 구매 / 판매 신호가 유발 될 수 있습니다.

여러 지표와 시간 프레임을 결합함으로써 트리플 슈퍼 트렌드 및 스톡 RSI 전략은 시장 소음을 효과적으로 필터링하고 신호 신뢰성을 향상시키고 잘못된 거래를 줄일 수 있습니다.

전략 의 장점

트리플 슈퍼 트렌드 및 스톡 RSI 전략의 가장 큰 장점은 여러 지표와 시간 프레임의 효과적인 조합으로 다음과 같은 이점을 가져옵니다.

  1. 잘못된 거래 신호를 줄입니다. 세 개의 슈퍼 트렌드 및 스톡 RSI 지표의 조합은 개별 지표와 함께 오는 잡음 및 잘못된 신호를 크게 줄일 수 있습니다.

  2. 수익성 신호 비율을 향상시킵니다. 신호 주파수가 감소했음에도 불구하고 수익성 신호의 비율은 크게 향상되었습니다.

  3. 트렌딩 시장에 적합합니다. 멀티 타임프레임 필터링은 중장기 트렌드를 캡처하고 트렌딩 시장 환경에 잘 맞게합니다.

  4. 더 나은 성능을 위해 쉬운 최적화. 세 개의 지표는 매개 변수 최적화에 대한 더 넓은 가능성을 허용합니다.

  5. 개인 거래 스타일에 맞는 사용자 정의 가능한 매개 변수. 매개 변수는 자신의 거래 스타일에 더 잘 맞게 자유롭게 조정 할 수 있습니다.

전략 의 위험

또한 트리플 슈퍼 트렌드 및 스톡 RSI 전략과 관련된 몇 가지 위험이 있습니다.

  1. 신호 주파수 감소. 다층 필터 메커니즘은 전략의 거래 주파수를 크게 감소시킵니다.

  2. 잠재적인 신호를 놓칠 수 있습니다. 보수적인 특성 때문에 이윤을 창출할 수 있는 기회를 놓칠 수 있습니다.

  3. 매개 변수 의존도가 높습니다. 더 많은 지표는 최적화에 더 큰 어려움을 의미합니다.

  4. 제한된 트렌드 추적 능력. 여러 시간 프레임 조합은 또한 전략의 트렌드 추적의 유연성을 제한합니다.

이러한 위험을 해결하기 위해, 지표 매개 변수를 조정하고 더 많은 보충 지표를 도입하는 것과 같은 최적화 조치는 수익성 품질을 향상시키는 동시에 위험 통제를 강화하기 위해 채택 될 수 있습니다.

최적화 방향

트리플 슈퍼 트렌드 및 스톡 RSI 전략의 추가 최적화에 대한 여지가 여전히 있습니다.

  1. 가장 좋은 조합을 위해 지표 매개 변수를 조정합니다. 최적을 찾기 위해 더 많은 매개 변수를 테스트 할 수 있습니다.

  2. 더 나은 리스크 통제를 위해 스톱 로스/프로피트를 도입하십시오. 이것은 전략의 안정성을 크게 향상시킬 수 있습니다.

  3. 신호 검증을 위한 더 많은 지표, 예를 들어 부피 지표를 포함합니다.

  4. 변화하는 시장 역동성에 따라 파라미터를 자동으로 최적화 할 수 있는 적응 기능을 구축합니다.

  5. 성능 예측을 위해 기계 학습 알고리즘을 결합하고 신호 정확성을 평가합니다.

지속적인 최적화로 트리플 슈퍼 트렌드 및 스톡 RSI 전략은 안정적이고 효율적인 거래 시스템으로 발전하여 상당한 알파를 제공할 수 있습니다.

결론

트리플 슈퍼 트렌드 및 스톡 RSI 전략은 다중 시간 프레임 분석과 과잉 구매/대판 판단을 독특한 트렌드 다음 거래 전략으로 성공적으로 결합합니다. 트렌드 다음 및 지표 필터링의 이중 장점을 유지하여 수익성 신호를 개선하고 잘못된 신호를 감소시킵니다. 위험과 최적화 공간이 여전히 존재하지만 매개 변수 조정 및 전략 최적화를 통해 수익성과 안정성이 더욱 향상 될 수 있습니다. 전반적으로 트리플 슈퍼 트렌드 및 스톡 RSI 전략은 고품질의 양적 거래 전략 선택을 제공합니다.


/*backtest
start: 2022-11-29 00:00:00
end: 2023-04-17 00:00:00
period: 1d
basePeriod: 1h
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/
// © M3RZI

//@version=4
strategy("3x Supertrend and Stoch RSI", overlay = true, max_bars_back = 1000)

//INPUTS
STATRLENGTH1 = input(10, title = "Fast Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")
STATRMULT1 = input(1, title = "Fast Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")
STATRLENGTH2 = input(11, title = "Medium Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")
STATRMULT2 = input(2, title = "Medium Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")
STATRLENGTH3 = input(12, title = "Slow Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")
STATRMULT3 = input(3, title = "Slow Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")

stochK = input(3, title = "K (Stochastic Fast)", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
stochD = input(3, title = "D (Signal Line)", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
rsiLength = input(14, title = "RSI Length", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
stochLength = input(14, title = "Stochastic Length", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
rsiSource = input(close, title = "RSI Source", type = input.source, group = "STOCHASTIC RSI SETTINGS")
stochRestrictions = input(false, title = "Restrict crosses to overbought/oversold territory", type = input.bool, group = "STOCHASTIC RSI SETTINGS")
overboughtLine = input(80, title = "Stochastic  RSI Upper Band", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
oversoldLine = input(20, title = "Stochastic RSI Lower Band", type = input.integer, group = "STOCHASTIC RSI SETTINGS")

EMALength  = input(200, title = "EMA Length", type = input.integer, group = "EMA SETTINGS")

SLStrategy = input("ATR Based", title = "Stop Loss Strategy", options = ["ATR Based"],type = input.string, group = "POSITION EXIT SETTINGS")
SLATRLength = input(14, title = "Stop Loss ATR Length", type = input.integer, group = "POSITION EXIT SETTINGS")
SLATRMult = input(2.7, title = "Stop Loss ATR Multiplier", type = input.float, group = "POSITION EXIT SETTINGS")
TPStrategy = input("ATR Based", title = "Take Profit Strategy", options = ["ATR Based"],type = input.string, group = "POSITION EXIT SETTINGS")
TPATRLength = input(14, title = "Take Profit ATR Length", type = input.integer, group = "POSITION EXIT SETTINGS")
TPATRMult = input(1.6, title = "Take Profit ATR Multiplier", type = input.float, group = "POSITION EXIT SETTINGS")

//SUPERTRENDS
[superTrend1,dir1] = supertrend(STATRMULT1,STATRLENGTH1)
[superTrend2,dir2] = supertrend(STATRMULT2,STATRLENGTH2)
[superTrend3,dir3] = supertrend(STATRMULT3,STATRLENGTH3)

directionST1 = dir1 == 1 and dir1[1] == 1 ? false : dir1 == -1 and dir1[1] == -1 ? true : na
directionST2 = dir2 == 1 and dir2[1] == 1 ? false : dir2 == -1 and dir2[1] == -1 ? true : na
directionST3 = dir3 == 1 and dir3[1] == 1 ? false : dir3 == -1 and dir3[1] == -1 ? true : na

//STOCH RSI
rsi = rsi(rsiSource, rsiLength)
k = sma(stoch(rsi, rsi, rsi, stochLength), stochK)
d = sma(k, stochD)

//EMA
ema = ema(close,EMALength)

//CONDITIONS LONG AND SHORT

var long = false
var longCondition = false
var short = false
var shortCondition = false
var drawing = false
var TP = 0.0
var SL = 0.0
var middle = 0.0
var initial = 0

stopSize = atr(SLATRLength) * SLATRMult
profitSize = atr(TPATRLength) * TPATRMult
longStop = close - stopSize
longProfit = close + profitSize
current = close
shortStop = close + stopSize
shortProfit = close - profitSize
barInitial = bar_index

if  stochRestrictions
    longCondition := close > ema and ((directionST1 == true and directionST2 == true)  or (directionST2 == true and directionST3 == true)) and crossover(k,d) and k < oversoldLine and not long and not drawing
    shortCondition := close < ema and ((directionST1 == false and directionST2 == false)  or (directionST2 == false and directionST3 == false)) and crossunder(k,d) and k > overboughtLine and not short and not drawing
else
    longCondition := close > ema and ((directionST1 == true and directionST2 == true)  or (directionST2 == true and directionST3 == true)) and crossover(k,d) and not long and not drawing
    shortCondition := close < ema and ((directionST1 == false and directionST2 == false)  or (directionST2 == false and directionST3 == false)) and crossunder(k,d) and not short and not drawing

if longCondition
    long := true
    short := false
    drawing := true
    TP := longProfit
    middle := current
    SL := longStop
    initial := barInitial
    strategy.entry("Long", strategy.long, 10)
    strategy.exit("Long exit","Long", limit = TP, stop = SL)
    alert("Long signal Supertrend \n Profit:"+tostring(TP)+"\Curret price:"+tostring(close)+"\Stop:"+tostring(SL),alert.freq_once_per_bar_close)
    //label.new(bar_index,low,text = "Long\nTP:"+tostring(TP)+"\nSL:"+tostring(SL)+"\nAbierto:"+tostring(current), yloc = yloc.belowbar, textcolor = color.white, color = color.green, size = size.small,  style = label.style_label_up)

if shortCondition
    short := true
    long := false
    drawing := true
    TP := shortProfit
    middle := current
    SL := shortStop
    initial := barInitial
    strategy.entry("Short", strategy.short, 10)
    strategy.exit("Short exit","Short",limit = TP , stop = SL)
    alert("Short signal Supertrend \n Profit:"+tostring(TP)+"\Curret price:"+tostring(close)+"\Stop:"+tostring(SL),alert.freq_once_per_bar_close)
    //label.new(bar_index,high,text = "Short\nTP:"+tostring(TP)+"\nSL:"+tostring(SL)+"\nAbierto:"+tostring(current), yloc = yloc.abovebar, textcolor = color.white, color = color.red, size = size.small,  style = label.style_label_down)

if long and (high[1] >= TP or low[1] <= SL)
    drawing := false
    long := false
    if high[1] >= TP
        label.new(bar_index[int((bar_index - initial)/2)],TP, text = "Win (Long)", textcolor = color.white, color = color.green, size = size.small, style = label.style_label_down)
    else
        label.new(bar_index[int((bar_index - initial)/2)],SL, text = "Lose (Long)", textcolor = color.white, color = color.red, size = size.small, style = label.style_label_up)

if short and (low[1] <= TP or high[1] >= SL)
    drawing :=  false
    short := false
    if low[1] <= TP
        label.new(bar_index[int((bar_index - initial)/2)],TP, text = "Win (short)", textcolor = color.white, color = color.green, size = size.small, style = label.style_label_up)
    else
        label.new(bar_index[int((bar_index - initial)/2)],SL, text = "Lose (short)", textcolor = color.white, color = color.red, size = size.small, style = label.style_label_down)

//STRATEGY
//strategy.entry("buy", strategy.long, 10, when = longCondition)
//strategy.exit("bracket", "buy",  10, limit = TP, stop = SL)
//strategy.entry("short", strategy.long, 10, when = shortCondition)
//strategy.exit("bracket", "short",  10, limit = TP, stop = SL)

//DRAWING
plotshape(longCondition, title = "Long Signal", location=location.belowbar, style=shape.labelup, color=color.green, textcolor=color.white, size=size.small, text="Long")
plotshape(shortCondition, title = "Short Signal", location=location.abovebar, style=shape.labeldown, color=color.red, textcolor=color.white, size=size.small, text="Short")
profitLine = plot(drawing and drawing[1] ? TP : na, title = "Take profit", color = color.green, style = plot.style_linebr)
currentLine =plot(drawing and drawing[1]  ? middle : na, title = "Middle Line", color = color.white, style = plot.style_linebr)
lossLine = plot(drawing and drawing[1]  ? SL : na, title = "Stop Loss", color = color.red, style = plot.style_linebr)
fill(currentLine,profitLine, title = "Profit Background" ,color = color.new(color.green,75))
fill(currentLine,lossLine, title = "Loss Background" ,color = color.new(color.red,75))
plot(superTrend1, title = "Fast Supertrend", color = dir1 == 1 and dir1[1] == 1 ? color.red : dir1 == -1 and dir1[1] == -1 ? color.green : na)
plot(superTrend2, title = "Medium Supertrend", color = dir2 == 1 and dir2[1] == 1 ? color.red : dir2 == -1 and dir2[1] == -1 ? color.green : na)
plot(superTrend3, title = "Slow Supertrend", color = dir3 == 1 and dir3[1] == 1 ? color.red : dir3 == -1 and dir3[1] == -1 ? color.green : na)
plot(ema, title = "EMA",color = color.yellow)
//plot(k, color = color.blue)
//plot(d, color = color.orange)
//h1 = hline(80)
//h2 = hline(20)
//fill(h1,h2, color = color.new(color.purple,60))




더 많은