슈퍼트렌드 기본 전략

저자:차오장, 날짜: 2023-10-11 15:14:54
태그:

전반적인 설명

슈퍼트렌드 기본 전략은 세 가지 강력한 지표: 슈퍼트렌드 (ATR), RSI 및 EMA를 기반으로 신뢰할 수 있고 수익성이 높은 알고리즘 거래 전략입니다. 시장 트렌드의 방향과 강도를 파악하고 최적의 지점에서 시장에 진입하고 스톱 로스 또는 영업이 달성되면 탈퇴하는 것을 목표로합니다.

전략 논리

이 전략은 가격이 상승 추세 또는 하락 추세인지 결정하기 위해 슈퍼 트렌드 지표를 사용합니다. 슈퍼 트렌드는 평균 진정한 범위와 요소, 슈퍼 트렌드의 위는 상승 추세이고 아래는 하락 추세를 기반으로합니다.

RSI는 과잉 구매/ 과잉 판매 상태를 감지하는 데 사용됩니다. 50 이상은 상승하고 50 이하는 하락합니다. RSI는 잘못된 신호를 필터링합니다.

EMA는 장기적인 트렌드 방향을 판단합니다. EMA 위는 상승 추세이고 아래는 하락 추세입니다. 무역 방향을 확인합니다.

거래 신호는 다음과 같습니다.

롱 엔트리: 슈퍼트렌드 이상의 가격과 50 이상의 RSI와 EMA 이상의 가격 긴 출입: 가격이 슈퍼 트렌드 또는 스톱 손실 또는 수익을 취하로 닫습니다.

짧은 엔트리: 슈퍼트렌드 이하의 가격과 50 이하의 RSI와 EMA 이하의 가격 짧은 출구: 가격이 슈퍼 트렌드 또는 스톱 손실 또는 수익을 취하기 전에 닫습니다.

스톱 로즈와 취득은 입시 가격의 비율로 설정할 수 있습니다.

이점 분석

이 전략의 장점:

  1. 3개 지표의 조합, 신뢰성 있는 트렌드 감지

  2. 슈퍼트렌드는 상승세와 하락세를 명확히 파악합니다.

  3. RSI는 가짜 브레이크오웃을 필터링하고 과잉 구매/ 과잉 판매를 피합니다.

  4. EMA는 전반적인 동향 방향을 확인합니다.

  5. 단순하고 명확한 거래 신호, 따라하기 쉽다

  6. 최적화를 위한 조정 가능한 ATR 기간, RSI 매개 변수 및 EMA 기간

  7. 손실을 멈추고 위험을 통제하기 위해 수익을 취하십시오.

  8. 다른 시장에 대한 단기 또는 단기 모드

  9. 모든 기간에 적용됩니다.

위험 분석

주요 위험은:

  1. 트렌드 반전에서 슈퍼 트렌드의 지연은 손실을 초래할 수 있습니다.

  2. 작은 스톱 손실/이익 취득은 큰 움직임을 잡지 못합니다.

  3. EMA는 트렌드 반전 지점을 발견할 수 없습니다.

  4. 분차 검출이 되지 않음

  5. 여전히 변동성 위험과 시간 위험

해결책:

  1. 반전을 감지하기 위해 다른 지표를 추가합니다.

  2. 스톱 로스/프로프트 취득을 최적화

  3. 스팟 역전으로 다른 지표를 추가합니다.

  4. 분산 지표 포함

  5. 위치 크기를 조정

최적화 방향

전략을 최적화하는 방법:

  1. 감수성과 안정성을 위해 ATR 기간을 최적화

  2. 더 높은 정확성을 위해 RSI 매개 변수를 최적화

  3. 다른 시장에 대한 EMA 기간을 최적화

  4. 역전 탐지를 위해 MACD, KD와 같은 지표를 추가

  5. 오차 지표를 추가합니다.

  6. Elliott Waves를 사용하여 반전을 감지합니다.

  7. 매개 변수를 동적으로 최적화하기 위해 기계 학습을 사용

  8. 후속 스톱 손실과 같은 고급 스톱 손실 알고리즘

  9. 다른 변동성에 대한 포지션 크기를 최적화

  10. 더 복잡한 입출입 조건을 테스트합니다.

결론

슈퍼트렌드 기본 전략은 슈퍼트렌드, RSI 및 EMA를 단순하고 실용적인 트렌드 추적 시스템으로 통합합니다. 트렌드 방향을 명확하게 식별하고 잘못된 신호를 필터링하고 전반적인 트렌드를 확인합니다. 명확한 입출시 규칙 및 스톱 손실 / 수익 취득 구성. 사용하기 쉽고 신뢰할 수있는 수익성. 모든 시간 프레임에 적용됩니다. 매개 변수를 조정하고 반전 도구를 추가하고 더 강력한 거래 시스템이 되기 위해 스톱을 강화하여 추가로 최적화 할 수 있습니다.


/*backtest
start: 2023-09-10 00:00:00
end: 2023-10-10 00:00:00
period: 2h
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/
// © JS_TechTrading

//@version=5
// strategy("Supertrend", overlay=true,default_qty_type =strategy.percent_of_equity,default_qty_value = 1,process_orders_on_close = false)

// group string////
var string group_text000="Choose Strategy"
var string group_text0="Supertrend Settings"
var string group_text0000="Ema Settings"
var string group_text00="Rsi Settings"
var string group_text1="Backtest Period"
var string group_text2="Trade Direction"
// var string group_text3="Quantity Settings"
var string group_text4="Sl/Tp Settings"
////////////////////
option_ch=input.string('Pullback',title = "Type Of Strategy",options =['Pullback','Simple'])

//atr period input supertrend 
atrPeriod = input(10, "ATR Length",group = group_text0)
factor = input.float(3.0, "Factor", step = 0.01,group=group_text0)

[supertrend, direction] = ta.supertrend(factor, atrPeriod)

bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)

long=direction < 0 ? supertrend : na
short=direction < 0? na : supertrend

longpos=false
shortpos=false

longpos :=long?true :short?false:longpos[1]
shortpos:=short?true:long?false:shortpos[1]

fin_pullbuy= (ta.crossunder(low[1],long) and long and high>high[1])
fin_pullsell=(ta.crossover(high[1],short) and short and low<low[1]) 

//Ema 1
on_ma=input.bool(true,"Ema Condition On/Off",group=group_text0000)
ma_len= input.int(200, minval=1, title="Ema Length",group = group_text0000)
ma_src = input.source(close, title="Ema Source",group = group_text0000)
ma_out = ta.ema(ma_src, ma_len)

ma_buy=on_ma?close>ma_out?true:false:true
ma_sell=on_ma?close<ma_out?true:false:true

// rsi indicator and condition
// Get user input
en_rsi    = input.bool(true,"Rsi Condition On/Off",group = group_text00)
rsiSource = input(title='RSI Source', defval=close,group = group_text00)
rsiLength = input(title='RSI Length', defval=14,group = group_text00)
rsiOverbought = input(title='RSI BUY Level', defval=50,group = group_text00)
rsiOversold   = input(title='RSI SELL Level', defval=50,group = group_text00)

// Get RSI value
rsiValue = ta.rsi(rsiSource, rsiLength)

rsi_buy=en_rsi?rsiValue>=rsiOverbought ?true:false:true
rsi_sell=en_rsi?rsiValue<=rsiOversold?true:false:true

// final condition
buy_cond=option_ch=='Simple'?long and not(longpos[1]) and rsi_buy and ma_buy:option_ch=='Pullback'?fin_pullbuy and rsi_buy and ma_buy:na
sell_cond=option_ch=='Simple'?short and not(shortpos[1]) and rsi_sell and ma_sell:option_ch=='Pullback'?fin_pullsell and rsi_sell and ma_sell:na

//backtest engine
start = input(timestamp('2005-01-01'), title='Start calculations from',group=group_text1)
end=input(timestamp('2045-03-01'), title='End calculations',group=group_text1)
time_cond =true

// Make input option to configure trade direction

tradeDirection = input.string(title='Trade Direction', options=['Long', 'Short', 'Both'], defval='Both',group = group_text2)

// Translate input into trading conditions
longOK  = (tradeDirection == "Long") or (tradeDirection == "Both")
shortOK = (tradeDirection == "Short") or (tradeDirection == "Both")



// strategy start
if buy_cond and longOK and time_cond and strategy.position_size==0
    strategy.entry('long',direction = strategy.long)
if sell_cond and shortOK and time_cond and strategy.position_size==0
    strategy.entry('short',direction =strategy.short)

// fixed percentage based stop loss and take profit 

// User Options to Change Inputs (%)
stopPer = input.float(1.0,step=0.10, title='Stop Loss %',group =group_text4) / 100
takePer = input.float(1.0,step =0.10, title='Take Profit %',group =group_text4) / 100

// Determine where you've entered and in what direction
longStop  = strategy.position_avg_price * (1 - stopPer)
shortStop = strategy.position_avg_price * (1 + stopPer)
shortTake = strategy.position_avg_price * (1 - takePer)
longTake  = strategy.position_avg_price * (1 + takePer)


if strategy.position_size > 0
    strategy.exit(id='Close Long',stop=longStop, limit=longTake)
if strategy.position_size < 0
    strategy.exit(id='Close Short',stop=shortStop, limit=shortTake)

//PLOT FIXED SLTP LINE
plot(strategy.position_size > 0 ? longStop : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Long Fixed SL')
plot(strategy.position_size < 0 ? shortStop :na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Short Fixed SL')
plot(strategy.position_size > 0 ? longTake : na, style=plot.style_linebr, color=color.new(color.green, 0), linewidth=1, title='Long Take Profit')
plot(strategy.position_size < 0 ? shortTake : na, style=plot.style_linebr, color=color.new(color.green, 0), linewidth=1, title='Short Take Profit')

//

더 많은