
이 전략은 Donchian 통로 기반의 해파리 거래 전략이라고 불린다. 이 전략은 유명한 해파리 거래법칙의 주요 아이디어를 빌려 Donchian 통로를 통해 시장 추세를 판단하고 이동 평균과 결합하여 필터링하여 비교적 간단한 추세 추적 전략을 구현한다.
이 전략의 주요 판단 지표는 Donchian channel이다. Donchian channel은 최고 가격과 최저 가격의 N 일 내의 변동 범위로 구성되어 있으며, 가격이 채널 상도를 돌파하면 긴 신호이며, 채널 하도를 돌파하면 짧은 신호이다. 이 전략은 빠른 Donchian channel을 사용하여 신호를 발산하고, 느린 Donchian channel을 사용하여 손실을 막는다.
또한, 이 전략은 두 개의 이동 평균 ((50 일선 및 125 일선) 을 도입하여 신호를 필터링합니다. 빠른 이동 평균 상에서 느린 이동 평균을 통과 할 때만 다중 거래가 이루어집니다. 빠른 이동 평균 아래에서 느린 이동 평균을 통과 할 때 공백 거래가 이루어집니다. 이것은 일부 가짜 신호를 효과적으로 필터링 할 수 있습니다.
이 전략의 개시 조건은: 가격이 돈치안 채널을 상회하여 상회하고, 빠른 이동 평균을 상회하여 느린 이동 평균을 상회하면 이 두 조건을 충족하기 전에 다중 주문을 열 수 있습니다. 가격이 돈치안 채널을 상회하여 하향으로 이동하고, 빠른 이동 평균을 하향으로 느린 이동 평균을 상회하면 공명 주문을 열 수 있습니다. 평점 조건은 가격이 반대 방향으로 느린 돈치안 채널의 경계와 접촉하는 것입니다.
이 전략은 다음과 같은 장점을 가지고 있습니다.
Donchian channel를 사용하여 트렌드 방향을 판단하고, 큰 트렌드를 잡는 데 성공하는 데 성공합니다.
이동 평균의 필터를 추가하여 일부 가짜 신호를 필터링하여 손실을 방지할 수 있습니다.
빠른 느린 Donchian 채널과 빠른 느린 이동 평균의 조합을 사용하여 거래 빈도와 중지 손실의 정확성을 균형을 잡을 수 있습니다.
리스크가 통제되고, 단독 손실을 통제하기 위한 스톱 로즈 메커니즘이 있습니다.
이 전략에는 몇 가지 위험도 있습니다.
“이런 상황에서는 더 적은 손실이 발생할 수 있습니다.
이동 평균의 필터링은 트렌드가 변할 때 창고 건설 비용을 증가시킵니다.
의 경우, 상쇄 손실이 발생할 수 있습니다.
대책과 해결책:
Donchian 주기를 줄이고, 이동 평균 주기를 줄여서 다른 시장에 적응할 수 있도록 파라미터를 적절히 조정할 수 있다.
큰 규모의 추세에 대한 판단을 높이고, 반대의 추세에 대한 입장을 피한다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
파격 강도에 대한 판단을 높이는 것. 예를 들어, 거래량을 도입하고 거래량이 커질 때만 포즈를 열 수 있습니다.
핫 지점에 대한 판단을 높여라. 지지부진, 파도, 패턴과 같은 가격 핫 지점을 판단하고, 핫 지점의 창고를 피한다.
손해 중지 전략을 최적화한다. 추적 손해, 진폭 손해, 시간 손해 등을 도입하여 손해를 더욱 지능화 할 수 있다.
이 전략은 전반적으로 매우 전형적이고 간단한 트렌드 추적 전략이다. Donchian 채널 판단 방향, 이동 평균 필터 신호를 통해, 좋은 재측량 효과를 달성한다. 이 전략은 큰 트렌드를 추격하는 투자자에게 적합하며, 위험은 통제되어 있으며, 실내에서 쉽게 작동한다. 일부 매개 변수와 규칙을 최적화하면 전략의 승률과 수익성을 더욱 향상시킬 수 있다.
/*backtest
start: 2023-11-24 00:00:00
end: 2023-12-24 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
// Coded by Vladkos
strategy("Donchian strategy with filter", overlay=true,default_qty_type = strategy.percent_of_equity, default_qty_value = 4,pyramiding=5)
fromyear = input(2017, defval = 2018, minval = 1800, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(21, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
term = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59))
ATR=input(20,minval=1)
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
needstoploss= input(true,defval=true,title="Stop LOSS")
///////////ATR
tra=atr(ATR)
////////////Переменные
Donchian_slow=input(20,minval=1)
Donchian_fast=input(10,minval=1)
Slow_EMA=input(125,minval=1)
Fast_EMA=input(50,minval=1)
/////////// Медленный Дончан
lower = lowest(Donchian_slow)
upper = highest(Donchian_slow)
basis = avg(upper, lower)
plot(lower,color=blue)
plot(upper,color=blue)
/////////// быстрый Дончан
lowerF = lowest(Donchian_fast)
upperF = highest(Donchian_fast)
basisF = avg(upperF, lowerF)
plot(lowerF,color=red)
plot(upperF,color=red)
////////// Скользящие средние
ema_S=ema(close,Slow_EMA)
ema_F=ema(close,Fast_EMA)
plot(ema_S,color=red)
plot(ema_F,color=green)
///////// Условия сделок
long_condition= close>=upper[1] and ema_F>ema_S
long_exit= close<lowerF[1]
short_condition=close<=lower[1] and ema_F<ema_S
short_exit=close>upperF[1]
////////// Отправка ордеров
strategy.entry("Long",strategy.long,when=long_condition and term and needlong==true)
strategy.exit("stop loss","Long",stop=strategy.position_avg_price-(tra*2),when= (needstoploss==true))
strategy.close("Long",when=long_exit and (time < timestamp(toyear, tomonth, today, 23, 59)))
strategy.entry("Short",strategy.short,when=short_condition and term and (needshort==true))
strategy.exit("stoploss","Short",stop=strategy.position_avg_price+(tra*2),when= (needstoploss==true))
strategy.close("Short",when=short_exit and (time < timestamp(toyear, tomonth, today, 23, 59)))
if time > timestamp(toyear, tomonth, today, 23, 59)
strategy.close_all()