
Chiến lược này là một chiến lược giao dịch ngắn hạn sử dụng chỉ số MFI để xác định các khu vực quá mua quá bán, kết hợp với bộ lọc MA để xác định hướng giá đảo ngược. Nó có thể có hiệu quả trong các thị trường như cổ phiếu, ngoại hối, hàng hóa và tiền điện tử.
Chiến lược sử dụng chỉ số MFI để đánh giá hiện tượng bán tháo của thị trường. Khi MFI đi vào vùng bán tháo dưới 20, nó cho thấy vùng đáy, giá trị bị đánh giá thấp, lúc đó giá trị tăng; Khi MFI đi vào vùng mua tháo trên 80, nó cho thấy vùng trên, tài sản được đánh giá cao, lúc đó giảm giá.
Để lọc sự đảo ngược giả mạo, chiến lược này cũng đưa ra chỉ số MA để xác định xu hướng giá. Chỉ khi MFI đảo ngược, giá lên hoặc xuống đường trung bình MA, tín hiệu giao dịch sẽ được tạo ra.
Các giao dịch được thực hiện theo các logic sau:
Bằng cách này, thông qua bộ lọc hai chỉ số, có thể xác định hiệu quả cơ hội đảo ngược, tín hiệu vào sân sẽ đáng tin cậy hơn.
Phản ứng:
Chiến lược này kết hợp các phương pháp phân tích cổ điển với các kỹ thuật định lượng hiện đại, thể hiện khả năng thích ứng mạnh mẽ trong nhiều giống thông qua bộ lọc hai chỉ số nghiêm ngặt, là một chiến lược ngắn hạn phổ biến đáng được đề xuất.
/*backtest
start: 2023-12-19 00:00:00
end: 2023-12-26 00:00:00
period: 1m
basePeriod: 1m
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/
// © vikris
//@version=4
strategy("[VJ]Thor for MFI", overlay=true, calc_on_every_tick = false,pyramiding=0)
// ********** Strategy inputs - Start **********
// Used for intraday handling
// Session value should be from market start to the time you want to square-off
// your intraday strategy
// Important: The end time should be at least 2 minutes before the intraday
// square-off time set by your broker
var i_marketSession = input(title="Market session", type=input.session,
defval="0915-1455", confirm=true)
// Make inputs that set the take profit % (optional)
longProfitPerc = input(title="Long Take Profit (%)",
type=input.float, minval=0.0, step=0.1, defval=1) * 0.01
shortProfitPerc = input(title="Short Take Profit (%)",
type=input.float, minval=0.0, step=0.1, defval=1) * 0.01
// Set stop loss level with input options (optional)
longLossPerc = input(title="Long Stop Loss (%)",
type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01
shortLossPerc = input(title="Short Stop Loss (%)",
type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01
i_MFI = input(3, title="MFI Length")
OB=input(100, title="Overbought Level")
OS=input(0, title="Oversold Level")
barsizeThreshold=input(.5, step=.05, minval=.1, maxval=1, title="Bar Body Size, 1=No Wicks")
i_MAFilter = input(true, title="Use MA Trend Filter")
i_MALen = input(80, title="MA Length")
// ********** Strategy inputs - End **********
// ********** Supporting functions - Start **********
// A function to check whether the bar or period is in intraday session
barInSession(sess) => time(timeframe.period, sess) != 0
// Figure out take profit price
longExitPrice = strategy.position_avg_price * (1 + longProfitPerc)
shortExitPrice = strategy.position_avg_price * (1 - shortProfitPerc)
// Determine stop loss price
longStopPrice = strategy.position_avg_price * (1 - longLossPerc)
shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)
// ********** Supporting functions - End **********
// ********** Strategy - Start **********
// See if intraday session is active
bool intradaySession = true
// Trade only if intraday session is active
//=================Strategy logic goes in here===========================
MFI=mfi(close,i_MFI)
barsize=high-low
barbodysize=close>open?(open-close)*-1:(open-close)
shortwicksbar=barbodysize>barsize*barsizeThreshold
SMA=sma(close, i_MALen)
MAFilter=close > SMA
BUY = MFI[1] == OB and close > open and shortwicksbar and (i_MAFilter ? MAFilter : true)
SELL = MFI[1] == OS and close < open and shortwicksbar and (i_MAFilter ? not MAFilter : true)
//Final Long/Short Condition
longCondition = BUY
shortCondition = SELL
//Long Strategy - buy condition and exits with Take profit and SL
if (longCondition and intradaySession)
stop_level = longStopPrice
profit_level = longExitPrice
strategy.entry("Buy", strategy.long)
strategy.exit("TP/SL", "Buy", stop=stop_level, limit=profit_level)
//Short Strategy - sell condition and exits with Take profit and SL
if (shortCondition and intradaySession)
stop_level = shortStopPrice
profit_level = shortExitPrice
strategy.entry("Sell", strategy.short)
strategy.exit("TP/SL", "Sell", stop=stop_level, limit=profit_level)
// Square-off position (when session is over and position is open)
squareOff = (not intradaySession) and (strategy.position_size != 0)
strategy.close_all(when = squareOff, comment = "Square-off")
// ********** Strategy - End **********