
Chiến lược này kết hợp các chỉ số chuyển động trung bình 200 ngày ((200 EMA), giá trung bình trọng lượng giao dịch ((VWAP) và chỉ số dòng tiền ((MFI) để tạo ra tín hiệu mua và bán. Ý tưởng chính là sử dụng sự kết hợp của ba chỉ số này để đánh giá hướng và cường độ của xu hướng, tạo ra tín hiệu giao dịch trong trường hợp giá phá vỡ 200 EMA và xác nhận các chỉ số của VWAP và MFI. Đồng thời, giới thiệu 200 EMA của chu kỳ thời gian cao là bộ lọc xu hướng, giao dịch chỉ khi xu hướng của chu kỳ thời gian hiện tại và chu kỳ thời gian cao phù hợp.
Chiến lược này xây dựng một hệ thống giao dịch theo dõi xu hướng tương đối vững chắc bằng cách kết hợp các chỉ số EMA, VWAP và MFI 200 ngày, đồng thời xem xét xu hướng của chu kỳ thời gian cao và tính liên tục của biến động giá. Chiến lược lọc các tín hiệu sai bằng cách đánh giá tổng hợp nhiều điều kiện, cải thiện độ chính xác của thời điểm vào. Đồng thời, tính linh hoạt của các tham số chiến lược cho phép tối ưu hóa theo các thị trường và phong cách giao dịch khác nhau.
/*backtest
start: 2023-05-08 00:00:00
end: 2024-05-13 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("200 EMA, VWAP, MFI Strategy - Visible Signals", overlay=true, pyramiding=0)
// Inputs for dynamic adjustments
buffer = input.float(0.2, title="EMA Buffer Percentage", step=0.1) / 100
higherTimeframe = input.timeframe("15", title="Higher Timeframe")
mfiBuyThreshold = input(60, title="MFI Buy Threshold")
mfiSellThreshold = input(40, title="MFI Sell Threshold")
consecutiveCloses = input.int(1, title="Consecutive Closes for Confirmation")
// Calculate the 200-period EMA
ema200 = ta.ema(close, 200)
emaBufferedHigh = ema200 * (1 + buffer)
emaBufferedLow = ema200 * (1 - buffer)
emaHigher = request.security(syminfo.tickerid, higherTimeframe, ta.ema(close, 200))
// VWAP calculation
vwap = ta.vwap(hlc3)
// Money Flow Index calculation
mfiLength = 14
mfi = ta.mfi(close, mfiLength)
// Plotting the indicators
plot(ema200, title="200 EMA", color=color.blue)
plot(vwap, title="VWAP", color=color.orange)
plot(mfi, title="MFI", color=color.purple)
hline(50, "MFI Reference", color=color.gray, linestyle=hline.style_dashed)
plot(emaHigher, title="Higher TF EMA", color=color.red)
// Price action confirmation
isUpTrend = ta.rising(close, consecutiveCloses)
isDownTrend = ta.falling(close, consecutiveCloses)
// Define entry conditions
longCondition = close > emaBufferedHigh and close > vwap and mfi > mfiBuyThreshold and close > emaHigher and isUpTrend
shortCondition = close < emaBufferedLow and close < vwap and mfi < mfiSellThreshold and close < emaHigher and isDownTrend
// Trading execution
if (longCondition)
strategy.entry("Buy", strategy.long)
if (shortCondition)
strategy.entry("Sell", strategy.short)
// Plot shapes for signals
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, size=size.small, title="Buy Signal", text="Buy")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, size=size.small, title="Sell Signal", text="Sell")