
이 전략은 지수 이동 평균 ((EMA) 와 슬라이드 방향 지표 ((SDI) 를 기반으로 한 자기 적응 트렌드 추적 거래 시스템입니다. 이 전략은 여러 기술적 지표와 위험 관리 도구를 결합하여 시장 추세를 포착하고 위험을 제어합니다. 이 전략은 빠른 및 느린 EMA의 교차와 SDI의 방향을 사용하여 시장 추세를 파악하고 그에 따라 구매 및 판매 신호를 생성합니다.
이 전략의 핵심은 자율성과 포괄적 인 위험 관리 방식에 있습니다. EMA 주기와 SDI 부드러움 및 위험 관리 값과 같은 조정 가능한 매개 변수를 사용하여 거래자는 다양한 시장 조건과 개인 위험 선호에 따라 전략을 최적화 할 수 있습니다.
지표 계산:
거래 신호 생성:
포지션 관리:
위험 관리:
시간 필터:
트렌드 캡처 능력: EMA와 SDI를 결합하여 시장의 트렌드를 효과적으로 식별하고 추적합니다.
자기 적응력: 조정 가능한 매개 변수를 통해 다른 시장 조건에 적응한다.
종합적인 위험 관리: 통합적인 스톱, 스로스, 스로스 추적, 종합적인 위험 제어.
유연한 포지션 제어: 리버리지와 자본 사용 비율을 조정할 수 있습니다.
재검토 친화적: 전략 최적화를 위한 역사 데이터 재검토를 지원한다.
감정 중립성: 객관적인 지표에 기초하여 주관적인 감정의 영향을 줄인다.
다기능: 다른 시간 주기 및 거래 품종에 사용할 수 있다.
과도한 거래: 불안한 시장에서는 거래가 빈번하게 이루어져 비용이 증가할 수 있다.
지연성: EMA와 SDI는 지연된 지표로, 추세가 역전될 때 반응이 느릴 수 있다.
가짜 브레이크 위험: 짧은 기간의 변동에 따라 흐름을 잘못 판단하여 잘못된 거래로 이어질 수 있다.
매개 변수 민감성: 성능은 매개 변수 설정에 크게 의존하며, 지속적인 최적화가 필요합니다.
시장 환경 의존성: 특정 시장 조건에서 좋지 않은 성과를 낼 수 있다.
리베이트 위험: 높은 리베이트가 손실을 증가시킬 수 있으므로 신중하게 사용하십시오.
기술 의존성: 안정적인 기술 환경에 의존하고, 시스템 장애가 손실을 초래할 수 있다.
동적 변수 조정: EMA와 SDI의 변수를 다양한 시장 단계에 맞게 조정할 수 있습니다.
다중 시간 프레임 분석: 여러 시간 주기의 신호를 통합하여 트렌드 판단의 정확성을 향상시킵니다.
변동성 필터: ATR과 같은 변동성 지표를 추가하여 높은 변동성 기간에 거래 규칙을 조정합니다.
시장 상태 식별: 시장 상태 분류 ((트렌드/스컬러), 타겟팅 최적화 거래 논리 도입.
자금 관리 최적화: 동적인 포지션 조정을 구현하고, 계좌의 적자 상태에 따라 자동으로 위험을 조정한다.
지표 조합: RSI 또는 MACD와 같은 다른 보완 지표를 추가하여 신호 신뢰성을 강화하는 것을 고려하십시오.
기계 학습 통합: 기계 학습 알고리즘을 도입하고, 파라미터 선택 및 신호 생성을 최적화한다.
이 EMA와 SDI가 결합된 자기 적응 트렌드 추적 전략은 강력한 시장 적응력과 위험 관리 능력을 보여준다. 유연한 파라미터 설정과 포괄적인 위험 제어 조치를 통해 거래자에게 신뢰할 수 있는 정량 거래 프레임워크를 제공한다. 전략의 핵심 장점은 트렌드에 민감한 캡처와 위험에 대한 엄격한 통제로 인해 다양한 시장 환경에서 안정적인 성능을 유지할 수 있다.
그러나, 거래자는 전략의 고유한 지연성과 파라미터 민감성 같은 잠재적인 위험에 주의해야 합니다. 이 전략은 특히 동적 파라미터 조정, 다중 시간 프레임 분석 및 시장 상태 식별과 같은 측면에서 지속적인 최적화 및 개선을 통해 성능과 안정성을 더욱 향상시킬 수 있습니다.
전체적으로, 이 전략은 양적 거래에 대한 견고한 기반을 제공하며, 체계적이고 규율적인 거래 방법을 찾는 투자자에게 적합합니다. 전략의 원리를 깊이 이해하고 개인 거래 스타일을 결합하면, 거래자는이 도구를 효과적으로 사용하여 금융 시장에서 경쟁력을 높일 수 있습니다.
/*backtest
start: 2024-06-01 00:00:00
end: 2024-06-30 23:59:59
period: 1h
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/
// © erdas0
//@version=5
strategy("Strategy SEMA SDI Webhook", overlay=true, slippage = 1, commission_value = 0.035, default_qty_type=strategy.percent_of_equity, default_qty_value=50, initial_capital = 1000, calc_on_order_fills = true, process_orders_on_close = true)
// Start and end dates
dts=input(false,"",inline="dts")
dte=input(false,"",inline="dte")
start_date = input(timestamp("2023-01-01 00:00:00"), "Start Date",inline="dts")
end_date = input(timestamp("2124-01-01"), "End Date",inline="dte")
times = true
// Initial capital
leverage= input.int(10, "Leverage", minval=1,inline="qty") //Leverage Test
usdprcnt= input.int(50, "%", minval=1,inline="qty")
qty= input(false,"Inital USDT ◨",inline="qty")
initial_capital = qty ? (strategy.initial_capital+strategy.netprofit)/close*leverage*usdprcnt/100 : na
//Level Inputs
tpon=input(false,"TP ◨",group ="Take Profit/Stop Loss", inline="1")
sloc=input(true,"SL ◨",group ="Take Profit/Stop Loss", inline="1")
tron=input(true,"Trailing ◨",group ="Take Profit/Stop Loss", inline="1")
tp = tpon ? input.float(25, "Take Profit %", minval=0.1,step=0.1,group ="Take Profit/Stop Loss", inline="2") : na
sl = sloc ? input.float(4.8, "Stop Loss %", minval=0.1,step=0.1,group ="Take Profit/Stop Loss", inline="2") : na
tr = tron ? input.float(1.9, "Trailing Stop ", minval=0.1,step=0.1,group ="Take Profit/Stop Loss", inline="4") : na
// Take profit and stop loss levels
dir=strategy.position_size/math.abs(strategy.position_size) //Directions
newtrade=strategy.closedtrades>strategy.closedtrades[1]
pftpcnt=dir<0 ? (strategy.position_avg_price-low)/strategy.position_avg_price*100 : dir>0 ? (high-strategy.position_avg_price)/strategy.position_avg_price*100 : na //max profit
pftpr= (1 + pftpcnt*dir/100) * strategy.position_avg_price //Trailing Price
take_profit = (1 + tp*dir/100) * strategy.position_avg_price
stop_loss = (1 - sl*dir/100) * strategy.position_avg_price
var float maxpft=na //max profit percent
maxpft := newtrade ? 0 : strategy.openprofit > 0 ? math.max(pftpcnt,maxpft) : maxpft
var float Tr=na //Trailing
Tr := newtrade ? na : pftpcnt >= tr and maxpft-pftpcnt >= tr ? close : Tr
//Inputs
ocema=input(true, title='EMA ◨',group="Inputs",inline="2")
ocsd=input(true, title='SDI ◨',group="Inputs",inline="2")
ocsm=input(true, title='Smooth ◨',group="Inputs",inline="2")
lenf = input.int(58, "Fast Ema", minval=1,group ="Inputs", inline="3")
lens = input.int(70, "Slow Ema", minval=1,group ="Inputs", inline="3")
slen = input.int(3, "Smooth", minval=1,group ="Inputs", inline="4")
dilen = input.int(1, title="DI Length", minval=1,group ="SDI", inline="5")
sdi = input.int(6, title="DI Smooth", minval=1,group ="SDI", inline="5")
//EMA
emaf=ta.ema(close,lenf)
emas=ta.ema(close,lens)
semaf=ta.ema(emaf,slen)
semas=ta.ema(emas,slen)
//SDI
dirmov(len,smt) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = ta.ema(fixnan(100 * ta.rma(plusDM, len) / truerange),smt)
minus = ta.ema(fixnan(100 * ta.rma(minusDM, len) / truerange),smt)
[plus, minus]
[plus,minus]=dirmov(dilen,sdi)
pm=ta.ema(plus-minus,10)
sdcl= plus>minus ? color.new(color.green,80) :plus<minus ? color.new(color.red,80) : na
cpm= pm>pm[1] ? color.lime : pm<pm[1] ? color.red : color.yellow
barcolor(cpm,title="PM Color")
//Plot
plot(ocsm ? semaf:emaf,"Fast Ema",color=color.green)
plot(ocsm ? semas:semas,"Slow Ema",color=color.red)
// Conditions
Long = (ocsd ? plus>minus:true) and (ocema ? (ocsm ? semaf:emaf)>(ocsm ? semas:emas):true)
Short = (ocsd ? plus<minus:true) and (ocema ? (ocsm ? semaf:emaf)<(ocsm ? semas:emas):true)
// Strategy conditions
if Long and times
strategy.close("Short","Close S")
strategy.entry("Long", strategy.long, comment="L",qty = initial_capital)
if strategy.position_size>0
strategy.exit("Long LTP", "Long", limit=take_profit, stop=stop_loss, comment="LSL",comment_profit = "LTP")
if Tr and strategy.position_size>0
strategy.exit("Long LTP", "Long", limit=take_profit, stop=pftpr, comment="Tr",comment_profit = "LTP")
if Short and times
strategy.close("Long","Close L")
strategy.entry("Short", strategy.short, comment="S",qty = initial_capital)
if strategy.position_size<0
strategy.exit("Short STP", "Short", limit=take_profit, stop=stop_loss, comment="SSL",comment_profit ="STP" )
if Tr and strategy.position_size<0
strategy.exit("Short STP", "Short", limit=take_profit, stop=pftpr, comment="Tr",comment_profit = "STP")
if not times
strategy.close_all()