Tìm cơ hội cược BO với Trend line

Tìm cơ hội cược BO với Trend line

Tìm cơ hội cược BO với Trend line
@vĩnh0902 còn 1 lệnh nữa là code tự take profit :)
Vĩnh muốn chạy tiếp thì có thể chỉnh thời gian cho số lệnh về 0 hoặc tăng số take profit trong phần cài đặt, mình ko có nhà nên để mặc định :)
IMG_20200320_121627.jpg
 
cả 3 lệnh đều co 1 cay siêu to :) đỡ đau tim
Nếu macro chạy theo level bằng click thì độ trễ cao quá, mình tính cuối tuần thay bằng lệnh nhập vốn, mình tính sẵn vốn cho mỗi level, ở level nào thì macro vẫn chỉ click 1 cái, chỉ thêm thao tác nhập vốn vào, ko biết độ trễ có ngắn hơn ko nữa, trước mắt mình tạm xử lý bằng cách ngắt nhỏ chuỗi lặp ra, sau 15' thì macro trừ lại 8 giây, đó là chưa kể mấy cái level cao hơn chưa thử click n phát vậy nó có đc ko, thời gian trễ sẽ tăng lên nhiều ko, hihi, mình nghĩ phương án nhập vốn chắc ok hơn, :)
 
Nếu macro chạy theo level bằng click thì độ trễ cao quá, mình tính cuối tuần thay bằng lệnh nhập vốn, mình tính sẵn vốn cho mỗi level, ở level nào thì macro vẫn chỉ click 1 cái, chỉ thêm thao tác nhập vốn vào, ko biết độ trễ có ngắn hơn ko nữa, trước mắt mình tạm xử lý bằng cách ngắt nhỏ chuỗi lặp ra, sau 15' thì macro trừ lại 8 giây, đó là chưa kể mấy cái level cao hơn chưa thử click n phát vậy nó có đc ko, thời gian trễ sẽ tăng lên nhiều ko, hihi, mình nghĩ phương án nhập vốn chắc ok hơn, :)
e thấy click chuột nhanh hơn nhập vốn nên e nghĩ đỗ trễ của nhập vốn lâu hơn keke. chưa thử nên chưa biêt với lại sàn e trade nhập vốn lại là nó load lại payout mất vài giây nên e e dùng click keke
 
@vĩnh0902 với lại mình tính điều chỉnh lại mức áp level, hiện tại win=loss đang là điểm khởi đầu của Fibonacci level, tức là bằng level 1, mình tính điều chỉnh lại win=loss+1 mới là level 1, còn win = loss là level 2, còn win=loss=0 là level 1. Vĩnh thấy vậy ok ko, hay để như hiện tại :)
 
@vĩnh0902 với lại mình tính điều chỉnh lại mức áp level, hiện tại win=loss đang là điểm khởi đầu của Fibonacci level, tức là bằng level 1, mình tính điều chỉnh lại win=loss+1 mới là level 1, còn win = loss là level 2, còn win=loss=0 là level 1. Vĩnh thấy vậy ok ko, hay để như hiện tại :)
e nghĩ lại chỉnh lại hợp lí hơn bác ạ :D rủi ro cao hơn nhưng se lợi nhuận hơn
 
yes :) tuần sau e cung demo để sang tháng 4 e chạy real:D
Mình chỉnh lại mức áp level rồi nè, vĩnh test nhé, nhớ tăng mức take profit lên lại nha, chứ để mặc định thì hôm nay take profit 100% òi, ko còn lệnh đâu :D
Mã:
// BO - Woodies Fibo - Backtesting
// © inno14
//@version=4
strategy("BO - Woodies Fibo - Backtesting")
//strategy.risk.max_intraday_loss(1, strategy.cash)
// === INPUT PERIOD OF TIME ===
Date   = input(true, title = "=== Date Option ===")
FromDay   = input(defval = 20, title = "From Day", minval = 1, maxval = 31)
FromMonth = input(defval = 3, title = "From Month", minval = 1, maxval = 12)
FromYear  = input(defval = 2020, title = "From Year", minval = 2017)

ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToMonth   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToYear    = input(defval = 9999, title = "To Year", minval = 2017)

// === DATE RANGE ===
start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window
finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)        // backtest finish window
window()  => time >= start and time <= finish ? true : false // create function "within window of time"

// === Trading Time ===
CTimeDvM   = input(true, title = "=== Trading Time ===")
Time_zone = input(7,title="Time Zone")
FromHourDvM   = input(defval = 07, title = "From Hour", minval = 00, maxval = 23)
FromMinuteDvM = input(defval = 30, title = "From Minute", minval = 00, maxval = 59)
ToHourDvM   = input(defval = 04, title = "To Hour", minval = 00, maxval = 23)
ToMinuteDvM = input(defval = 59, title = "To Minute", minval = 00, maxval = 59)

GMT_FHDvM=FromHourDvM<Time_zone?FromHourDvM-Time_zone+24:FromHourDvM-Time_zone
GMT_THDvM=ToHourDvM<Time_zone?ToHourDvM-Time_zone+24:ToHourDvM-Time_zone
fhDvM= (GMT_FHDvM<10?"0"+tostring(GMT_FHDvM):tostring(GMT_FHDvM))
fmDvM= (FromMinuteDvM<10?"0"+tostring(FromMinuteDvM):tostring(FromMinuteDvM))
thDvM= (GMT_THDvM<10?"0"+tostring(GMT_THDvM):tostring(GMT_THDvM))
tmDvM= (ToMinuteDvM<10?"0"+tostring(ToMinuteDvM):tostring(ToMinuteDvM))
WorkingHourDvM = fhDvM+fmDvM+"-"+thDvM+tmDvM
t0_DvM = time(timeframe.period, WorkingHourDvM)
htrtime = input(true,title="Highlight Trading Time")
bgcolor(htrtime? t0_DvM? color.white : na:na, title="Trading Time", transp=0)

//

//Woodies CCI
cciTurboLength = 6
cci14Length = input(title="CCI 14 Length", type=input.integer, defval=14)

source = close
cciTurbo = cci(source, cciTurboLength)
cci14 = cci(source, cci14Length)

last5IsDown = cci14[5] < 0 and cci14[4] < 0 and cci14[3] < 0 and cci14[2] < 0 and cci14[1] < 0
last5IsUp = cci14[5] > 0 and cci14[4] > 0 and cci14[3] > 0 and cci14[2] > 0 and cci14[1] > 0
histogramColor = last5IsUp ? color.green : last5IsDown ? color.red : cci14 < 0 ? color.gray : color.gray

//Plot Woodies CCI
//plot(cci14, title="CCI Histogram", color=histogramColor, style=plot.style_histogram, linewidth=2, transp=40)
//plot(0, title="Zero Line", color=cciTurbo>100?color.blue:cciTurbo<-100?color.red:color.navy, style=plot.style_line, linewidth=6, transp=20)
hline(200, title="Hundred Line", color=color.black, linestyle=hline.style_dotted)
hline(-200, title="Minus Line", color=color.black, linestyle=hline.style_dotted)

//Plot lingreg CCI14
linreg_len=input(5,title="Linear Regression Length")
linreg_cci14=linreg(cci14, linreg_len, 0)
//plot(linreg_cci14, color=color.aqua, linewidth=4)

//
ext_linreg=input(100,title="Extreme Level")

//peak & top
peak_cci=
       linreg_cci14[2]>linreg_cci14[3] and linreg_cci14[1]>linreg_cci14[2] and linreg_cci14[0]<linreg_cci14[1] and linreg_cci14[1]>ext_linreg
bott_cci=
       linreg_cci14[2]<linreg_cci14[3] and linreg_cci14[1]<linreg_cci14[2] and linreg_cci14[0]>linreg_cci14[1] and linreg_cci14[1]<-ext_linreg
peak_cci_1=
       linreg_cci14[2]>linreg_cci14[3] and linreg_cci14[1]>linreg_cci14[2] and linreg_cci14[0]<linreg_cci14[1]
bott_cci_1=
       linreg_cci14[2]<linreg_cci14[3] and linreg_cci14[1]<linreg_cci14[2] and linreg_cci14[0]>linreg_cci14[1]
//
fil_len=input(6,title="Filter Length")
top_ext=highest(linreg_cci14,fil_len)
bot_ext=lowest(linreg_cci14,fil_len)
//
//Put signal
x1=
       peak_cci
       and linreg_cci14[1]==top_ext
       and linreg_cci14[1]>valuewhen(peak_cci_1,linreg_cci14[1],1)
       and close>low[1]
       and cci14<linreg_cci14
      

//Call signal
y1=
       bott_cci
       and linreg_cci14[1]==bot_ext
       and linreg_cci14[1]<valuewhen(bott_cci_1,linreg_cci14[1],1)
       and close<high[1]
       and cci14>linreg_cci14
      

no_orders =
       not strategy.opentrades

//Function
xTech=
       x1
       and no_orders

yTech=
       y1
       and no_orders

sumtrades=strategy.losstrades[0]+strategy.wintrades[0]
losstrades=strategy.losstrades[0]
wintrades=strategy.wintrades[0]
//Fibonacci Money Management
fibo_tt=input(true,title="=== Fibonacci Money Management ===")
take_profit=input(3,title="Take profit = wintrades - losstrades =")
//Bid level
current_bid_lv=
       losstrades == 0 and wintrades == 0?1:
       losstrades-wintrades == -1?1:
       losstrades>0 and (losstrades-wintrades == 0)?2:
       losstrades-wintrades == 1?3:
       losstrades-wintrades == 2?5:
       losstrades-wintrades == 3?8:
       losstrades-wintrades == 4?13:
       losstrades-wintrades == 5?21:
       losstrades-wintrades == 6?34:
       1
bid_level=current_bid_lv
take_profit_val = wintrades - losstrades
//Plot Analyzing Signals
//hline1=hline(-1.2*300)
hline2=hline(-1.6*300)
hline0=hline(0)
sigtext=
       xTech?"Put signal"+ " * Current Bid Level: " + tostring(bid_level):yTech?"Call signal"+ " * Current Bid Level: " + tostring(bid_level):
       "Backtesting From: "+tostring(FromDay)+"/"+tostring(FromMonth)+"/"+tostring(FromYear)+" To: "+tostring(ToDay)+"/"+tostring(ToMonth)+"/"+tostring(ToYear)
       + " * Trading Time From: "+tostring(FromHourDvM)+":"+tostring(FromMinuteDvM)+" To "+tostring(ToHourDvM)+":"+tostring(ToMinuteDvM)
       + " * Current Bid Level: " + tostring(bid_level)

sig_col=xTech?color.new(color.red,10):yTech?color.new(color.blue,10):color.new(color.navy,10)
label_sig_text = label.new(bar_index[0], -1.5*300, text=sigtext, style=label.style_none, textcolor=sig_col, size=size.large)
label.delete(label_sig_text[1])

//Plot Color Panel of Finobacci Money Management
fib_sigtext=
       "Color Panel of Finobacci Money Management"
      
fib_sig_col=color.new(color.navy,10)
label_fib_sig_text = label.new(bar_index[5], 250, text=fib_sigtext, style=label.style_none, textcolor=fib_sig_col, size=size.large)
label.delete(label_fib_sig_text[1])
fib_put=50
fib_col=-150

fib_put_lv1=color.new(color.red,0)
plotshape(fib_put, title='Put Lv1', text="Put Lv1", style=shape.circle, location=location.absolute, color=fib_put_lv1, textcolor=color.black, offset=-9, size=size.normal, show_last=2)
fib_call_lv1=color.new(color.blue,0)
plotshape(fib_col, title='Call Lv1', text="Call Lv1", style=shape.circle, location=location.absolute, color=fib_call_lv1, textcolor=color.black, offset=-9, size=size.normal, show_last=2)

fib_put_lv2=color.new(color.red,10)
plotshape(fib_put, title='Put Lv2', text="Put Lv2", style=shape.circle, location=location.absolute, color=fib_put_lv2, textcolor=color.black, offset=-8, size=size.normal, show_last=2)
fib_call_lv2=color.new(color.blue,10)
plotshape(fib_col, title='Call Lv2', text="Call Lv2", style=shape.circle, location=location.absolute, color=fib_call_lv2, textcolor=color.black, offset=-8, size=size.normal, show_last=2)

fib_put_lv3=color.new(color.red,20)
plotshape(fib_put, title='Put Lv3', text="Put Lv3", style=shape.circle, location=location.absolute, color=fib_put_lv3, textcolor=color.black, offset=-7, size=size.normal, show_last=2)
fib_call_lv3=color.new(color.blue,20)
plotshape(fib_col, title='Call Lv3', text="Call Lv3", style=shape.circle, location=location.absolute, color=fib_call_lv3, textcolor=color.black, offset=-7, size=size.normal, show_last=2)

fib_put_lv5=color.new(color.red,30)
plotshape(fib_put, title='Put Lv5', text="Put Lv5", style=shape.circle, location=location.absolute, color=fib_put_lv5, textcolor=color.black, offset=-6, size=size.normal, show_last=2)
fib_call_lv5=color.new(color.blue,40)
plotshape(fib_col, title='Call Lv5', text="Call Lv5", style=shape.circle, location=location.absolute, color=fib_call_lv5, textcolor=color.black, offset=-6, size=size.normal, show_last=2)

fib_put_lv8=color.new(color.red,40)
plotshape(fib_put, title='Put Lv8', text="Put Lv8", style=shape.circle, location=location.absolute, color=fib_put_lv8, textcolor=color.black, offset=-5, size=size.normal, show_last=2)
fib_call_lv8=color.new(color.blue,40)
plotshape(fib_col, title='Call Lv8', text="Call Lv8", style=shape.circle, location=location.absolute, color=fib_call_lv8, textcolor=color.black, offset=-5, size=size.normal, show_last=2)

fib_put_lv13=color.new(color.red,50)
plotshape(fib_put, title='Put Lv13', text="Put Lv13", style=shape.circle, location=location.absolute, color=fib_put_lv13, textcolor=color.black, offset=-4, size=size.normal, show_last=2)
fib_call_lv13=color.new(color.blue,50)
plotshape(fib_col, title='Call Lv13', text="Call Lv13", style=shape.circle, location=location.absolute, color=fib_call_lv13, textcolor=color.black, offset=-4, size=size.normal, show_last=2)

fib_put_lv21=color.new(color.red,60)
plotshape(fib_put, title='Put Lv21', text="Put Lv21", style=shape.circle, location=location.absolute, color=fib_put_lv21, textcolor=color.black, offset=-3, size=size.normal, show_last=2)
fib_call_lv21=color.new(color.blue,60)
plotshape(fib_col, title='Call Lv21', text="Call Lv21", style=shape.circle, location=location.absolute, color=fib_call_lv21, textcolor=color.black, offset=-3, size=size.normal, show_last=2)

fib_put_lv34=color.new(color.red,70)
plotshape(fib_put, title='Put Lv34', text="Put Lv34", style=shape.circle, location=location.absolute, color=fib_put_lv34, textcolor=color.black, offset=-2, size=size.normal, show_last=2)
fib_call_lv34=color.new(color.blue,70)
plotshape(fib_col, title='Call Lv34', text="Call Lv34", style=shape.circle, location=location.absolute, color=fib_call_lv34, textcolor=color.black, offset=-2, size=size.normal, show_last=2)
//plot Signal
PutSignal= xTech and window() and t0_DvM and take_profit_val<take_profit?-1.2*300:na
CallSignal= yTech and window() and t0_DvM and take_profit_val<take_profit?-1.2*300:na
putcol =
       PutSignal ?
       bid_level==1? color.new(color.red,0):
       bid_level==2? color.new(color.red,10):
       bid_level==3? color.new(color.red,20):
       bid_level==5? color.new(color.red,30):
       bid_level==8? color.new(color.red,40):
       bid_level==13? color.new(color.red,50):
       bid_level==21? color.new(color.red,60):
       bid_level==34? color.new(color.red,70):
       color.new(color.red,0): na
callcol =
       CallSignal ?
       bid_level==1? color.new(color.blue,0):
       bid_level==2? color.new(color.blue,10):
       bid_level==3? color.new(color.blue,20):
       bid_level==5? color.new(color.blue,30):
       bid_level==8? color.new(color.blue,40):
       bid_level==13? color.new(color.blue,50):
       bid_level==21? color.new(color.blue,60):
       bid_level==34? color.new(color.blue,70):
       color.new(color.blue,0): na
plotshape(PutSignal, title='Put', text="Put", style=shape.circle, location=location.absolute, color=putcol, textcolor=color.black, offset=1, size=size.large)
plotshape(CallSignal, title='Call', text="Call", style=shape.circle, location=location.absolute, color=callcol, textcolor=color.black, offset=1, size=size.large)

//Backtesting
exp_tt=input(true,"Expiry Option By Bars")
exp_val=input(3,"Number of Bars")
strategy.entry("Call", strategy.long, when=yTech and window() and t0_DvM and take_profit_val<take_profit)
strategy.entry("Put", strategy.short, when=xTech and window() and t0_DvM and take_profit_val<take_profit)
strategy.close_all(when=barssince(xTech)==exp_val or barssince(yTech)==exp_val)
//EOF
 
@vĩnh0902 phải loss 3 lệnh nữa mới có fibo level 2 để test, vĩnh chỉnh thời gian tăng lên để xoá các giao dịch đã take profit đi mới mau test level 2-3-5... Đc nha
 

BÌNH LUẬN MỚI NHẤT

  • Nhật Hoài trong Lập trình MQL - Expert Advisor - Indicator 160,779 Xem / 1,106 Trả lời
  • Mạc An trong Phân tích Forex - Vàng - Hàng hóa 860 Xem / 39 Trả lời
  • DuongHuy trong Phân tích Forex - Vàng - Hàng hóa 367 Xem / 23 Trả lời
  • haruking trong Kiến thức Trading - Kinh nghiệm Trading 31,535 Xem / 112 Trả lời
  • captainfx trong Chuyện bên lề 609 Xem / 3 Trả lời
  • DuongHuy trong Phân tích Bitcoin - Altcoins - Cryptocurrency 68,924 Xem / 107 Trả lời
  • Tín Phong trong Phân tích Chứng khoán Việt Nam 85,377 Xem / 279 Trả lời
  • AdBlock Detected

    We get it, advertisements are annoying!

    Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

    Back
    Bên trên