
Chiến lược SuperTrend và Stoch RSI ba lần là một chiến lược giao dịch định lượng kết hợp theo dõi xu hướng và mua quá mức của chỉ số bán tháo trong nhiều khung thời gian. Chiến lược này sử dụng chỉ số SuperTrend ba lần với các tham số khác nhau để xác định xu hướng thị trường và kết hợp với tín hiệu mua quá mức của chỉ số Stoch RSI để phát ra tín hiệu giao dịch. Trong hoạt động cụ thể, chiến lược này phát ra tín hiệu mua / bán đồng thời trong hai chỉ số SuperTrend nhanh hơn, nếu chỉ số Stoch RSI cũng xác nhận tín hiệu này, thì sẽ thực hiện hoạt động mua / bán tương ứng.
Lý luận cốt lõi của chiến lược SuperTrend và Stoch RSI ba là kết hợp các chỉ số SuperTrend và Stoch RSI với các tham số khác nhau để lọc tín hiệu giao dịch để cải thiện chất lượng tín hiệu và giảm tỷ lệ tín hiệu sai.
Đầu tiên, chiến lược này sử dụng ba bộ chỉ số SuperTrend với các tham số khác nhau để xác định xu hướng chính của thị trường. Các tham số của ba bộ chỉ số SuperTrend được thiết lập khác nhau, khung thời gian từ nhanh đến chậm, được sử dụng để nắm bắt sự thay đổi xu hướng ở các cấp độ khác nhau.
Tiếp theo, chiến lược đưa ra chỉ số Stoch RSI để xác định xem tín hiệu này có quá mua hay bán quá mức hay không. Chỉ số Stoch RSI kết hợp lợi thế của chỉ số RSI và chỉ số Stochastic ngẫu nhiên, có thể xác định hiệu quả liệu thị trường có đang mua hay bán quá mức hay không.
Bằng cách kết hợp nhiều chỉ số và nhiều khung thời gian, chiến lược SuperTrend và Stoch RSI có thể lọc hiệu quả tiếng ồn thị trường, tăng độ tin cậy của tín hiệu và giảm tỷ lệ giao dịch sai.
Lợi thế lớn nhất của chiến lược SuperTrend và Stoch RSI là sự kết hợp hiệu quả của nhiều chỉ số và nhiều khung thời gian, mang lại cho chúng tôi những lợi ích sau:
Giảm tín hiệu giao dịch sai. Sự kết hợp của ba chỉ số SuperTrend và chỉ số Stoch RSI có thể làm giảm đáng kể các tín hiệu tiếng ồn và tín hiệu sai có trong chỉ số đơn.
Tăng tỷ lệ tín hiệu lợi nhuận. Mặc dù tần số tín hiệu giảm, tỷ lệ tín hiệu lợi nhuận sẽ tăng đáng kể.
Thích hợp cho thị trường có xu hướng. Các luồng khung thời gian đa dạng có lợi cho việc nắm bắt xu hướng đường dài và trung bình, phù hợp với môi trường thị trường có xu hướng rõ ràng hơn.
Dễ dàng đạt được hiệu quả tốt hơn thông qua tối ưu hóa tham số. Các chỉ số ba cung cấp không gian khả năng lớn hơn cho tối ưu hóa tham số.
Các tham số có thể được điều chỉnh tùy theo phong cách cá nhân của bạn. Bạn có thể tự do điều chỉnh các tham số để làm cho chiến lược phù hợp hơn với phong cách giao dịch của bạn.
Các chiến lược SuperTrend và Stoch RSI ba chiều cũng có một số rủi ro, chủ yếu tập trung vào các khía cạnh sau:
Tần số tín hiệu giảm. Các cơ chế lọc nhiều lớp cho phép các chiến lược giảm tần số giao dịch rõ rệt.
Dễ dàng bỏ lỡ một số tín hiệu. Sự bảo thủ của chiến lược có thể khiến nó dễ dàng bỏ lỡ một số cơ hội tiềm năng.
Nhiều chỉ số tăng phụ thuộc vào tham số. Càng nhiều chỉ số và tham số, chiến lược tối ưu hóa càng khó hơn.
Khả năng theo dõi bị giới hạn. Việc kết hợp nhiều khung thời gian cũng hạn chế sự linh hoạt của chiến lược theo dõi xu hướng.
Đối với các rủi ro trên, chúng ta có thể tối ưu hóa bằng cách điều chỉnh các tham số chỉ số, giới thiệu nhiều chỉ số phán đoán hỗ trợ hơn, để chiến lược có thể đạt được chất lượng lợi nhuận cao hơn trong khi kiểm soát rủi ro.
Chiến lược SuperTrend ba và Stoch RSI vẫn có thể được tối ưu hóa hơn nữa, chủ yếu từ các khía cạnh sau:
Điều chỉnh các tham số chỉ số để tìm các tham số phù hợp nhất. Bạn có thể giới thiệu thêm các thử nghiệm tham số chỉ số để tìm các tham số tối ưu.
Thêm chiến lược dừng lỗ, kiểm soát rủi ro giao dịch đơn. Điều này có thể làm tăng đáng kể sự ổn định của chiến lược.
Tham gia vào nhiều chỉ số phán đoán để xác minh tín hiệu. Ví dụ như đưa ra chỉ số khối lượng giao dịch để đánh giá nhiều góc độ.
Thêm tính năng tự điều chỉnh. Nó cho phép các chiến lược tự động tối ưu hóa và điều chỉnh các tham số để thích ứng với sự thay đổi của thị trường.
Kết hợp với thuật toán học máy để dự đoán. Sử dụng thuật toán AI để dự đoán chính xác tín hiệu chỉ số.
Với sự tối ưu hóa liên tục, chiến lược SuperTrend và Stoch RSI có thể phát triển thành một chiến lược giao dịch định lượng ổn định và hiệu quả, mang lại cho chúng ta một Alpha đáng kể.
Chiến lược SuperTrend và Stoch RSI ba lần đã kết hợp thành công phân tích khung thời gian đa dạng với phán đoán mua quá mức và bán quá mức, tạo thành một chiến lược giao dịch theo xu hướng độc đáo. Trong khi đó, nó vẫn giữ được lợi thế kép theo xu hướng và lọc các chỉ số, tăng tỷ lệ tín hiệu lợi nhuận trong khi giảm tín hiệu nhiễu. Mặc dù rủi ro và không gian tối ưu hóa của chiến lược vẫn tồn tại, nhưng khả năng lợi nhuận và sự ổn định của nó vẫn có thể được nâng cao hơn nữa bằng cách điều chỉnh tham số và tối ưu hóa chiến lược.
/*backtest
start: 2022-11-29 00:00:00
end: 2023-04-17 00:00:00
period: 1d
basePeriod: 1h
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/
// © M3RZI
//@version=4
strategy("3x Supertrend and Stoch RSI", overlay = true, max_bars_back = 1000)
//INPUTS
STATRLENGTH1 = input(10, title = "Fast Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")
STATRMULT1 = input(1, title = "Fast Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")
STATRLENGTH2 = input(11, title = "Medium Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")
STATRMULT2 = input(2, title = "Medium Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")
STATRLENGTH3 = input(12, title = "Slow Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")
STATRMULT3 = input(3, title = "Slow Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")
stochK = input(3, title = "K (Stochastic Fast)", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
stochD = input(3, title = "D (Signal Line)", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
rsiLength = input(14, title = "RSI Length", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
stochLength = input(14, title = "Stochastic Length", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
rsiSource = input(close, title = "RSI Source", type = input.source, group = "STOCHASTIC RSI SETTINGS")
stochRestrictions = input(false, title = "Restrict crosses to overbought/oversold territory", type = input.bool, group = "STOCHASTIC RSI SETTINGS")
overboughtLine = input(80, title = "Stochastic RSI Upper Band", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
oversoldLine = input(20, title = "Stochastic RSI Lower Band", type = input.integer, group = "STOCHASTIC RSI SETTINGS")
EMALength = input(200, title = "EMA Length", type = input.integer, group = "EMA SETTINGS")
SLStrategy = input("ATR Based", title = "Stop Loss Strategy", options = ["ATR Based"],type = input.string, group = "POSITION EXIT SETTINGS")
SLATRLength = input(14, title = "Stop Loss ATR Length", type = input.integer, group = "POSITION EXIT SETTINGS")
SLATRMult = input(2.7, title = "Stop Loss ATR Multiplier", type = input.float, group = "POSITION EXIT SETTINGS")
TPStrategy = input("ATR Based", title = "Take Profit Strategy", options = ["ATR Based"],type = input.string, group = "POSITION EXIT SETTINGS")
TPATRLength = input(14, title = "Take Profit ATR Length", type = input.integer, group = "POSITION EXIT SETTINGS")
TPATRMult = input(1.6, title = "Take Profit ATR Multiplier", type = input.float, group = "POSITION EXIT SETTINGS")
//SUPERTRENDS
[superTrend1,dir1] = supertrend(STATRMULT1,STATRLENGTH1)
[superTrend2,dir2] = supertrend(STATRMULT2,STATRLENGTH2)
[superTrend3,dir3] = supertrend(STATRMULT3,STATRLENGTH3)
directionST1 = dir1 == 1 and dir1[1] == 1 ? false : dir1 == -1 and dir1[1] == -1 ? true : na
directionST2 = dir2 == 1 and dir2[1] == 1 ? false : dir2 == -1 and dir2[1] == -1 ? true : na
directionST3 = dir3 == 1 and dir3[1] == 1 ? false : dir3 == -1 and dir3[1] == -1 ? true : na
//STOCH RSI
rsi = rsi(rsiSource, rsiLength)
k = sma(stoch(rsi, rsi, rsi, stochLength), stochK)
d = sma(k, stochD)
//EMA
ema = ema(close,EMALength)
//CONDITIONS LONG AND SHORT
var long = false
var longCondition = false
var short = false
var shortCondition = false
var drawing = false
var TP = 0.0
var SL = 0.0
var middle = 0.0
var initial = 0
stopSize = atr(SLATRLength) * SLATRMult
profitSize = atr(TPATRLength) * TPATRMult
longStop = close - stopSize
longProfit = close + profitSize
current = close
shortStop = close + stopSize
shortProfit = close - profitSize
barInitial = bar_index
if stochRestrictions
longCondition := close > ema and ((directionST1 == true and directionST2 == true) or (directionST2 == true and directionST3 == true)) and crossover(k,d) and k < oversoldLine and not long and not drawing
shortCondition := close < ema and ((directionST1 == false and directionST2 == false) or (directionST2 == false and directionST3 == false)) and crossunder(k,d) and k > overboughtLine and not short and not drawing
else
longCondition := close > ema and ((directionST1 == true and directionST2 == true) or (directionST2 == true and directionST3 == true)) and crossover(k,d) and not long and not drawing
shortCondition := close < ema and ((directionST1 == false and directionST2 == false) or (directionST2 == false and directionST3 == false)) and crossunder(k,d) and not short and not drawing
if longCondition
long := true
short := false
drawing := true
TP := longProfit
middle := current
SL := longStop
initial := barInitial
strategy.entry("Long", strategy.long, 10)
strategy.exit("Long exit","Long", limit = TP, stop = SL)
alert("Long signal Supertrend \n Profit:"+tostring(TP)+"\Curret price:"+tostring(close)+"\Stop:"+tostring(SL),alert.freq_once_per_bar_close)
//label.new(bar_index,low,text = "Long\nTP:"+tostring(TP)+"\nSL:"+tostring(SL)+"\nAbierto:"+tostring(current), yloc = yloc.belowbar, textcolor = color.white, color = color.green, size = size.small, style = label.style_label_up)
if shortCondition
short := true
long := false
drawing := true
TP := shortProfit
middle := current
SL := shortStop
initial := barInitial
strategy.entry("Short", strategy.short, 10)
strategy.exit("Short exit","Short",limit = TP , stop = SL)
alert("Short signal Supertrend \n Profit:"+tostring(TP)+"\Curret price:"+tostring(close)+"\Stop:"+tostring(SL),alert.freq_once_per_bar_close)
//label.new(bar_index,high,text = "Short\nTP:"+tostring(TP)+"\nSL:"+tostring(SL)+"\nAbierto:"+tostring(current), yloc = yloc.abovebar, textcolor = color.white, color = color.red, size = size.small, style = label.style_label_down)
if long and (high[1] >= TP or low[1] <= SL)
drawing := false
long := false
if high[1] >= TP
label.new(bar_index[int((bar_index - initial)/2)],TP, text = "Win (Long)", textcolor = color.white, color = color.green, size = size.small, style = label.style_label_down)
else
label.new(bar_index[int((bar_index - initial)/2)],SL, text = "Lose (Long)", textcolor = color.white, color = color.red, size = size.small, style = label.style_label_up)
if short and (low[1] <= TP or high[1] >= SL)
drawing := false
short := false
if low[1] <= TP
label.new(bar_index[int((bar_index - initial)/2)],TP, text = "Win (short)", textcolor = color.white, color = color.green, size = size.small, style = label.style_label_up)
else
label.new(bar_index[int((bar_index - initial)/2)],SL, text = "Lose (short)", textcolor = color.white, color = color.red, size = size.small, style = label.style_label_down)
//STRATEGY
//strategy.entry("buy", strategy.long, 10, when = longCondition)
//strategy.exit("bracket", "buy", 10, limit = TP, stop = SL)
//strategy.entry("short", strategy.long, 10, when = shortCondition)
//strategy.exit("bracket", "short", 10, limit = TP, stop = SL)
//DRAWING
plotshape(longCondition, title = "Long Signal", location=location.belowbar, style=shape.labelup, color=color.green, textcolor=color.white, size=size.small, text="Long")
plotshape(shortCondition, title = "Short Signal", location=location.abovebar, style=shape.labeldown, color=color.red, textcolor=color.white, size=size.small, text="Short")
profitLine = plot(drawing and drawing[1] ? TP : na, title = "Take profit", color = color.green, style = plot.style_linebr)
currentLine =plot(drawing and drawing[1] ? middle : na, title = "Middle Line", color = color.white, style = plot.style_linebr)
lossLine = plot(drawing and drawing[1] ? SL : na, title = "Stop Loss", color = color.red, style = plot.style_linebr)
fill(currentLine,profitLine, title = "Profit Background" ,color = color.new(color.green,75))
fill(currentLine,lossLine, title = "Loss Background" ,color = color.new(color.red,75))
plot(superTrend1, title = "Fast Supertrend", color = dir1 == 1 and dir1[1] == 1 ? color.red : dir1 == -1 and dir1[1] == -1 ? color.green : na)
plot(superTrend2, title = "Medium Supertrend", color = dir2 == 1 and dir2[1] == 1 ? color.red : dir2 == -1 and dir2[1] == -1 ? color.green : na)
plot(superTrend3, title = "Slow Supertrend", color = dir3 == 1 and dir3[1] == 1 ? color.red : dir3 == -1 and dir3[1] == -1 ? color.green : na)
plot(ema, title = "EMA",color = color.yellow)
//plot(k, color = color.blue)
//plot(d, color = color.orange)
//h1 = hline(80)
//h2 = hline(20)
//fill(h1,h2, color = color.new(color.purple,60))