anhnguyen14
Active Member
- 15,634
- 19,261
* Hi anh em, hôm nay mình sẽ làm backtest cho một chiến lược khá cũ và khá là không hiệu quả, đó cũng là lý do vì sao anh tác giả qua đến trang 2 của chiến lược ở BOE đã phải thêm thắt vào một cơ số các indi mới Chiến lược sơ khai không hiệu quả không đồng nghĩa với một ý tưởng tồi, chỉ là nó chưa được phát triển hoàn chỉnh thôi, không biết anh ấy cải tiến ra sao nhưng có vẻ anh ấy thích đánh theo kinh nghiệm nhiều hơn nên thường xuyên phá rule, do các lệnh thắng của anh ấy đa phần không theo setup, nhưng lúc có setup thì anh ấy vẫn bỏ lệnh nên thật khó để đánh giá chính xác mức độ hiệu quả của chiến lược. Do đó mình sẽ code cho tradingview backtest và cải tiến theo ý mình xem thế nào, đồng thời giới thiệu đến anh em cùng thư giãn cuối tuần nhé (đương nhiên sẽ có code backtest tặng anh em tự test nhé)
* Trước khi vào backtest và thêm thắt rule, mời anh em đọc bài gốc ở đây
BOE: http://www.binaryoptionsedge.com/topic/5910-novecento-5-min-reversal-strategy/
Bài giới thiệu trên TraderViet: https://traderviet.org/threads/bina...chi-danh-cho-newbie-khong-can-nhin-nen.10619/
* Rule cơ bản:
Chart EU IDC M5 (từ bar M5 14/10 5:00 am - 9/11/2019)
* Backtest theo rule cơ bản của tác giả và thông số chỉ báo giống như ảnh minh họa của tác giả chiến lược trên BOE (TDF(5,20) - Vostro(4))
* Bactest theo rule cơ bản + điều chỉnh chu kỳ Vostro(4) thành Vostro(8) như mặc định của indicator
* Backtest theo rule cơ bản + rule của mình
* Phân tích các lệnh OTM theo rule cơ bản
* Thêm rule của mình: rule PA nhé
* Code indi Vostro, TDF và code backtest để anh em trải nghiệm chiến lược ở các cặp khác trên các sàn khác
1. Indi Vostro
2. Indi Trend Direction Force Index
3. Code backtest
=====Nice Weekend & Lucky Trading===
* Trước khi vào backtest và thêm thắt rule, mời anh em đọc bài gốc ở đây
BOE: http://www.binaryoptionsedge.com/topic/5910-novecento-5-min-reversal-strategy/
Bài giới thiệu trên TraderViet: https://traderviet.org/threads/bina...chi-danh-cho-newbie-khong-can-nhin-nen.10619/
* Rule cơ bản:
Chart EU IDC M5 (từ bar M5 14/10 5:00 am - 9/11/2019)
* Backtest theo rule cơ bản của tác giả và thông số chỉ báo giống như ảnh minh họa của tác giả chiến lược trên BOE (TDF(5,20) - Vostro(4))
* Bactest theo rule cơ bản + điều chỉnh chu kỳ Vostro(4) thành Vostro(8) như mặc định của indicator
* Backtest theo rule cơ bản + rule của mình
* Phân tích các lệnh OTM theo rule cơ bản
* Thêm rule của mình: rule PA nhé
* Code indi Vostro, TDF và code backtest để anh em trải nghiệm chiến lược ở các cặp khác trên các sàn khác
1. Indi Vostro
Mã:
//@version=4
//author:Kıvanç Özbilgiç @fr3762 on twitter
study("The Vostro Indicator")
period156 = input(100, minval=1)
level = input(8, type=input.integer)
gd120 = sum(hl2, 5)
gd128 = gd120 * .2
gd121 = sum(high - low, 5)
gd136 = gd121 * .2 * .2
ibuff116 = (low - gd128) / gd136
ibuff112 = (high - gd128) / gd136
ibuff108 = iff(ibuff112 > level and high > wma(hl2, period156), 90, iff(ibuff116 < -level and low < wma(hl2, period156), -90, 0))
ibuff109 = iff(ibuff112 > level and ibuff112[1] > level or ibuff116 < -level and ibuff116[1] < -8, 0, ibuff108)
plot(ibuff109, color=color.blue, linewidth=2)
plot(80)
plot(-80)
2. Indi Trend Direction Force Index
Mã:
//@version=4
//author:causecelebre
study("Trend Direction Force Index - TDFI [wm]", shorttitle="TDFI [wm]")
filterHigh = input(1, title="Filter High")
filterMid1 = 0.5
filterMid2 = -0.5
filterLow = input(-1, title="Filter Low")
price = input(close, "Period")
//TFD5
lookback5 = input(5, title="Lookback")
mma5 = ema(price * 1000, lookback5)
smma5 = ema(mma5, lookback5)
impetmma5 = mma5 - mma5[1]
impetsmma5 = smma5 - smma5[1]
divma5 = abs(mma5 - smma5)
averimpet5 = (impetmma5 + impetsmma5) / 2
number5 = averimpet5
pow5 = 3
result5 = float(na)
for i = 1 to pow5 - 1 by 1
if i == 1
result5 := number5
result5
result5 := result5 * number5
result5
tdf5 = divma5 * result5
ntdf5 = tdf5 / highest(abs(tdf5), lookback5 * 3)
//c = ntdf5 > filterHigh ? color.green : ntdf < filterLow ? color.red : color.gray
plot(ntdf5, linewidth=3, color=color.red)
//TFD20
lookback20 = input(20, title="Lookback")
mma20 = ema(price * 1000, lookback20)
smma20 = ema(mma20, lookback20)
impetmma20 = mma20 - mma20[1]
impetsmma20 = smma20 - smma20[1]
divma20 = abs(mma20 - smma20)
averimpet20 = (impetmma20 + impetsmma20) / 2
number20 = averimpet20
pow20 = 3
result20 = float(na)
for i = 1 to pow20 - 1 by 1
if i == 1
result20 := number20
result20
result20 := result20 * number20
result20
tdf20 = divma20 * result20
ntdf20 = tdf20 / highest(abs(tdf20), lookback20 * 3)
//c = ntdf5 > filterHigh ? color.green : ntdf < filterLow ? color.red : color.gray
plot(ntdf20, linewidth=3, color=color.yellow)
hline(filterHigh, color=color.black, linewidth=3)
hline(filterMid1, color=color.gray)
hline(filterMid2, color=color.gray)
hline(filterLow, color=color.black, linewidth=3)
3. Code backtest
Mã:
//@version=4
//Bo Novecento M5
//author: anhnguyen14
strategy(title="Bo Novecento M5", overlay=true, pyramiding=14)
// === INPUTS
setup=input(true, title="Check = Novecentas Setup / Uncheck = anhnguyen14 Setup")
// - /INPUTS
//The Vostro Indicator
period156 = 100
level = input(8, title="Vostro Level")
gd120 = sum(hl2, 5)
gd128 = gd120 * .2
gd121 = sum(high - low, 5)
gd136 = gd121 * .2 * .2
ibuff116 = (low - gd128) / gd136
ibuff112 = (high - gd128) / gd136
ibuff108 = iff(ibuff112 > level and high > wma(hl2, period156), 90, iff(ibuff116 < -level and low < wma(hl2, period156), -90, 0))
ibuff109 = iff(ibuff112 > level and ibuff112[1] > level or ibuff116 < -level and ibuff116[1] < -8, 0, ibuff108)
//plot(ibuff109, color=color.blue, linewidth=2)
//plot(80)
//plot(-80)
//Trend Direction Force Index
filterHigh = 0.5
filterMid = 0
filterLow = -0.5
price = close
//TFD5
lookback5 = input(5, title="TDF Slow")
mma5 = ema(price * 1000, lookback5)
smma5 = ema(mma5, lookback5)
impetmma5 = mma5 - mma5[1]
impetsmma5 = smma5 - smma5[1]
divma5 = abs(mma5 - smma5)
averimpet5 = (impetmma5 + impetsmma5) / 2
number5 = averimpet5
pow5 = 3
result5 = float(na)
for i = 1 to pow5 - 1 by 1
if i == 1
result5 := number5
result5
result5 := result5 * number5
result5
tdf5 = divma5 * result5
ntdf5 = tdf5 / highest(abs(tdf5), lookback5 * 3)
//c = ntdf5 > filterHigh ? color.green : ntdf < filterLow ? color.red : color.gray
//plot(ntdf5, linewidth=3, color=color.red)
//TFD20
lookback20 = input(20, title="TDF Fast")
mma20 = ema(price * 1000, lookback20)
smma20 = ema(mma20, lookback20)
impetmma20 = mma20 - mma20[1]
impetsmma20 = smma20 - smma20[1]
divma20 = abs(mma20 - smma20)
averimpet20 = (impetmma20 + impetsmma20) / 2
number20 = averimpet20
pow20 = 3
result20 = float(na)
for i = 1 to pow20 - 1 by 1
if i == 1
result20 := number20
result20
result20 := result20 * number20
result20
tdf20 = divma20 * result20
ntdf20 = tdf20 / highest(abs(tdf20), lookback20 * 3)
//c = ntdf5 > filterHigh ? color.green : ntdf < filterLow ? color.red : color.gray
//plot(ntdf20, linewidth=3, color=color.yellow)
//hline(filterHigh, color=color.black)
//hline(filterMid, color=color.black)
//hline(filterLow, color=color.black)
//Barry Support & Resistance
FractalLen=3
isFractal(x) => highestbars(x,FractalLen*2+1)==-FractalLen
sF=isFractal(-low), support=low, support:=sF ? low[FractalLen] : support[1]
rF=isFractal(high), resistance=high, resistance:=rF ? high[FractalLen] : resistance[1]
//plot(series=support, title="Support", color=color.blue, offset=-FractalLen)
//plot(series=resistance, title="Resistance", color=color.red, offset=-FractalLen)
plotshape(sF, title="Lower fractal", style=shape.diamond, location=location.belowbar, color=color.black, offset=-FractalLen, size=size.tiny)
plotshape(rF, title="Upper fractal", style=shape.diamond, location=location.abovebar, color=color.black, offset=-FractalLen, size=size.tiny)
//Put Condition
//Novecento M5 - Put Condition
x=
setup?
ibuff109>80
and ntdf5==1
and ntdf20<0.5
:
ibuff109>80
and ntdf5==1
and ntdf20<0.5
and high[barssince(rF)+3]<resistance[barssince(rF)+3]
and close[0]<resistance[barssince(rF)+3]
//Call Condition
//Novecento M5 - Call Condition
y=
setup?
ibuff109<-80
and ntdf5==-1
and ntdf20>-0.5
:
ibuff109<-80
and ntdf5==-1
and ntdf20>-0.5
and low[barssince(sF)+3]>support[barssince(sF)+3]
and close[0]>support[barssince(sF)+3]
// - /FUNCTIONS
//--------------------------------------\\
// Alert
putcol = x ? color.red : na
callcol = y ? color.blue : na
bgcolor(putcol, transp=70, offset=1, title="Put Signal For Macro (A)")
bgcolor(callcol, transp=70, offset=1, title="Call Signal For Macro (A)")
strategy.entry("Call", strategy.long, when=(y))
strategy.entry("Put", strategy.short, when=(x))
strategy.close_all(when=barstate.isnew)
//EOF
=====Nice Weekend & Lucky Trading===
Giới thiệu sách Trading hay
Giao Dịch Theo Xu Hướng Để Kiếm Sống
Sách chia sẻ chiến lược giao dịch, tâm lý, phương pháp quản lý vốn thực chiến của Trader 18 năm kinh nghiệm giao dịch theo xu hướng
Bài viết liên quan