슈퍼 트렌드 기본 전략


생성 날짜: 2023-10-11 15:14:54 마지막으로 수정됨: 2023-10-11 15:14:54
복사: 0 클릭수: 907
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

슈퍼 트렌드 기본 전략은 세 가지 강력한 지표: 슈퍼 트렌드 지표 ((ATR), 상대적으로 강한 지수 ((RSI) 및 지수 이동 평균 ((EMA) 에 기반한 신뢰할 수 있고 수익성이있는 알고리즘 거래 전략입니다. 이 전략은 시장 추세의 방향과 강도를 식별하고, 최적의 입문 지점에서 시장에 진입하고, 중단 지점이나 정지 지점에 도달했을 때 시장에서 빠져 나갑니다.

전략 원칙

이 전략은 슈퍼 트렌드 지표를 사용하여 가격이 상승 또는 하락 추세에 있는지 판단한다. 슈퍼 트렌드 지표는 평균 실제 파도와 한 인자를 기반으로 하며, 가격이 슈퍼 트렌드보다 높으면 상승 추세이며, 가격이 슈퍼 트렌드보다 낮으면 하락 추세이다.

상대적으로 강한 지수는 과열과 과매매 또는 과매매의 상태를 탐지하기 위해 사용됩니다. RSI가 50보다 높으면 강한 시장이며, 반대로 약한 시장입니다. RSI는 가짜 돌파구를 필터링 할 수 있습니다.

지수 이동 평균은 장기적인 트렌드 방향을 판단하는 데 사용됩니다. 가격이 EMA보다 높을 때 상승 트렌드이며, 낮을 때 하락 트렌드입니다. 거래 방향을 확인하는 데 사용할 수 있습니다.

이 전략의 거래 신호는 다음과 같습니다.

다중 입점: 가격이 슈퍼 트렌드보다 높고 RSI가 50보다 높고 가격이 EMA보다 높을 때 더 많이 한다. 다수 출전: 가격 종료 초고속 트렌드 또는 상쇄 또는 정지

공백 입시: 가격이 슈퍼 트렌드보다 낮고 RSI가 50보다 낮고 가격이 EMA보다 낮을 때 공백
공백 출구: 가격 종료 초고 추세 또는 상쇄 또는 정지

스톱로스와 스톱은 입점 가격의 비율로 설정할 수 있다.

우위 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 세 가지 지표의 조합을 사용하여 트렌드 방향을 신뢰할 수 있습니다.

  2. 슈퍼 트렌드 지표는 상승 경향과 하락 경향을 명확하게 판단합니다.

  3. RSI 지표는 가짜 브레이크를 필터링하여 과매매를 방지합니다.

  4. EMA는 큰 트렌드 방향을 확인하는 데 사용될 수 있습니다.

  5. 전략적 신호는 간단하고 명확하며 작동하기 쉽습니다.

  6. 사용자 정의 ATR 주기, RSI 매개 변수 및 EMA 주기 최적화

  7. 리스크를 제어하기 위해 Stop Loss Stopper을 설정할 수 있습니다.

  8. 다른 시장 환경에 적응하기 위해 더 많은 일을 할 수도 있고, 더 적은 일을 할 수도 있습니다.

  9. 어떤 시간 사이클에도 사용할 수 있습니다.

위험 분석

이 전략의 주요 위험은 다음과 같습니다.

  1. 큰 트렌드가 역전되면 슈퍼 트렌드 지표가 지연되어 손실이 발생할 수 있습니다.

  2. 스톱로스 이 너무 작아서 큰 상황을 파악하지 못할 수도 있습니다.

  3. EMA는 트렌드 전환점을 판단할 수 없습니다.

  4. 이 사건은,

  5. 어느 정도의 변동 위험과 시간 거래 위험도 있을 수 있습니다.

대응방법:

  1. 다른 지표와 함께 추세가 바뀐다는 것을 판단하는 것

  2. 정지파수 최적화

  3. 다른 지표와 함께 추세가 바뀐다는 것을 판단하는 것

  4. 이 지표와 함께

  5. 적당히 조정된 위치 관리

최적화 방향

이 전략은 다음과 같은 측면에서 최적화될 수 있습니다.

  1. 감수성과 안정성을 균형을 맞추기 위해 ATR 주기 변수를 최적화합니다.

  2. RSI 파라미터를 최적화하여 정확도를 높여줍니다.

  3. 다양한 시장에 맞게 EMA 주기를 최적화

  4. MACD, KD 등과 같은 다른 측정값을 추가합니다.

  5. 지표에서 벗어난 판단의 역전

  6. 파동이론과 결합된 판단의 역전

  7. 기계 학습과 같은 알고리즘의 동적 최적화 매개 변수

  8. 트래킹 스톱, 모바일 스톱과 같은 고급 스톱 알고리즘을 추가합니다.

  9. 포지션 관리를 최적화하여 다양한 변동률 시장에 적응

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

요약하다

슈퍼 트렌드 기본 전략은 슈퍼 트렌드, RSI 및 EMA의 3 대 지표를 통합하여 간단한 실용적인 트렌드 추적 전략을 형성합니다. 그것은 트렌드 방향을 명확하게 식별하고, 가짜 신호를 필터링하고, 큰 트렌드를 확인합니다. 동시에 명확한 입출장 규칙과 스톱 스톱 설정이 있습니다. 이 전략은 작동하기 쉽고, 신뢰할 수있는 수익을 창출하고, 모든 시간 주기에 적합합니다. 지표 수를 최적화하고, 트렌드 판단 도구를 추가하고, 스톱 손실 알고리즘을 개선하는 방법을 사용하여이 전략을 더 강력한 거래 시스템으로 최적화 할 수 있습니다.

전략 소스 코드
/*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')

//