Triple SuperTrend 및 Stoch RSI 전략


생성 날짜: 2023-12-06 14:29:00 마지막으로 수정됨: 2023-12-06 14:29:00
복사: 1 클릭수: 1377
avatar of ChaoZhang ChaoZhang
1
집중하다
1619
수행원

Triple SuperTrend 및 Stoch RSI 전략

개요

트리플 슈퍼트렌드 및 스토흐 RSI 전략은 여러 시간 프레임의 트렌드 추적과 오버로 오버소드 지표의 오버를 결합한 양적 거래 전략이다. 이 전략은 3개의 서로 다른 파라미터 세트의 슈퍼트렌드 지표를 사용하여 시장의 흐름을 판단하고, 스토흐 RSI 지표의 오버로 오버소드 신호와 결합하여 거래 신호를 발산한다. 구체적인 작업에서, 이 전략은 두 개의 더 빠른 슈퍼트렌드 지표가 동시에 구매/판매 신호를 발산할 때, 스토흐 RSI 지표가 이 신호를 확인하면, 그에 따른 더 많은/무료 작업이 수행된다.

전략 원칙

트리플 슈퍼 트렌드 및 스토치 RSI 전략의 핵심 논리는 신호 품질을 높이고 잘못된 신호 비율을 줄이기 위해 SuperTrend 지표와 스토치 RSI 지표의 거래 신호를 필터링하는 것입니다.

첫째, 이 전략은 세 개의 다른 파라미터의 슈퍼트렌드 지표를 사용하여 시장의 주요 흐름을 판단한다. 이 세 개의 슈퍼트렌드 지표의 파라미터 설정은 서로 다르며, 시간 프레임은 빠르고 느리다. 다양한 수준의 트렌드 변화를 잡기 위해 사용됩니다.

둘째, 전략은 스토흐 RSI 지표를 도입하여 신호가 과도하게 과매매되거나 과매매되었는지 판단합니다. 스토흐 RSI 지표는 무작위 지표 RSI와 무작위 지표 스토카스틱의 장점을 결합하여 시장이 과매매 또는 과매매 상태에 있는지 효과적으로 판단 할 수 있습니다. 가장 빠른 및 두 번째로 빠른 슈퍼 트렌드 신호가 스토흐 RSI 지표와 일치하는 신호라면 최종 구매 / 판매 신호를 보낼 수 있습니다.

다중 지표와 다중 시간 프레임의 조합을 통해, 삼중 슈퍼 트렌드 및 스토치 RSI 전략은 시장 소음을 효과적으로 필터링하여 신호의 신뢰성을 높이고 잘못된 거래의 발생을 줄일 수 있습니다.

전략적 이점

트리플 슈퍼 트렌드 및 스토치 RSI 전략의 가장 큰 장점은 여러 지표와 여러 시간 프레임의 효과적인 결합입니다. 이것은 다음과 같은 이점을 제공합니다.

  1. 잘못된 거래 신호를 줄이십시오. 3 개의 슈퍼 트렌드 지표와 스토치 RSI 지표의 결합은 단일 지표의 잡음 신호와 잘못된 신호를 크게 줄일 수 있습니다.

  2. 이윤 신호 비율을 높여라. 신호 주파수가 낮아지더라도 이윤 신호 비율이 크게 높아진다.

  3. 트렌디 시장에 적합하다. 다중 시간 프레임 波은 중장선 트렌드를 포착하는 데 도움이 되며, 트렌드가 더 명백한 시장 환경에 적합하다.

  4. 매개 변수 최적화를 통해 더 나은 효과를 쉽게 얻을 수 있다. 삼중 지표는 매개 변수 최적화에 더 큰 가능성을 제공한다.

  5. 개인 스타일에 따라 파라미터를 조정할 수 있다. 전략이 자신의 거래 스타일에 더 적합하도록 파라미터를 자유롭게 조정할 수 있다.

전략적 위험

트리플 슈퍼 트렌드 및 스토치 RSI 전략에는 다음과 같은 몇 가지 측면에 초점을 맞추는 위험이 있습니다.

  1. 신호 주파수 감소. 다층 필터링 메커니즘은 전략의 거래 주파수가 눈에 띄게 감소합니다.

  2. 일부 신호를 놓치기 쉽다. 전략의 보수성이 일부 잠재적인 기회를 놓치기 쉽다.

  3. 다중 지표가 증가하면 변수 의존도가 높아진다. 지표와 변수가 많을수록 전략 최적화가 더 어려워진다.

  4. 트렌드를 따라가는 능력은 제한된다. 여러 시간 프레임의 결합은 트렌드를 따라가는 전략의 유연성을 제한한다.

위와 같은 위험에는 지표 변수를 조정하여 더 많은 보조 판단 지표를 도입하여 전략을 최적화하여 위험을 통제하면서 더 높은 수익 품질을 얻을 수 있습니다.

전략 최적화 방향

삼중 슈퍼 트렌드 및 스토치 RSI 전략은 다음과 같은 몇 가지 측면에서 더 많은 최적화를 할 수 있습니다.

  1. 지표 변수 모음을 조정하여 최적의 변수 짝을 찾습니다. 더 많은 지표 변수 모음 테스트를 도입하여 최적의 변수를 찾습니다.

  2. 단편 거래 위험을 통제하기 위해 스톱 스톱 전략을 추가하십시오. 이것은 전략의 안정성을 크게 향상시킬 수 있습니다.

  3. 더 많은 판단 지표를 도입하여 신호 검증을 한다. 예를 들어 거래량 지표 등을 도입하여 다각 판단한다.

  4. 적응 기능을 추가한다. 전략은 자동으로 최적화되고 변수를 조정하여 시장 변화에 적응할 수 있다.

  5. 기계 학습 알고리즘과 결합하여 예측한다. AI 알고리즘을 사용하여 지표 신호의 정확성을 예측한다.

계속적으로 최적화하면, 삼중 슈퍼 트렌드 및 스토치 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))