통합된 멀티 전략 양적 거래 시스템

저자:차오장날짜: 2023-09-15 12:29:33
태그:

이 기사에서는 암호화폐에 대한 종합 다전 전략 양적 거래 시스템이라는 양적 거래 전략을 소개합니다. 이 전략은 더 높은 안정성과 다양성을 달성하는 것을 목표로 여러 가지 전략의 포트폴리오를 구축하기 위해 여러 단일 전략의 장점을 통합합니다.

이 전략은 네 가지 일반적인 양적 거래 전략을 포함합니다.

  1. 채널 브레이크 전략: 일정 기간 동안 가장 높고 가장 낮은 가격을 기반으로 상위 및 하위 채널을 구축하고 가격이 채널을 벗어날 때 포지션을 취합니다.

  2. 동력 전략: 특정 기간 동안의 가격 변화에 따라 동력을 결정합니다. 가격이 가속 상승할 때 장거리, 가격이 가속 하락할 때 단거리입니다.

  3. MACD 전략: MACD 골든 크로스와 데드 크로스를 기반으로 긴 위치와 짧은 위치를 결정합니다.

  4. 하라미 패턴 전략: 특정 촛불 패턴을 인식하고 전환점을 중심으로 거래함으로써 잠재적 인 미래 반전을 식별합니다.

이 전략들은 각각 장점이 있습니다. 함께 결합하면 더 안정적인 수익을 얻을 수 있습니다. 구체적으로:

채널 브레이크업 전략은 시장 트렌드를 파악할 수 있고, 모멘텀 전략은 단기 트렌드를 적시에 추적할 수 있고, MACD 전략은 중기 트렌드 반전을 발견할 수 있으며, 하라미 전략은 주요 반전 지점을 결정할 수 있다.

이 모든 것을 하나의 전략으로 통합하면 트렌드 시장에서 상승과 하락을 추격하고 전환점을 중심으로 역전 포지션을 열 수 있습니다. 한편으로 다른 전략은 또한 위험 다양화를 달성 할 수 있습니다.

물론 이러한 다중 전략 조합은 몇 가지 단점도 있습니다.

  1. 전략은 너무 복잡하고 매개 변수를 조정하기가 어렵습니다.

  2. 어떤 전략들 사이에는 충돌이 있을 수 있습니다.

  3. 거래 빈도와 거래 비용을 증가시킵니다.

  4. 백테스트 결과는 단일 전략보다 더 나빠질 수 있습니다.

따라서 이 다중 전략 조합을 사용할 때 사용자는 매개 변수 조정의 어려움에 주의를 기울이고 충돌 간의 상호 작용을 테스트하고 거래 빈도를 제어하고 장기 안정성을 보장하기 위해 충분한 백테스팅을 수행해야합니다.

일반적으로,이 통합된 다중 전략 양적 거래 시스템은 매우 풍부한 거래 조합을 얻을 수 있으며 주요 트렌드에서 매우 잘 수행합니다. 그것은 다른 전략의 장점을 결합하고 더 안정적인 장기적 긍정적 인 수익을 얻을 수 있습니다. 강력한 양적 전략 포트폴리오를 개발하기 위해 사용자에게 더 많은 연구와 최적화가 필요합니다.


/*backtest
start: 2023-09-07 00:00:00
end: 2023-09-14 00:00:00
period: 45m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3

//Channel breakout
strategy("all_strategy", overlay=true)

length = input(title="Length", minval=1, maxval=1000, defval=5)

upBound = highest(high, length)
downBound = lowest(low, length)

if (not na(close[length]))
    strategy.entry("ChBrkLE", strategy.long, stop=upBound + syminfo.mintick, comment="ChBrkLE")
    strategy.entry("ChBrkSE", strategy.short, stop=downBound - syminfo.mintick, comment="ChBrkSE")

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)


//Momentum
length1 = input(12)
price = close

momentum(seria, length) =>
    mom = seria - seria[length1]
    mom

mom0 = momentum(price, length1)
mom1 = momentum( mom0, 1)

if (mom0 > 0 and mom1 > 0)
    strategy.entry("MomLE", strategy.long, stop=high+syminfo.mintick, comment="MomLE")
else
    strategy.cancel("MomLE")

if (mom0 < 0 and mom1 < 0)
    strategy.entry("MomSE", strategy.short, stop=low-syminfo.mintick, comment="MomSE")
else
    strategy.cancel("MomSE")

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)


//MACD Strategy
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)

MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD

if (crossover(delta, 0))
    strategy.entry("MacdLE", strategy.long, comment="MacdLE")

if (crossunder(delta, 0))
    strategy.entry("MacdSE", strategy.short, comment="MacdSE")

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)


//Harami

pctDw = input(60,minval=0,maxval=90,title="Doji, Min % of Range of Candle for Wicks")
pipMin= input(0,minval=0,title="Doji, Previous Candle Min Pip Body Size")
sname=input(true,title="Show Price Action Bar Names")
cbar = input(false,title="Highlight Harami & Doji Bars")
sHm    = input(false,title="Show Only Harami Style Doji's")
setalm = input(true, title="Generate Alert for Harami & Doji Bars")
uha   =input(true, title="Use Heikin Ashi Candles for Calculations")
bars = input(3,minval=1,maxval=3,step=1, title="Doji, Number of Lookback Bars")
//
// Use only Heikinashi Candles for all calculations
srcclose = uha ? security(heikinashi(syminfo.tickerid), timeframe.period, close) : close
srcopen = uha ? security(heikinashi(syminfo.tickerid), timeframe.period, open) : open
srchigh = uha ? security(heikinashi(syminfo.tickerid), timeframe.period, high) : high
srclow = uha ?security(heikinashi(syminfo.tickerid), timeframe.period, low) : low

//
pip = syminfo.mintick
range = srchigh - srclow


// Calculate Doji/Harami Candles
pctCDw = (pctDw/2) * 0.01
pctCDb = (100-pctDw) * 0.01

//Lookback Candles for bulls or bears
lbBull = bars==1? srcopen[1]>srcclose[1]: bars==2? (srcopen[1]>srcclose[1] and srcopen[2]>srcclose[2]): bars==3?(srcopen[1]>srcclose[1] and srcopen[2]>srcclose[2] and srcopen[3]>srcclose[3]):false
lbBear = bars==1? srcopen[1]<srcclose[1]: bars==2? (srcopen[1]<srcclose[1] and srcopen[2]<srcclose[2]): bars==3?(srcopen[1]<srcclose[1] and srcopen[2]<srcclose[2] and srcopen[3]<srcclose[3]):false

//Lookback Candle Size only if mininum size is > 0
lbSize = pipMin==0? true : bars==1 ? (abs(srcopen[1]-srcclose[1])>pipMin*pip) :
  bars==2 ? (abs(srcopen[1]-srcclose[1])>pipMin*pip and abs(srcopen[2]-srcclose[2])>pipMin*pip) :
  bars==3 ? (abs(srcopen[1]-srcclose[1])>pipMin*pip and abs(srcopen[2]-srcclose[2])>pipMin*pip and abs(srcopen[3]-srcclose[3])>pipMin*pip) :
  false

dojiBu = (srcopen[1] >= max(srcclose,srcopen) and srcclose[1]<=min(srcclose,srcopen)) and lbSize and
  (abs(srcclose-srcopen)<range*pctCDb and (srchigh-max(srcclose,srcopen))>(pctCDw*range) and (min(srcclose,srcopen)-srclow)>(pctCDw*range))? 1 : 0

dojiBe = (srcclose[1] >= max(srcclose,srcopen) and srcopen[1]<=min(srcclose,srcopen)) and lbSize and
  (abs(srcclose-srcopen)<range*pctCDb and (srchigh-max(srcclose,srcopen))>(pctCDw*range) and (min(srcclose,srcopen)-srclow)>(pctCDw*range))? 1 : 0
  
haramiBull = (srcopen<=srcclose or (max(srcclose,srcopen)-min(srcclose,srcopen))<pip*0.5) and lbBull and dojiBu
haramiBear = (srcopen>=srcclose or (max(srcclose,srcopen)-min(srcclose,srcopen))<pip*0.5) and lbBear and dojiBe

dojiBull = not sHm and not haramiBull and not haramiBear and lbBull and dojiBu
dojiBear = not sHm and not haramiBull and not haramiBear and lbBear and dojiBe

//
plotshape(haramiBear and sname?srchigh:na,title="Bearish Harami",text='Bearish\nHarami',color=red, style=shape.arrowdown,location=location.abovebar)
plotshape(haramiBear and cbar?max(srcopen,srcclose):na,title="Bear Colour Harami",color=red, style=shape.circle,location=location.absolute,size=size.normal)
//
plotshape(haramiBull and sname?srclow:na,title="Bullish Harami",text='Bullish\nHarami',color=green, style=shape.arrowup,location=location.belowbar)
plotshape(haramiBull and cbar?max(srcopen,srcclose):na,title="Bull Colour Harami",color=green, style=shape.circle,location=location.absolute,size=size.normal)
//
plotshape(dojiBear and sname?srchigh:na,title="Bearish Doji",text='Bearish\nDoji',color=fuchsia, style=shape.arrowdown,location=location.abovebar)
plotshape(dojiBear and cbar?max(srcopen,srcclose):na,title="Bear Colour Doji",color=fuchsia, style=shape.circle,location=location.absolute,size=size.normal)
//
plotshape(dojiBull and sname?srclow:na,title="Bullish Doji",text='Bullish\nDoji',color=aqua, style=shape.arrowup,location=location.belowbar)
plotshape(dojiBull and cbar?max(srcopen,srcclose):na,title="Bull Colour Doji",color=aqua, style=shape.circle,location=location.absolute,size=size.normal)

// Only Alert harami Doji's
bcolor = haramiBull ? 1 : haramiBear ? 2 : dojiBull ? 3 : dojiBear ? 4 : 0
baralert = setalm and bcolor>0
alertcondition(baralert,title="PACDOJI Alert",message="PACDOJI Alert")

//
plotshape(na(baralert[1])?na:baralert[1], transp=0,style=shape.circle,location=location.bottom, offset=-1,title="Bar Alert Confirmed", 
  color=bcolor[1]==1 ? green : bcolor[1]==2? red : bcolor[1]==3? aqua : bcolor[1]==4? fuchsia : na)

//EOF

더 많은