Chiến lược giao dịch ngày đột phá

Tác giả:ChaoZhang, Ngày: 2023-10-09 16:56:21
Tags:

Tổng quan

Đây là một chiến lược giao dịch ngày đơn giản dựa trên đường trung bình động, phù hợp với khung thời gian 1 giờ GBPUSD. Nó chỉ đi vào mở tại London và ra vào đóng tại London, làm cho nó lý tưởng cho giao dịch đột phá xu hướng trong phiên London.

Chiến lược logic

Chiến lược sử dụng hai đường trung bình động, một rất nhanh và một rất chậm.

  1. Chỉ tham gia tại London mở (8 AM) khi giá phá vỡ MA nhanh. Đi dài nếu đóng hoặc cao phá vỡ trên MA nhanh, đi ngắn nếu đóng hoặc thấp phá vỡ dưới MA nhanh.

  2. Yêu cầu các thanh gần trước đó ở trên MA chậm trong thời gian dài, dưới MA chậm trong thời gian ngắn, để lọc các động thái không theo xu hướng.

  3. Sử dụng một mức dừng lỗ rất nhỏ là 50-100 điểm.

  4. Không có lợi nhuận, ra ngoài vô điều kiện tại London đóng cửa (15:00).

Phân tích lợi thế

Đây là một chiến lược đột phá rất đơn giản, nhưng bằng cách sử dụng đúng các đặc điểm xu hướng phiên London, nó có những lợi thế sau:

  1. Chỉ đi vào xu hướng rõ ràng, tránh rủi ro thị trường hỗn loạn.

  2. Giao dịch chỉ phá vỡ trong thời gian biến động cao ở London.

  3. Stop loss nhỏ có thể chịu được một số sự rút lui.

  4. Rời khỏi không có điều kiện tránh được rủi ro qua đêm.

Phân tích rủi ro

Chiến lược này cũng có một số rủi ro:

  1. Có thể giữ nguyên trong thời gian dài khi London không có xu hướng rõ ràng.

  2. Cấm rủi ro bị dừng lại trên các retraces.

  3. Rủi ro thoát sớm khi xu hướng mạnh đòi hỏi thời gian giữ kéo dài.

Các biện pháp giảm thiểu bao gồm mở rộng các quy tắc nhập cảnh, sử dụng các điểm dừng để khóa lợi nhuận và điều chỉnh thời gian ra đi dựa trên điều kiện thị trường.

Hướng dẫn tối ưu hóa

Chiến lược có thể được cải thiện trong một số lĩnh vực:

  1. Thêm các bộ lọc khác như RSI, Bollinger Bands để tránh tiếp tục thị trường hỗn loạn.

  2. Tối ưu hóa các kết hợp trung bình động bằng cách thử nghiệm các thông số khác nhau.

  3. Kiểm tra kích thước stop loss khác nhau để tìm phạm vi tối ưu.

  4. Điều chỉnh thời gian thoát động dựa trên hành động giá thay vì thời gian cố định.

  5. Kiểm tra các cặp tiền tệ và khung thời gian khác.

  6. Thêm quản lý rủi ro như kích thước vị trí dựa trên kích thước tài khoản.

Tóm lại

Nói chung, đây là một chiến lược đột phá phiên London rất đơn giản và thực tế. Nó có lợi từ việc tránh một số rủi ro giao dịch bằng cách sử dụng đúng các đặc điểm của phiên. Ngoài ra còn có các lĩnh vực để tối ưu hóa hơn nữa để cải thiện độ bền và lợi nhuận. Chiến lược cung cấp một khuôn khổ và mẫu hữu ích để giao dịch hiệu quả các phiên đột phá London.


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



Thêm nữa