hổm giờ vợ sanh nên tuần này không theo dõi đc, ae demo tiếp nhá. Xem lịch sử thì tuần này đang thử thách rồi@vĩnh0902 @Trương Nhật lúc nào rãnh thì add em indi Pre-H1 Fibo Line mình mới đăng ngoài kia vào chart, quan sát giá, demo lệnh nếu thích, và quan trọng nhất là đánh giá giúp mình xem nó có lợi thế gì để chúng ta khai thác không nhé, các ý tưởng hay mình mới code backtest, vì mấy nay mình khá bận nên cậy nhờ chất xám của anh em xíu nhé
Chúc mừng gia đình có thêm thành viên mới nhéhổm giờ vợ sanh nên tuần này không theo dõi đc, ae demo tiếp nhá. Xem lịch sử thì tuần này đang thử thách rồi
Như vậy setup trong ảnh minh họa của bạn vi phạm rule ADX>20 này rùi áMình quên chưa thêm dk là tất cả các TH thì adx phải lớn hơn 20 nhé
//@version = 4
study(title="DMI HangVu", overlay=false)
HVadxlen = input(14, title="HV ADX Smoothing")
HVdilen = input(14, title="HV DI Length")
HVadxlevel = input(20, title="HV ADX Level")
HVdirmov(HVlen) =>
HVup = change(high)
HVdown = -change(low)
HVtruerange = rma(tr, HVlen)
HVplus = fixnan(100 * rma(HVup > HVdown and HVup > 0 ? HVup : 0, HVlen) / HVtruerange)
HVminus = fixnan(100 * rma(HVdown > HVup and HVdown > 0 ? HVdown : 0, HVlen) / HVtruerange)
[HVplus, HVminus]
HVadx(HVdilen, HVadxlen) =>
[HVplus, HVminus] = HVdirmov(HVdilen)
HVsum = HVplus + HVminus
HVadx = 100 * rma(abs(HVplus - HVminus) / (HVsum == 0 ? 1 : HVsum), HVadxlen)
HVadxHigh(HVdilen, HVadxlen) =>
[HVplus, HVminus] = HVdirmov(HVdilen)
HVplus
HVadxLow(HVdilen, HVadxlen) =>
[HVplus, HVminus] = HVdirmov(HVdilen)
HVminus
HVsig = HVadx(HVdilen, HVadxlen)
HVsigHigh = HVadxHigh(HVdilen, HVadxlen)
HVsigLow = HVadxLow(HVdilen, HVadxlen)
plot(HVsig, color=color.yellow, title="ADX", linewidth=2)
hline(HVadxlevel, color=color.olive, title="ADX Level")
plot(HVsigHigh, color=color.blue, title="DI+", linewidth=2)
plot(HVsigLow, color=color.red, title="DI-", linewidth=2)
chúc mừng gd bác có thêm bạn nhỏ nháhổm giờ vợ sanh nên tuần này không theo dõi đc, ae demo tiếp nhá. Xem lịch sử thì tuần này đang thử thách rồi
hi, mình ghi nhầm đấy DI+@HangVu confirm lại ảnh minh họa Sell Th1 là ADX từ dưới đi lên cắt qua DI+ hay DI- nha. Trong ảnh minh họa theo mình nghĩ là nó cắt lên DI+ mà
View attachment 127653
Buy TH2 giống sell TH1@HangVu Sell trh2 cuar bạn, chỉ còn thiếu rule của buy trh2 thôi
* Không xét BB có bung bands hay không
View attachment 127679
* BB bắt buộc phải bung bands
View attachment 127682
Nếu DI+ thì hiệu suất cực thấp nha. Adx là đường xác nhận trend, adx cắt lên DI+ nhưng thấp hơn DI- tức là trend giảm vẫn còn yếu đó, chỉ khi adx cắt lên DI- luôn thì trend giảm mới mạnh. Code xong rồi, để lát mình gửi, vâỵ sell trh1 này mình sẽ sửa lại cho đúng rule của bạn là DI+ nhé, hiệu suất nó thấp lắm íhi, mình ghi nhầm đấy DI+
//@version=4
//BO Backtesting HangVu
//author: anhnguyen14
strategy(title="BO Backtesting HangVu", overlay=true, pyramiding=10)
// === INPUT BACKTEST RANGE ===
Date = input(true, title = "=== Date Option ===")
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 = 2019, 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 ===")
FromHourDvM = input(defval = 05, title = "From Hour", minval = 00, maxval = 23)
FromMinuteDvM = input(defval = 00, 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<7?FromHourDvM-7+24:FromHourDvM-7
GMT_THDvM=ToHourDvM<7?ToHourDvM-7+24:ToHourDvM-7
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)
//bgcolor(CTimeDvM? t0_DvM? color.gray : na:na, title="Trading Time", transp=90)
HVtt = input(true, title = "=== HangVu Setup ===")
call1 = input(true, title = "1. Call Case 1")
call2 = input(true, title = "2. Call Case 2")
put1 = input(true, title = "3. Put Case 1")
put2 = input(true, title = "4. Put Case 2")
//Bollinger Bands - 20 - 2.0
BBHVlen = input(20, title="BBHV Periode")
BBHVmult = input(2.0, minval=0.001, maxval=5, title="BBHV Multip")
BBHVbasis = sma(close,BBHVlen)
BBHVdev = BBHVmult * stdev(close, BBHVlen)
BBHVupper = BBHVbasis + BBHVdev
BBHVlower = BBHVbasis - BBHVdev
//Bollinger BandWidth
BBHVbbw = (BBHVupper - BBHVlower) / BBHVbasis
//plot(BBHVbbw)
//Bollinger Bands %B
BBHVpB = (close - BBHVlower) / (BBHVupper - BBHVlower)
//plot(BBHVpB)
//plot Bollinger Bands
plot(BBHVbasis, title="BBHV Basis", linewidth=2, color=color.green, transp=0, linewidth=1)
BBHVpb3 = plot(BBHVupper, color=color.green, transp=0,title="BBHV Upper", linewidth=1)
BBHVpb4 = plot(BBHVlower, color=color.green, transp=0,title="BBHV Lower", linewidth=1)
fill(BBHVpb3, BBHVpb4, color=color.aqua,title="Bollinger Bands Background - HangVu",transp=80)
//DMI HangVu
HVadxlen = input(14, title="HV ADX Smoothing")
HVdilen = input(14, title="HV DI Length")
HVadxlevel = input(20, title="HV ADX Level")
HVdirmov(HVlen) =>
HVup = change(high)
HVdown = -change(low)
HVtruerange = rma(tr, HVlen)
HVplus = fixnan(100 * rma(HVup > HVdown and HVup > 0 ? HVup : 0, HVlen) / HVtruerange)
HVminus = fixnan(100 * rma(HVdown > HVup and HVdown > 0 ? HVdown : 0, HVlen) / HVtruerange)
[HVplus, HVminus]
HVadx(HVdilen, HVadxlen) =>
[HVplus, HVminus] = HVdirmov(HVdilen)
HVsum = HVplus + HVminus
HVadx = 100 * rma(abs(HVplus - HVminus) / (HVsum == 0 ? 1 : HVsum), HVadxlen)
HVadxHigh(HVdilen, HVadxlen) =>
[HVplus, HVminus] = HVdirmov(HVdilen)
HVplus
HVadxLow(HVdilen, HVadxlen) =>
[HVplus, HVminus] = HVdirmov(HVdilen)
HVminus
HVsig = HVadx(HVdilen, HVadxlen)
HVsigHigh = HVadxHigh(HVdilen, HVadxlen)
HVsigLow = HVadxLow(HVdilen, HVadxlen)
adx=HVsig
dip=HVsigHigh
dim=HVsigLow
//plot(HVsig, color=color.yellow, title="ADX", linewidth=2)
//hline(HVadxlevel, color=color.olive, title="ADX Level")
//plot(HVsigHigh, color=color.blue, title="DI+", linewidth=2)
//plot(HVsigLow, color=color.red, title="DI-", linewidth=2)
//ADX Between DI+, DI-
adxBT =
(adx>dip and adx<dim)
or
(adx<dip and adx>dim)
//DI+, DI- Cross
dicross =
cross(dip,dim)
or
cross(dim,dip)
//Out the band
Outup =
(close>BBHVupper
or high>BBHVupper)
//and BBHVbbw>BBHVbbw[1]
Outlow =
(close<BBHVlower
or low<BBHVlower)
//and BBHVbbw>BBHVbbw[1]
//ADX down
adxDn =
highest(adx,14)>20
and adx[0]<20
//Case 1
//Put Condition
x1=
put1?
Outlow
and adx[1]<adx[2]
and dim[1]>dip[1]
and dip[1]>adx[1]
and crossover(adx,dip)
:false
//Call Condition
y1=
call1?
barssince(dicross)>0 and barssince(dicross)<5
and adxBT
and crossover(close,BBHVbasis)
:false
//Case 2
//Put Condition
x2=
put2?
Outlow
and adxDn
and crossover(dim,adx)
and dim[1]>dip[1]
and adx>adx[1]
and BBHVbbw>BBHVbbw[1]
:false
//Call Condition
y2=
call2?
Outup
and adx>adx[1]
and dip[1]>dim[1]
and dim[1]>adx[1]
and crossover(adx,dim)
:false
// - /FUNCTIONS
xDvM=
x1
or x2
yDvM=
y1
or y2
//--------------------------------------\\
// - /FUNCTIONS
//--------------------------------------\\
// Alert
CputcolDvM = xDvM ? color.red : na
CcallcolDvM = yDvM ? color.blue : na
plotshape(CTimeDvM?t0_DvM?xDvM:na:na, title='Put', text="Put", style=shape.labeldown, location=location.bottom, color=color.orange, textcolor=color.black, offset=1, transp=0)
plotshape(CTimeDvM?t0_DvM?yDvM:na:na, title='Call', text="Call", style=shape.labelup, location=location.bottom, color=color.orange, textcolor=color.black, offset=1, transp=0)
bgcolor(CTimeDvM?t0_DvM?CputcolDvM:na:na, transp=50, offset=1, title="Put Signal")
bgcolor(CTimeDvM?t0_DvM?CcallcolDvM:na:na, transp=50, offset=1, title="Call Signal")
//Backtesting
if (CTimeDvM)
strategy.entry("Call", strategy.long, when=yDvM and window() and t0_DvM)
if (CTimeDvM)
strategy.entry("Put", strategy.short, when=xDvM and window() and t0_DvM)
strategy.close_all(when=barstate.isnew)
//EOF
đúng là từ quan sát mắt thường, đến đưa vào lập trình nó khác nhau 1 trời, 1 vực. Tôi vẫn thường trade bằng tay, theo pp này. ko thắng tuyệt đối, nhưng vẫn tạm ổn. Và tôi nhận thấy trade theo pp này còn phụ thuộc khá nhiều vào tổng quan của chart khi đó, quan sát xem chart đang khu vực nào trend ra sao?@HangVu code backtest của bạn
Mã://@version=4 //BO Backtesting HangVu //author: anhnguyen14 strategy(title="BO Backtesting HangVu", overlay=true, pyramiding=10) // === INPUT BACKTEST RANGE === Date = input(true, title = "=== Date Option ===") 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 = 2019, 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 ===") FromHourDvM = input(defval = 05, title = "From Hour", minval = 00, maxval = 23) FromMinuteDvM = input(defval = 00, 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<7?FromHourDvM-7+24:FromHourDvM-7 GMT_THDvM=ToHourDvM<7?ToHourDvM-7+24:ToHourDvM-7 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) //bgcolor(CTimeDvM? t0_DvM? color.gray : na:na, title="Trading Time", transp=90) HVtt = input(true, title = "=== HangVu Setup ===") call1 = input(true, title = "1. Call Case 1") call2 = input(true, title = "2. Call Case 2") put1 = input(true, title = "3. Put Case 1") put2 = input(true, title = "4. Put Case 2") //Bollinger Bands - 20 - 2.0 BBHVlen = input(20, title="BBHV Periode") BBHVmult = input(2.0, minval=0.001, maxval=5, title="BBHV Multip") BBHVbasis = sma(close,BBHVlen) BBHVdev = BBHVmult * stdev(close, BBHVlen) BBHVupper = BBHVbasis + BBHVdev BBHVlower = BBHVbasis - BBHVdev //Bollinger BandWidth BBHVbbw = (BBHVupper - BBHVlower) / BBHVbasis //plot(BBHVbbw) //Bollinger Bands %B BBHVpB = (close - BBHVlower) / (BBHVupper - BBHVlower) //plot(BBHVpB) //plot Bollinger Bands plot(BBHVbasis, title="BBHV Basis", linewidth=2, color=color.green, transp=0, linewidth=1) BBHVpb3 = plot(BBHVupper, color=color.green, transp=0,title="BBHV Upper", linewidth=1) BBHVpb4 = plot(BBHVlower, color=color.green, transp=0,title="BBHV Lower", linewidth=1) fill(BBHVpb3, BBHVpb4, color=color.aqua,title="Bollinger Bands Background - HangVu",transp=80) //DMI HangVu HVadxlen = input(14, title="HV ADX Smoothing") HVdilen = input(14, title="HV DI Length") HVadxlevel = input(20, title="HV ADX Level") HVdirmov(HVlen) => HVup = change(high) HVdown = -change(low) HVtruerange = rma(tr, HVlen) HVplus = fixnan(100 * rma(HVup > HVdown and HVup > 0 ? HVup : 0, HVlen) / HVtruerange) HVminus = fixnan(100 * rma(HVdown > HVup and HVdown > 0 ? HVdown : 0, HVlen) / HVtruerange) [HVplus, HVminus] HVadx(HVdilen, HVadxlen) => [HVplus, HVminus] = HVdirmov(HVdilen) HVsum = HVplus + HVminus HVadx = 100 * rma(abs(HVplus - HVminus) / (HVsum == 0 ? 1 : HVsum), HVadxlen) HVadxHigh(HVdilen, HVadxlen) => [HVplus, HVminus] = HVdirmov(HVdilen) HVplus HVadxLow(HVdilen, HVadxlen) => [HVplus, HVminus] = HVdirmov(HVdilen) HVminus HVsig = HVadx(HVdilen, HVadxlen) HVsigHigh = HVadxHigh(HVdilen, HVadxlen) HVsigLow = HVadxLow(HVdilen, HVadxlen) adx=HVsig dip=HVsigHigh dim=HVsigLow //plot(HVsig, color=color.yellow, title="ADX", linewidth=2) //hline(HVadxlevel, color=color.olive, title="ADX Level") //plot(HVsigHigh, color=color.blue, title="DI+", linewidth=2) //plot(HVsigLow, color=color.red, title="DI-", linewidth=2) //ADX Between DI+, DI- adxBT = (adx>dip and adx<dim) or (adx<dip and adx>dim) //DI+, DI- Cross dicross = cross(dip,dim) or cross(dim,dip) //Out the band Outup = (close>BBHVupper or high>BBHVupper) //and BBHVbbw>BBHVbbw[1] Outlow = (close<BBHVlower or low<BBHVlower) //and BBHVbbw>BBHVbbw[1] //ADX down adxDn = highest(adx,14)>20 and adx[0]<20 //Case 1 //Put Condition x1= put1? Outlow and adx[1]<adx[2] and dim[1]>dip[1] and dip[1]>adx[1] and crossover(adx,dip) :false //Call Condition y1= call1? barssince(dicross)>0 and barssince(dicross)<5 and adxBT and crossover(close,BBHVbasis) :false //Case 2 //Put Condition x2= put2? Outlow and adxDn and crossover(dim,adx) and dim[1]>dip[1] and adx>adx[1] and BBHVbbw>BBHVbbw[1] :false //Call Condition y2= call2? Outup and adx>adx[1] and dip[1]>dim[1] and dim[1]>adx[1] and crossover(adx,dim) :false // - /FUNCTIONS xDvM= x1 or x2 yDvM= y1 or y2 //--------------------------------------\\ // - /FUNCTIONS //--------------------------------------\\ // Alert CputcolDvM = xDvM ? color.red : na CcallcolDvM = yDvM ? color.blue : na plotshape(CTimeDvM?t0_DvM?xDvM:na:na, title='Put', text="Put", style=shape.labeldown, location=location.bottom, color=color.orange, textcolor=color.black, offset=1, transp=0) plotshape(CTimeDvM?t0_DvM?yDvM:na:na, title='Call', text="Call", style=shape.labelup, location=location.bottom, color=color.orange, textcolor=color.black, offset=1, transp=0) bgcolor(CTimeDvM?t0_DvM?CputcolDvM:na:na, transp=50, offset=1, title="Put Signal") bgcolor(CTimeDvM?t0_DvM?CcallcolDvM:na:na, transp=50, offset=1, title="Call Signal") //Backtesting if (CTimeDvM) strategy.entry("Call", strategy.long, when=yDvM and window() and t0_DvM) if (CTimeDvM) strategy.entry("Put", strategy.short, when=xDvM and window() and t0_DvM) strategy.close_all(when=barstate.isnew) //EOF
Cảm ơn bạn @anhnguyen14 nhiều nhađúng là từ quan sát mắt thường, đến đưa vào lập trình nó khác nhau 1 trời, 1 vực. Tôi vẫn thường trade bằng tay, theo pp này. ko thắng tuyệt đối, nhưng vẫn tạm ổn. Và tôi nhận thấy trade theo pp này còn phụ thuộc khá nhiều vào tổng quan của chart khi đó, quan sát xem chart đang khu vực nào trend ra sao?
Haizz, không có gì mà, mình là một lão sói cô độc đi săn ý tưởng mà thôiCảm ơn bạn @anhnguyen14 nhiều nha
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.