
Chiến lược này dựa trên một chiến lược theo dõi xu hướng của các đường nét đôi. Nó kết hợp các đường trung bình di chuyển đơn giản nhanh (SMA) và đường trung bình di chuyển trọng lượng chậm (VWMA) để tạo ra tín hiệu mua và bán bằng cách sử dụng các đường nét chéo của hai đường trung bình.
Khi SMA nhanh đi lên vượt qua VWMA chậm, nó tạo ra tín hiệu mua; khi SMA nhanh đi xuống vượt qua VWMA chậm, nó tạo ra tín hiệu bán.
Lập luận cốt lõi của chiến lược này dựa trên hệ thống giao chéo kép đồng tuyến. Cụ thể, nó đồng thời sử dụng các chỉ số kỹ thuật sau:
Các tham số SMA nhanh trong đường trung bình kép được thiết lập ngắn hơn, có thể phản ứng nhanh với sự thay đổi giá; tham số VWMA chậm là dài hơn, có tác dụng sóng. Khi xu hướng ngắn hạn và dài hạn tiến về cùng một hướng, SMA nhanh đi lên vượt qua VWMA chậm tạo ra tín hiệu mua; đi xuống vượt qua tạo ra tín hiệu bán.
Chiến lược này đồng thời thiết lập cơ chế dừng lỗ. Khi giá chạy theo hướng bất lợi, dừng lỗ kịp thời để kiểm soát rủi ro.
Phương pháp kiểm soát rủi ro:
Chiến lược này có thể được tối ưu hóa theo các khía cạnh sau:
Chiến lược này nói chung là một chiến lược theo dõi xu hướng rất thực tế. Nó sử dụng giao dịch đơn giản, trực quan, hai đường trung bình để tạo ra tín hiệu giao dịch, có thể nắm bắt hiệu quả sự thay đổi của xu hướng thị trường thông qua sự kết hợp của đường trung bình nhanh và đường trung bình chậm.
/*backtest
start: 2023-11-23 00:00:00
end: 2023-11-28 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
//strategy(title="Bitlinc Entry v0.1 VWMA / SMA / MRSI SQQQ 94M", overlay=true, initial_capital=10000, currency='USD')
strategy(title="Bitlinc Entry v0.1 VWMA / SMA / MRSI SQQQ 94M", overlay=true)
// Credit goes to this developer for the "Date Range Code"
// https://www.tradingview.com/script/62hUcP6O-How-To-Set-Backtest-Date-Range/
// === GENERAL INPUTS ===
// short ma
maFastSource = input(defval = close, title = "Simple MA Source")
maFastLength = input(defval = 6, title = "Simple MA Length", minval = 1)
// long ma
maSlowSource = input(defval = high, title = "VW MA Source")
maSlowLength = input(defval = 7, title = "VW MA Period", minval = 1)
// === SERIES SETUP ===
// a couple of ma's...
maFast = sma(maFastSource, maFastLength)
maSlow = vwma(maSlowSource, maSlowLength)
// === PLOTTING ===
fast = plot(maFast, title = "Fast MA", color = color.green, linewidth = 2, style = plot.style_line, transp = 30)
slow = plot(maSlow, title = "Slow MA", color = color.red, linewidth = 2, style = plot.style_line, transp = 30)
// === INPUT BACKTEST RANGE ===
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear = input(defval = 2018, title = "From Year", minval = 2017)
ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear = input(defval = 9999, title = "To Year", minval = 2017)
// === FUNCTION EXAMPLE ===
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"
// === LOGIC ===
enterLong = crossover(maFast, maSlow)
exitLong = crossover(maSlow, maFast)
//enterLong = crossover(maSlow, maFast)
//exitLong = crossover(maFast, maSlow)
// Entry //
strategy.entry(id="Long Entry", long=true, when=window() and enterLong)
strategy.entry(id="Short Entry", long=false, when=window() and exitLong)
// === FILL ====
fill(fast, slow, color = maFast > maSlow ? color.green : color.red)
// === MRSI ===
//
//
basis = rsi(close, input(50))
ma1 = ema(basis, input(2))
ma2 = ema(basis, input(27))
oversold = input(32.6)
overbought = input(63)
//plot(ma1, title="RSI EMA1", color=blue)
//plot(ma2, title="RSI EMA2", color=yellow)
obhist = ma1 >= overbought ? ma1 : overbought
oshist = ma1 <= oversold ? ma1 : oversold
//plot(obhist, title="Overbought Highligth", style=columns, color=color.maroon, histbase=overbought)
//plot(oshist, title="Oversold Highligth", style=columns, color=color.yellow, histbase=oversold)
//i1 = hline(oversold, title="Oversold Level", color=white)
//i2 = hline(overbought, title="Overbought Level", color=white)
//fill(i1, i2, color=olive, transp=100)
// === LOGIC ===
enterLongMrsi = crossover(ma1, oversold)
exitLongMrsi = crossover(ma1, overbought)
// Entry //
strategy.entry(id="MRSI Long Entry", long=true, when=window() and enterLongMrsi)
strategy.entry(id="MRSI Short Entry", long=false, when=window() and exitLongMrsi)
//hline(50, title="50 Level", color=white)