마감 브레이크아웃 데이 트레이딩 전략


생성 날짜: 2023-10-09 16:56:21 마지막으로 수정됨: 2023-10-09 16:56:21
복사: 0 클릭수: 641
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

이 전략은 이동 평균에 기반한 간단한 일일 거래 전략으로, GBPUSD 1시간 시간 사이클 차트에 적용된다. 런던 상장시만 입시하고 런던 상장시만 상장하며, 런던 시간대에 트렌드 브레이크 거래에 적합하다.

전략 원칙

이 전략은 두 개의 이동 평균선을 사용한다. 하나는 매우 빠른 평균선이고 하나는 매우 느린 평균선이다. 구체적인 논리는 다음과 같다:

  1. 런던 개시시 (8시) 에만 돌파구가 진입한다. 판단 방식은 종전 가격 또는 최고 가격 돌파구 급속 평균선을 하면 더할 수 있고, 종전 가격 또는 최저 가격 돌파구 급속 평균선을 하면 공백할 수 있다.

  2. 동시에, 이전 K 선의 종결값이 느린 평균보다 높을 수 있도록 요구하고, 느린 평균보다 낮을 수 있도록 공백을 요구하여 비 트렌드 상황을 필터링한다.

  3. 스톱패스는 최소로 설정되어 있습니다. 50-100점입니다.

  4. 스톱을 설정하지 않고, 런던이 종료될 때 (15시) 무조건 출전한다.

우위 분석

이것은 매우 간단한 돌파구 전략이지만, 런던 시기의 트렌드 특성을 합리적으로 활용하기 때문에 다음과 같은 장점이 있습니다:

  1. 트렌드가 확실할 때만 입점하면, 흔들리는 시장의 위험을 피할 수 있다.

  2. 런던 시간대에만 거래가 이루어지면서, 이 시간대의 변동성이 큰 특징을 최대한 활용했다.

  3. 작은 스톱으로, 어느 정도의 반발을 견딜 수 있다.

  4. 하지만, 이 경기에 출전할 수 있는 조건은 없습니다.

위험 분석

이 전략에는 몇 가지 위험도 있습니다.

  1. 런던 시간대에 명확한 추세가 없을 때, 오랫동안 거래가 없을 수도 있습니다.

  2. 소손실으로 인한 상쇄손실 위험. 돌파구 이후 상쇄손실으로 인한 반발이 있을 수 있다.

  3. 고정 퇴출 시간으로 인한 조기 퇴출 위험. 강한 추세에서는 지분 기간을 연장해야 할 수 있다.

대책은 출전 규칙을 적절히 완화하고, 이동적 손실을 사용하여 수익을 잠금하고, 시장 상황에 따라 출전 시간을 적절히 조정할 수 있습니다.

최적화 방향

이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.

  1. RSI, 브린 띠 등과 같은 다른 지표 필터링을 추가하여 흔들리는 시장을 더 피하십시오.

  2. 이동평등선 조합을 최적화하고, 다른 변수들의 평평선 효과를 테스트한다.

  3. 다양한 스톱 포인트 크기를 테스트하여 최적의 스톱 범위를 찾습니다.

  4. 경기 종료 시점에 고정된 것이 아니라, 실제 상황에 따라 출발 시간을 조정한다.

  5. 다른 통화 쌍과 다른 시간 주기의 효과를 테스트하십시오.

  6. 위험 관리 모듈을 추가합니다. 예를 들어, 자금 관리, 거래 크기 계산 등등.

요약하다

이 전략은 전체적으로 매우 간단하고 실용적인 런던 시간대를 뚫는 전략이다. 장점은 규칙이 간단하고 명확하다는 점이며, 시간대를 합리적으로 사용하여 거래 위험을 피할 수 있다는 점이다. 또한, 최적화 가능한 공간이 있으며, 테스트를 계속하면 전략의 안정성과 수익성을 더욱 향상시킬 수 있다.

전략 소스 코드
/*backtest
start: 2023-09-08 00:00:00
end: 2023-10-08 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4

// strategy(title="2 ma breakout",shorttitle="2 ma breakout", initial_capital=10000,overlay=true, commission_type = strategy.commission.cash_per_contract, commission_value = 0.00008 )
timeinrange(res, sess) => time(res, sess) != 0

//Change false to false = You have to turn on, won't show up by default
//****Always use lowercase letters

doNYOpen = input(defval=false, type = input.bool, title="NY Open On")
doNYSession = input(defval=false, type = input.bool, title="NY Session On")
doNYClose = input(defval=false, type = input.bool, title="NY Close On")

doAussieOpen = input(defval=false, type = input.bool, title="Aussie Open On")
doAussieSession = input(defval=false, type = input.bool, title="Aussie Session On")
doAussieClose = input(defval=false, type = input.bool, title="Aussie Close On")

doAsiaOpen = input(defval=false, type = input.bool, title="Asia Open On")
doAsiaSession = input(defval=false, type = input.bool, title="Asia Session On")
doAsiaClose = input(defval=false, type = input.bool, title="Asia Close On")

doEurOpen = input(defval=true, type = input.bool, title="Euro Open On")
doEurSession = input(defval=true, type = input.bool, title="Euro Session On")
doEurClose = input(defval=true, type = input.bool, title="Euro Close On")

//You can copy and paste these colors. white - silver - gray - maroon - red - purple - fuchsia - green - lime
//   olive - yellow - navy - blue - teal - aqua - orange 

nySessionStart = color.olive
nySession = color.olive
nySessionEnd = color.olive
asiaSessionStart = color.blue
asiaSession = color.blue
asiaSessionEnd = color.blue
europeSessionStart = color.red
europeSession = color.red
europeSessionEnd = color.red
colorwhite = color.white

//****Note ---- Use Military Times --- So 3:00PM = 1500


bgcolor(doAsiaSession and timeinrange(timeframe.period, "1800-0400") ? asiaSession : na, transp=75)
//bgcolor(timeinrange(timeframe.period, "0000-0300") ? color.white  : na, transp=75)
bgcolor(doEurSession and timeinrange(timeframe.period, "0300-1100") ? europeSession : na, transp=75)
bgcolor(doNYSession and timeinrange(timeframe.period, "0800-1600") ? nySession : na, transp=75)

active = input(true, title="Show On Chart")
pricehigh = security(syminfo.tickerid, '60', high[0])
pricelow = security(syminfo.tickerid, '60', low[0])
//Daily Plots
offs_daily = 0 
hiHighs = 0
loLows = 0
//plot(timeinrange(timeframe.period, "0000-0300") and pricehigh ? pricehigh  : na, title="Previous Daily High", style=plot.style_line, linewidth=2, color=color.gray)
//plot(timeinrange(timeframe.period, "0000-0300") and pricelow ? pricelow : na, title="Previous Daily Low", style=plot.style_linebr, linewidth=2, color=color.gray)

if(timeinrange(timeframe.period, "0000-0300"))
    hiHighs = highest(high, 3)
    loLows = lowest(low, 3)
    

// From Date Inputs
fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
fromYear = input(defval = 2020, title = "From Year", minval = 1970)
 
// To Date Inputs
toDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)
toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
toYear = input(defval = 2020, title = "To Year", minval = 1970)
 
// Calculate start/end date and time condition
startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond = true


len = input(2)
src = input(close, title="Source")
out = sma(src, len)

lena = input(200, minval=1, title="Length slow")
srca = input(close, title="Source")
outa = ema(srca, lena)

//tp = input(100, title="tp")
sl = input(66, title="sl")
// if(smabool)
//     out := sma(src, len)
// else if(emabool)
//     out := ema(src, len)
// else if(hmabool)
//     out := hma(src, len)
// else if(vmabool)
//     out := wma(src, len)  
// else if(vwmabool)
//     out := vwma(src, len)   
// else if(smmabool)
//     out := sma(src, len)  
 
plot(out, color=color.white, title="MA")
plot(outa, color=color.white, title="MA")

longC = timeinrange(timeframe.period, "0300-0400") and (crossover(close,out) or crossover(high,out)) and close[1] > outa and time_cond
shortC = timeinrange(timeframe.period, "0300-0400") and (crossunder(close,out) or crossunder(low,out)) and close[1] < outa and time_cond



//inputlondon = input(false, title="london session")
//inputny = input(false, title="new york session")

//if(inputlondon==true)

strategy.initial_capital = 50000

//MONEY MANAGEMENT--------------------------------------------------------------
balance = strategy.netprofit + strategy.initial_capital //current balance
floating = strategy.openprofit          //floating profit/loss
risk = input(1,type=input.float,title="Risk % of equity ")/100           //risk % per trade

temp01 = balance * risk     //Risk in USD
temp02 = temp01/sl        //Risk in lots
temp03 = temp02*100      //Convert to contracts
size = temp03 - temp03%1 //Normalize to 1000s (Trade size)
if(size < 1)
    size := 1         //Set min. lot size


strategy.entry("long",1,when=longC)
//strategy.close("long", when = crossunder(close,out) or not (timeinrange(timeframe.period, "0300-1000")))
strategy.close("long", when =  not (timeinrange(timeframe.period, "0300-0945")))
strategy.exit("x_long","long", loss = sl)
     
    
strategy.entry("short",0,when=shortC)
//strategy.close("short",when = crossover(close,out) or not (timeinrange(timeframe.period, "0300-1000")))
strategy.close("short",when = not (timeinrange(timeframe.period, "0300-0945")))

strategy.exit("x_short","short", loss = sl)

//strategy.exit("closelong", "RSI_BB_LONG" , profit = close * 0.01 / syminfo.mintick, loss = close * 0.01 / syminfo.mintick, alert_message = "closelong")
//strategy.exit("closeshort", "RSI_BB_SHORT" , profit = close * 0.01 / syminfo.mintick, loss = close * 0.01 / syminfo.mintick, alert_message = "closeshort")