베가스 채널 크로스오버 전략

저자:차오장, 날짜: 2024-01-02 10:53:06
태그:

img

이 전략의 핵심 아이디어는 구매 및 판매 신호를 발행하기 위해 36, 143, 169와 같은 다른 주기로 EMA를 기반으로 주식의 단기, 중기 및 장기 트렌드 방향을 결정하는 것입니다. 구체적으로, 단기에는 5 및 10 일 EMA가 판단하기 위해 사용되며, 중기에는 20 및 60 일 EMA가 판단하기 위해 사용되며, 장기적으로는 120 및 250 일 EMA가 판단하기 위해 사용됩니다. 단기 EMA가 중기 EMA를 상향으로 넘으면 상승세를 보이고, 그렇지 않으면 하락세를 나타냅니다. 상승 및 하락 신호의 MACD 지표는 구매 및 판매 시간을 결정하는 데 사용됩니다.

베가스 터널 전략의 구체적인 메커니즘:

  1. EMA 36와 EMA 43를 사용하여 단기 트렌드 판단을 형성하십시오. 그들은 빨간 채널을 만듭니다.
  2. EMA 144과 EMA 169을 사용하여 중장기 트렌드 판단을 형성하십시오. 그들은 녹색 채널을 구성합니다.
  3. EMA576과 EMA676을 사용하여 장기 트렌드 판단을 형성하십시오. 그들은 회색 채널을 만듭니다.
  4. 가격이 위의 EMA 라인 위에 있을 때, MACD 지표가 0축을 깨고 상향으로 파는 신호로 결합하여, 긴 라인을 가집니다.
  5. 가격이 위의 EMA 라인 아래로 넘어갈 때, MACD 지표가 0축을 넘어서는 것과 함께 판매 신호로 짧게 이동합니다.
  6. EMA 라인 브루크에 따르면 각각 다른 보유 기간에 해당하는 단기, 중장기 및 장기 세 가지 전략이 정의됩니다.

이 전략의 장점:

  1. 트렌드 방향을 판단하기 위해 짧은, 중간 및 긴 세 개의 채널을 결합, 비교적 안정적;
  2. 베가스 터널은 트렌드를 결정하는 데 직관적입니다.
  3. MACD는 더 나은 구매 및 판매 시기를 파악하는 데 도움이 됩니다.
  4. 보다 유연한 운영을 위해 단기, 중장기, 세 가지 전략으로 나뉘어 있습니다.

주요 위험:

  1. 가격 변동이 심할 때, EMA 라인은 뒤떨어져 잘못된 판단을 할 가능성이 있습니다.
  2. 3개의 채널이 일치하지 않는 신호를 표시하면 잘못된 동작의 위험이 있습니다.
  3. 분기 차트 작업은 더 강한 심리적 견딜 능력이 필요합니다.

대처 방법:

  1. 현재 시장 특성에 더 잘 맞게 EMA 주기를 조정합니다.
  2. 단일 손실을 제한하기 위해 사전에 포지션 크기를 조정합니다.

최적화 공간:

  1. 베가스 터널의 트렌드 판단 능력은 개선되어야 합니다. 볼린거 대역이 추가될 수 있습니다.
  2. MACD는 옆 시장에서 잘 작동하지 않습니다. KD와 RSI와 같은 지표는 더 나은 옵션이 될 수 있습니다.
  3. 마감 가격이 주요 EMA 라인을 깨는 경우 마감 손실 정책과 같은 스톱 손실 정책을 추가합니다.
  4. A 주식 제한 및 하락이 더 큰 영향을 미치면 헤지하기 위한 짧은 ETF.

/*backtest
start: 2022-12-26 00:00:00
end: 2024-01-01 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4

strategy("Vegas Tunnel strategy", overlay=true)
//-------------------------------------------
//-------------------------------------------
// Inputs
useCurrentRes = input(true, title="Use Current Chart Resolution?")
resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=input.resolution, defval="D")
//tfSet = input(title = "Time Frame", options=["Current","120", "240", "D", "W"], defval="D")
tfSet = useCurrentRes ? timeframe.period : resCustom
maPeriods2 = input(12, "12 EMA")
maPeriods6 = input(240, "240 SMA")
BBlength = input(20, title="BB Length", minval=1)
BBsrc = input(close, title="BB Source")
mult = input(2.0, minval=0.001, maxval=50, title="BB StdDev")
sm2 = security(syminfo.tickerid, tfSet, ema(close, maPeriods2))
sm6 = security(syminfo.tickerid, tfSet, sma(close, maPeriods6))
p2 = plot(sm2, color=color.green, transp=30,  linewidth=2, title="SMA2")
p6 = plot(sm6, color=color.white, transp=30,  linewidth=2, title="SMA6")
//BB
basis = sma(BBsrc, BBlength)
dev = mult * stdev(BBsrc, BBlength)
upper = basis + dev
lower = basis - dev
offset = input(0, "BB Offset", type = input.integer, minval = -500, maxval = 500)
//plot(basis, "Basis", color=color.blue,linewidth, offset = offset)
pBB1 = plot(upper, "Upper", color=color.blue, offset = offset)
pBB2= plot(lower, "Lower", color=color.blue, offset = offset)

//MACD
fast_ma = ema(close, 48)
slow_ma = ema(close, 56)
macd = fast_ma - slow_ma

//vagas隧道
f1=ema(close, 36)
f2=ema(close, 43)
f3=ema(close, 144)
f4=ema(close, 169)
f5=ema(close, 576)
f6=ema(close, 676)
f7=ema(close,2304)
z1=plot(f1,color=color.red, title="ema36",transp=100)
z2=plot(f2,color=color.red, title="ema43",transp=100)
z3=plot(f3,color=color.green, title="ema144",transp=100)
z4=plot(f4,color=color.green, title="ema169",transp=100)
z5=plot(f5,color=color.white, title="ema576",transp=100)
z6=plot(f6,color=color.white, title="ema676",transp=100)
fill(z1, z2, color=color.red,transp=60)
fill(z3, z4, color=color.green,transp=60)
fill(z5, z6, color=color.gray,transp=60)

// Make input options that configure backtest date range
startDate = input(title="Start Date", type=input.integer,
     defval=1, minval=1, maxval=31)
startMonth = input(title="Start Month", type=input.integer,
     defval=1, minval=1, maxval=12)
startYear = input(title="Start Year", type=input.integer,
     defval=2018, minval=1800, maxval=2100)
endDate = input(title="End Date", type=input.integer,
     defval=1, minval=1, maxval=31)
endMonth = input(title="End Month", type=input.integer,
     defval=11, minval=1, maxval=12)
endYear = input(title="End Year", type=input.integer,
     defval=2030, minval=1800, maxval=2100)
// Look if the close time of the current bar
// falls inside the date range
inDateRange =  true

//波段多
if (inDateRange and crossunder(f3,f1))// 
    strategy.entry("buy", strategy.long,1, when=macd>0, comment = "買Long-term")
buyclose=crossunder(f3,f5) 
strategy.close("buy", when = buyclose, comment = "關Long-term")
//多策略1
if (inDateRange and crossover(low , f3) and macd>0 and f3>f6)
    strategy.entry("buy1", strategy.long,100, comment = "買Mid-term")
buyclose1=crossunder(close,upper*0.999) 
if (macd<0 or f3<f6)
    strategy.close("buy1", comment = "關Mid-term")
//strategy.close("buy1",when=cross(basis,close), comment = "關M",qty_percent=50)
strategy.close("buy1", when = buyclose1, comment = "關Mid-term",qty_percent=100)
//多策略3
if (inDateRange and  (macd>0) and crossunder(low,f1) and f1>f4) // 
    strategy.entry("buy3", strategy.long,1, comment = "買Short-term")
buyclose3=crossunder(close,upper*0.999)
if (macd<0 or f1<f4)
    strategy.close("buy3", comment = "關Short-term")
strategy.close("buy3", when = buyclose3, comment = "關Short-term")
//多策略4
if (inDateRange and  (macd>0) and crossunder(low,f5) and f4>f5) // 
    strategy.entry("buy4", strategy.long,1, comment = "買Long-term")
buyclose4=crossunder(close,upper*0.999)
if (macd<0 or f4<f6)
    strategy.close("buy4", comment = "關Long-term")
strategy.close("buy4", when = buyclose4, comment = "關Long-term")
    
//空策略1
if (inDateRange and  (macd<0) and crossunder(high,f1) and f1<f3 and f3<f6) // 
    strategy.entry("sell1", strategy.short,1, comment = "空Short-term")
sellclose1=crossunder(lower*0.999,close)
if (macd>0 or f1>f4)
    strategy.close("sell1", comment = "關空Short-term")
strategy.close("sell1", when = sellclose1, comment = "關空Short-term")
//空策略2
if (inDateRange and  (macd<0) and crossunder(high,f4) and f4<f6) // 
    strategy.entry("sell2", strategy.short,1, comment = "空Mid-term")
sellclose2=crossunder(lower,close)
if (macd>0 or f4>f6)
    strategy.close("sell2", comment = "關空Mid-term")
strategy.close("sell2", when = sellclose2, comment = "關Mid-term")
//空策略3
if (inDateRange and (macd<0) and crossunder(high,f6)) // 
    strategy.entry("sell3", strategy.short,1, comment = "空Long-term")
sellclose3=crossunder(lower,close)
if (macd>0 or f6>f7)
    strategy.close("sell3", comment = "關空Long-term")
strategy.close("sell3", when = sellclose3, comment = "關空Long-term")

더 많은