브레이크데이 거래 전략

저자:차오장, 날짜: 2023-10-09 16:56:21
태그:

전반적인 설명

이것은 이동 평균에 기반한 간단한 일일 거래 전략으로 GBPUSD 1시간 시간 프레임에 적합합니다. 런던 오픈에서만 입력하고 런던 클로즈에서 종료하여 런던 세션 중 트렌드 브레이크 트레이딩에 이상적입니다.

전략 논리

이 전략은 두 개의 이동 평균을 사용합니다. 하나는 매우 빠르고 하나는 매우 느립니다. 논리는 다음과 같습니다.

  1. 가격이 빠른 MA를 깨는 경우에만 런던 오픈 (8AM) 에 진입합니다. 닫거나 높은 것이 빠른 MA를 넘어서면 장거리, 닫거나 낮은 것이 빠른 MA를 넘어서면 단거리입니다.

  2. 이전 바가 긴 경우 느린 MA보다 높고 짧은 경우 느린 MA보다 낮아야 트렌드가 아닌 움직임을 필터링 할 수 있습니다.

  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")



더 많은