
Chiến lược này sử dụng so sánh trong và ngoài kênh Boll và kết hợp với chỉ số động lực để theo dõi xu hướng, thuộc chiến lược theo dõi xu hướng. Chiến lược này sẽ tạo ra tín hiệu hướng xu hướng mới khi biến động trong kênh nhỏ hơn ngoài kênh và mở vị trí.
Chiến lược này bao gồm:
Thiết lập dải pol: bao gồm dải pol lớn dài 40 chu kỳ, dải pol nhỏ dài 20 chu kỳ, đường dẫn rộng gấp 2 lần chênh lệch tiêu chuẩn.
Quyết định bùng nổ kênh: Nếu băng tần lớn lên đường ray thấp hơn băng tần nhỏ lên đường ray và băng tần lớn xuống đường ray cao hơn băng tần nhỏ xuống đường ray, điều này cho thấy sóng tăng lên và tạo ra tín hiệu hướng xu hướng mới.
Chỉ số động lực: EMA 14 ngày 240 chu kỳ, định hướng xu hướng.
ATR Stop Stop: 14 lần so với ATR và 1,5 lần so với Stop Stop.
Chiến lược đầu tiên là đánh giá xem liệu kênh có nổ hay không, nếu kênh nổ, sau đó đánh giá hướng động lực, quyết định làm nhiều hoặc trống. Sau khi vào sân, quản lý dừng lỗ bằng ATR.
Sử dụng cấu trúc băng tần kép, bạn có thể so sánh sự biến động trong các khoảng thời gian khác nhau để xác định điểm bùng phát xu hướng.
Sử dụng các chỉ số động lực để đánh giá xu hướng, tránh bị đánh đòn bởi các biến động thị trường.
ATR được sử dụng để quản lý lệnh dừng lỗ và có thể điều chỉnh khoảng cách dừng lỗ theo biến động của thị trường.
Tỷ lệ rủi ro-lợi nhuận hợp lý, tránh theo đuổi quá mức và không quá bảo thủ.
Trong các tình huống xung đột không có xu hướng rõ ràng, dễ bị mắc kẹt. Bạn có thể giảm sai lầm bằng cách tối ưu hóa các tham số chỉ số động lực.
ATR dừng có thể quá bảo thủ, bạn có thể thử nghiệm các phương pháp dừng khác, chẳng hạn như dừng di động.
Tỷ số dừng lỗ cố định có thể không phù hợp với tất cả các giống, bạn có thể xem xét làm cho nó có thể điều chỉnh.
Các chỉ số khác có thể được thử nghiệm như kênh KD.
Kiểm tra các tham số chỉ số động lực khác nhau để tìm ra sự kết hợp tốt nhất.
Thử các phương pháp dừng lỗ khác nhau, chẳng hạn như dừng lỗ di động, ATR tự điều chỉnh.
Cho phép Stop Loss Stop Loss Coefficient có thể điều chỉnh, tối ưu hóa cho các giống và môi trường thị trường khác nhau.
Kiểm tra hiệu quả của các chỉ số kênh khác nhau, chọn chỉ số kênh ổn định hơn.
Hãy xem xét việc quản lý lợi nhuận để có thể kiểm soát được lợi nhuận.
Có thể lọc thời gian nhập cảnh dựa trên sóng, thời gian, để tăng tỷ lệ chiến thắng.
Ý tưởng tổng thể của chiến lược này rất rõ ràng, sử dụng các vùng hai cực để đánh giá điểm bùng nổ xu hướng là điểm sáng lớn nhất của nó. Tuy nhiên, vẫn cần kiểm tra tối ưu hóa về phương thức dừng lỗ, chỉ số kênh và quản lý rủi ro, để các tham số chiến lược có thể thích ứng hơn, hoạt động ổn định trong các môi trường thị trường khác nhau. Nhìn chung, chiến lược này có lợi thế tốt và tiềm năng phát triển, đáng để nghiên cứu sâu hơn.
/*backtest
start: 2023-09-30 00:00:00
end: 2023-10-30 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kasaism
//@version=4
// strategy(title="[EURUSD60] BB Expansion Strategy", shorttitle="[EURUSD60] BBEXP",overlay=true, max_bars_back=5000, max_labels_count=500)
// === INPUTS === //
////BB
largeBbRes = input(title="Large BB Resolution", type=input.resolution, defval="", group="BB")
largeBbLength = input(title="Large BB Length", type=input.integer, defval=40, minval=1, group="BB")
smallBbRes = input(title="Small BB Resolution ", type=input.resolution, defval="", group="BB")
smallBbLength = input(title="Small BB Length", type=input.integer, defval=20, minval=1, group="BB")
multi = input(title="BB StdDev", type=input.float, defval=2.0, maxval=10, minval=0.01, group="BB")
validLen = input(title="BB expand valid length", defval=14, group="BB")
// 3 each EMA settings. EMA directions are as each time frame directions.
resFirstTime = input(title="EMA Trend t/f", type=input.resolution, defval="240", group="SMT")
// resSecondTime = input(title="Second t/f", type=input.resolution, defval="30", group="SMT")
// resThirdTime = input(title="Third t/f", type=input.resolution, defval="", group="SMT")
emaLen = input(14, minval=1, title="Length", group="SMT")
smooth = input(3, minval=1, title="Smooth factor", group="SMT")
//Lisk Management
var riskManagementRule1 = "ATR"
var riskManagementRule2 = "Bracket"
riskManagementRule = input(riskManagementRule1, "Detect Risk Management Based On", options=[riskManagementRule1, riskManagementRule2, "No detection"], group="Trade")
atrMulti = input(3.0, title="ATR Multiple", type=input.float, minval = 1.0, group="ATR")
riskRewardRatio = input(1.5, title="Risk Reward Ratio for ATR", type=input.float, minval = 0.01, group="ATR")
stopLossPoint = input(100, title="Stop Loss Point for Braket(tick)", type=input.float, minval = 1.0, group="Bracket")
takeProfitPoint = input(200, title="Take Profit Point for Braket(tick)", type=input.float, minval = 1.0, group="Bracket")
// === /INPUTS/ === //
// === CONSTANT === //
//For barmerge.lookahead_off
index = barstate.isrealtime ? 1 : 0
//For Entry
NOENTRY=0
LONG=1
SHORT=2
//SMT color
int up=1
int dn=2
int up_HL=3
int dn_HL=4
//label color
color_bearish = color.red
color_bullish = color.blue
C_label_color_bearish = color.red
C_label_color_bullish = color.blue
// === /CONSTANT/ === //
// === FUNCTIONS === //
//BB trade direction
bbTradeDetection(lrgUpper, lrgLower, smlUpper, smlLower) =>
if not(na(lrgUpper) or na(lrgLower) or na(smlUpper) or na(smlLower))
if lrgUpper < smlUpper and lrgLower > smlLower
true
else
false
else
na
// === /FUNCTIONS/ === //
// === CALCURATES === //
////BB
//large BB
lrgBbBasis = security(syminfo.tickerid, largeBbRes, sma(close[index], largeBbLength))
lrgBbDev = multi * security(syminfo.tickerid, largeBbRes, stdev(close[index], largeBbLength))
lrgBbUpper = lrgBbBasis + lrgBbDev
lrgBbLower = lrgBbBasis - lrgBbDev
//small BB
smlBbBasis = security(syminfo.tickerid, smallBbRes, sma(close[index], smallBbLength))
smlBbDev = multi * security(syminfo.tickerid, smallBbRes, stdev(close[index], smallBbLength))
smlBbUpper = smlBbBasis + smlBbDev
smlBbLower = smlBbBasis - smlBbDev
bbTrade = bbTradeDetection(lrgBbUpper, lrgBbLower, smlBbUpper, smlBbLower)
//EMA Trend
base=security(syminfo.tickerid, resFirstTime, ema(close[index],emaLen))
sig=security(syminfo.tickerid, resFirstTime, ema(base[index],smooth))
emaTrend = not(na(base) or na(sig)) ? base < sig ? dn : up : na
////LISK MANAGEMENT
float stopLossLineForLong = na
float stopLossLineForShort = na
float takeProfitLineForLong = na
float takeProfitLineForShort = na
atr_ = atr(14) * atrMulti
if riskManagementRule == riskManagementRule1
stopLossLineForLong := strategy.position_size > 0 ? stopLossLineForLong[1] ? stopLossLineForLong[1] : round(close[index] - atr_,3) : na
stopLossLineForShort := strategy.position_size < 0 ? stopLossLineForShort[1] ? stopLossLineForShort[1] : round(close[index] + atr_,3) : na
takeProfitLineForLong := strategy.position_size > 0 ? takeProfitLineForLong[1] ? takeProfitLineForLong[1] : close[index] + atr_*riskRewardRatio : na
takeProfitLineForShort := strategy.position_size < 0 ? takeProfitLineForShort[1] ? takeProfitLineForShort[1] :close[index] - atr_*riskRewardRatio : na
if riskManagementRule == riskManagementRule2
stopLossLineForLong := strategy.position_size > 0 ? stopLossLineForLong[1] ? stopLossLineForLong[1] : close[index] - stopLossPoint * syminfo.mintick : na
stopLossLineForShort := strategy.position_size < 0 ? stopLossLineForShort[1] ? stopLossLineForShort[1] : close[index] + stopLossPoint * syminfo.mintick : na
takeProfitLineForLong := strategy.position_size > 0 ? takeProfitLineForLong[1] ? takeProfitLineForLong[1] : close[index] +takeProfitPoint * syminfo.mintick : na
takeProfitLineForShort := strategy.position_size < 0 ? takeProfitLineForShort[1] ? takeProfitLineForShort[1] :close[index] - takeProfitPoint * syminfo.mintick : na
// === /CALCURATES/ === //
// === CONDITIONS === //
//BB
bool isBbEntry = na
for i=0 to validLen
isBbEntry := bbTrade==true ? true : bbTrade[i]==true ? true : false
//plotshape(isBbEntry, style=shape.circle, location=location.bottom)
isBbLong = isBbEntry and open[index] < smlBbBasis[index] and close[index] > smlBbBasis[index]
isBbShort = isBbEntry and open[index] > smlBbBasis[index] and close[index] < smlBbBasis[index]
//SMT
isEmaLong = emaTrend == up
isEmaShort = emaTrend == dn
//ATR
isAtrLongStop = low[index] <= stopLossLineForLong
isAtrShortStop = high[index] >= stopLossLineForShort
isAtrLongLimit = high[index] >= takeProfitLineForLong
isAtrShortLimit = low[index] <= takeProfitLineForShort
// === /CONDITIONS/ === //
// === TRADE === //
//ENTRY
if (isBbLong and isEmaLong)
strategy.entry("LongEntry", strategy.long, comment="LongEntry")
if riskManagementRule == riskManagementRule2
strategy.exit("LongEntry", loss=stopLossPoint, profit=takeProfitPoint, comment="bracket")
if (isBbShort and isEmaShort)
strategy.entry("ShortEntry", strategy.short, comment="ShortEntry")
if riskManagementRule == riskManagementRule2
strategy.exit("ShortEntry", loss=stopLossPoint, profit=takeProfitPoint, comment="bracket")
//EXIT
if riskManagementRule == riskManagementRule1
if(isAtrLongStop)
strategy.close("LongEntry", when=isAtrLongStop, comment="ATR Stop")
if(isAtrShortStop)
strategy.close("ShortEntry", when=isAtrShortStop, comment="ATR Stop")
if(isAtrLongLimit)
strategy.close("LongEntry", when=isAtrLongLimit, comment="ATR Limit")
if(isAtrShortLimit)
strategy.close("ShortEntry", when=isAtrShortLimit, comment="ATR Limit")
// === /TRADE/ === //
// === PLOTS === //
plot(lrgBbBasis, title="Large BB Basis", linewidth=2, color=color.gray)
plot(lrgBbUpper, title="Large BB Upper", linewidth=2, color=color.gray)
plot(lrgBbLower, title="Large BB Lower", linewidth=2, color=color.gray)
plot(smlBbBasis, title="Small BB Basis", color=color.white)
plot(smlBbUpper, title="Small BB Upper", color=color.white)
plot(smlBbLower, title="Small BB Lower", color=color.white)
plot(base, title="EMA Line", color= emaTrend==dn ? color_bearish : emaTrend==up ? color_bullish : color.gray)
plot(stopLossLineForLong ? stopLossLineForLong : na, title="S/L Line For Long", color=color.yellow, style=plot.style_circles)
plot(stopLossLineForShort ? stopLossLineForShort : na, title="S/L Line For Short", color=color.yellow, style=plot.style_circles)
plot(takeProfitLineForLong ? takeProfitLineForLong : na, title="T/P Line For Long", color=color.purple, style=plot.style_circles)
plot(takeProfitLineForShort ? takeProfitLineForShort : na, title="T/P Line For Short", color=color.purple, style=plot.style_circles)
// /=== PLOTS ===/ //