다중 지표를 기반으로 한 디지털 화폐 양적 전략


생성 날짜: 2023-09-15 11:58:36 마지막으로 수정됨: 2023-09-15 11:58:36
복사: 1 클릭수: 717
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이 글은 디지털 화폐 디자인에 대한 다중 지표 수량화 거래 전략을 자세히 소개한다. 이 전략은 평균선, 진동기, 통로 등의 지표를 통합적으로 사용하여 진입 판단과 위험 통제를 한다.

1 전략

이 전략은 다음과 같은 지표들을 주로 적용합니다.

  1. ROC 진동기는 가격을 판단하는 오버 바이 오버 세일 범위를 나타냅니다.

  2. 동천 통로에서 역동적인 지지와 저항을 구축하는 것;

  3. 이 지표는 아래의 특징을 판단하는 지표입니다.

  4. 에너지 평형 지표는 빈 공간 경향을 판단합니다.

  5. 이동 평균은 트렌드 필터를 사용합니다.

여러 지표 신호가 일치할 때만 최종 입시 판단이 이루어집니다. 또한 단편 거래의 위험을 제어하기 위해 스톱-스트로스 포인트를 설정합니다.

2 전략적 장점

이 전략의 가장 큰 장점은 지표가 서로 보완되어 여러 차원에서 추세와 핵심 지점을 판단한다는 것입니다.

또 다른 장점은 바로 Stop Loss 설정이 합리적이고 적극적인 자금 관리에 도움이 된다는 것입니다.

마지막으로, 기수 공간은 넓고, 디지털 화폐에 대해 세밀하게 최적화 할 수 있습니다.

  1. 잠재적인 위험

그러나 이 전략에는 다음과 같은 문제점이 있습니다.

첫째, 다중 지표 조합은 파라미터를 최적화하는 데 어려움을 증가시킵니다.

두 번째, 지표들 사이에는 차이가 있을 수 있고, 명확한 판단 규칙이 필요하다.

마지막으로, 특정 품종에 대한 매개 변수 최적화가 필요합니다.

네 가지 내용

이 문서에서는 디지털 화폐 설계에 특화된 다중 지표량화 전략을 상세히 소개한다. 이 전략은 여러 지표를 합리적으로 사용하여 위험 제어 및 수익 관리한다. 이 전략은 변수 최적화를 통해 안정적인 수익을 얻을 수 있지만, 또한 제어 최적화의 어려움과 지표 사용 문제를 주의해야 한다.

전략 소스 코드
/*backtest
start: 2023-09-07 00:00:00
end: 2023-09-14 00:00:00
period: 4m
basePeriod: 1m
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/
// © mbagheri746

//@version=4
strategy("Bagheri IG Ether", overlay=true, margin_long=100, margin_short=100)

TP = input(3000, minval = 1 , title ="Take Profit")
SL = input(3443, minval = 1 , title ="Stop Loss")


//_________________ RoC Definition _________________


rocLength = input(title="ROC Length", type=input.integer, minval=1, defval=185)
smoothingLength = input(title="Smoothing Length", type=input.integer, minval=1, defval=49)
src = input(title="Source", type=input.source, defval=close)

ma = ema(src, smoothingLength)
mom = change(ma, rocLength)

sroc = nz(ma[rocLength]) == 0
     ? 100
     : mom == 0
         ? 0
         : 100 * mom / ma[rocLength]

//srocColor = sroc >= 0 ? #0ebb23 : color.red
//plot(sroc, title="SROC", linewidth=2, color=srocColor, transp=0)
//hline(0, title="Zero Level", linestyle=hline.style_dotted, color=#989898)


//_________________ Donchian Channel _________________

length1 = input(43, minval=1, title="Upper Channel")
length2 = input(43, minval=1, title="Lower Channel")
offset_bar = input(90,minval=0, title ="Offset Bars")

upper = highest(length1)
lower = lowest(length2)

basis = avg(upper, lower)


DC_UP_Band = upper[offset_bar]
DC_LW_Band = lower[offset_bar]

l = plot(DC_LW_Band, style=plot.style_line, linewidth=2, color=color.red)
u = plot(DC_UP_Band, style=plot.style_line, linewidth=2, color=color.aqua)

fill(l,u,color = color.new(color.aqua,transp = 90))

//_________________ Bears Power _________________


wmaBP_period = input(61,minval=1,title="BearsP WMA Period")
line_wma = ema(close, wmaBP_period)

BP = low - line_wma


//_________________ Balance of Power _________________

ES_BoP=input(15, title="BoP Exponential Smoothing")
BOP=(close - open) / (high - low)

SBOP = rma(BOP, ES_BoP)

//_________________ Alligator _________________

//_________________ CCI _________________

//_________________ Moving Average _________________

sma_period = input(74, minval = 1 , title = "SMA Period")
sma_shift = input(37, minval = 1 , title = "SMA Shift")

sma_primary = sma(close,sma_period)

SMA_sh = sma_primary[sma_shift]

plot(SMA_sh, style=plot.style_line, linewidth=2, color=color.yellow)

//_________________ Long Entry Conditions _________________//

MA_Lcnd = SMA_sh > low and SMA_sh < high

ROC_Lcnd = sroc < 0

DC_Lcnd = open < DC_LW_Band

BP_Lcnd = BP[1] < BP[0] and BP[1] < BP[2]

BOP_Lcnd = SBOP[1] < SBOP[0]

//_________________ Short Entry Conditions _________________//

MA_Scnd = SMA_sh > low and SMA_sh < high

ROC_Scnd = sroc > 0

DC_Scnd = open > DC_UP_Band

BP_Scnd = BP[1] > BP[0] and BP[1] > BP[2]

BOP_Scnd = SBOP[1] > SBOP[0]

//_________________ OPEN POSITION __________________//


strategy.entry(id = "BUY", long = true , when = MA_Lcnd and ROC_Lcnd and DC_Lcnd and BP_Lcnd and BOP_Lcnd)

strategy.entry(id = "SELL", long = false , when = MA_Scnd and ROC_Scnd and DC_Scnd and BP_Scnd and BOP_Scnd)

//_________________ CLOSE POSITION __________________//

strategy.exit(id = "CLOSE BUY", from_entry = "BUY", profit = TP , loss = SL)

strategy.exit(id = "CLOSE SELL", from_entry = "SELL" , profit = TP , loss = SL)


//_________________ TP and SL Plot __________________//

currentPL= strategy.openprofit
pos_price = strategy.position_avg_price
open_pos = strategy.position_size

TP_line = (strategy.position_size  > 0) ? (pos_price + TP/100) : strategy.position_size < 0 ? (pos_price - TP/100) : 0.0
SL_line = (strategy.position_size  > 0) ? (pos_price - SL/100) : strategy.position_size < 0 ? (pos_price + SL/100) : 0.0

// hline(TP_line, title = "Take Profit", color = color.green , linestyle = hline.style_dotted, editable = false)
// hline(SL_line, title = "Stop Loss", color = color.red , linestyle = hline.style_dotted, editable = false)


Tline = plot(TP_line != 0.0 ? TP_line : na , title="Take Profit", color=color.green, trackprice = true, show_last = 1)
Sline = plot(SL_line != 0.0 ? SL_line : na, title="Stop Loss", color=color.red, trackprice = true, show_last = 1)
Pline = plot(pos_price != 0.0 ? pos_price : na, title="Stop Loss", color=color.gray, trackprice = true, show_last = 1)


fill(Tline , Pline, color = color.new(color.green,transp = 90))
fill(Sline , Pline, color = color.new(color.red,transp = 90))



//_________________ Label __________________//


inMyPrice           = input(title="My Price", type=input.float, defval=0)
inLabelStyle        = input(title="Label Style", options=["Upper Right", "Lower Right"], defval="Lower Right")

posColor = color.new(color.green, 25)
negColor = color.new(color.red, 25)
dftColor = color.new(color.aqua, 25)
posPnL   = (strategy.position_size != 0) ? (close * 100 / strategy.position_avg_price - 100) : 0.0
posDir   = (strategy.position_size  > 0) ? "long" : strategy.position_size < 0 ? "short" : "flat"
posCol   = (posPnL > 0) ? posColor : (posPnL < 0) ? negColor : dftColor
myPnL    = (inMyPrice != 0) ? (close * 100 / inMyPrice - 100) : 0.0

var label lb = na
label.delete(lb)
lb := label.new(bar_index, close,
   color=posCol,
   style=inLabelStyle=="Lower Right"?label.style_label_upper_left:label.style_label_lower_left,
   text=
      "╔═══════╗" +"\n" + 
      "Pos: "  +posDir +"\n" +
      "Pos Price: "+tostring(strategy.position_avg_price) +"\n" +
      "Pos PnL: "  +tostring(posPnL, "0.00") + "%" +"\n" +
      "My Price: " +tostring(inMyPrice) +"\n" +
      "My PnL: "   +tostring(myPnL, "0.00") + "%" +"\n" +
      "╚═══════╝")