
Chiến lược giao dịch mạnh mẽ hai đường trung bình di chuyển kết hợp hai sức mạnh của chỉ số tương đối yếu ((RSI) và chỉ số tỷ lệ biến đổi ((ROC) để xác định hướng của xu hướng đường dài. Chiến lược này đồng thời đặt điều kiện lọc và điều kiện dừng lỗ, thực hiện Entry trên cơ sở xác nhận hướng xu hướng, có thể làm giảm hiệu quả rủi ro của phá vỡ giả.
Chiến lược này dựa trên sự kết hợp của chỉ số RSI và chỉ số ROC để đánh giá thời gian vào thị trường. Khi giá gần với khu vực bán tháo tương đối, nó được coi là điểm biến đổi cấu trúc và tạo ra tín hiệu đảo ngược. Khi giá dao động trong khu vực bán tháo tương đối, nó cho thấy xu hướng hiện tại sẽ kéo dài trong một thời gian.
Ngoài ra, chiến lược này đã thêm hai điều kiện lọc SMA và đường dừng ngắn hạn của phán đoán xu hướng đường dài trung bình, điều này làm cho chiến lược chỉ được xác nhận theo hướng xu hướng đường dài trung bình và không có rủi ro dừng ngắn hạn. Cách bố trí này có thể làm giảm cơ hội bị mắc kẹt trong tình huống xung đột, rủi ro có thể kiểm soát được cho các nhà giao dịch.
Các thiết lập đầu vào linh hoạt của chiến lược cũng cho phép các nhà giao dịch tự do lựa chọn chỉ sử dụng RSI hoặc ROC hoặc một trong các chỉ số này như cơ sở đầu vào, hoặc sử dụng sự kết hợp của cả hai để tối ưu hóa cho các loại và loại thị trường khác nhau, điều này mở rộng hơn nữa phạm vi áp dụng của chiến lược.
Ưu điểm lớn nhất của chiến lược này là kết hợp xu hướng và tín hiệu đảo ngược để đưa ra phán đoán, xem xét cả yếu tố xu hướng và cơ hội cấu trúc, dựa trên sự thay đổi cấu trúc thị trường, do đó có thể đảm bảo thời gian nhập cảnh chính xác. Việc sử dụng kết hợp RSI và ROC cũng làm cho chiến lược có khả năng chống nhiễu mạnh hơn đối với tiếng ồn ngẫu nhiên trong thị trường so với chỉ số đơn lẻ.
Một lợi thế khác là bộ lọc xu hướng (SMA) và trạm dừng ngắn hạn được tích hợp trong chiến lược, có thể làm giảm hiệu quả xác suất bị mắc kẹt trong tình huống biến động. Việc thiết lập cả hai tuyến phòng thủ này là phán đoán xu hướng và dừng ngắn hạn làm cho nó trở thành một chiến lược ổn định có thể kiểm soát rủi ro.
Cuối cùng, chiến lược này có một loạt các thiết lập tham số trong đó các nhà giao dịch có thể tối ưu hóa cho các loại khác nhau và các loại giao dịch, điều này làm cho chiến lược có khả năng áp dụng rất rộng. Dù là giao dịch theo xu hướng hay giao dịch cân bằng, chiến lược có thể điều chỉnh thông qua các tham số để thích ứng với sự thay đổi của thị trường.
Rủi ro lớn nhất của chiến lược này là có một sự chậm trễ của các chỉ số tín hiệu đảo ngược như RSI và ROC. Khi xu hướng biến đổi, các chỉ số này thường có một sự chậm trễ để các tham số đạt đến mức ngưỡng được đặt. Sự chậm trễ này có thể khiến chiến lược nhập cảnh muộn và không thể nắm bắt giai đoạn khởi đầu của xu hướng ban đầu.
Một rủi ro tiềm ẩn khác là trong xu hướng dao động, các thiết lập tham số của RSI và ROC có thể quá nhạy cảm, dẫn đến việc tạo ra một số tín hiệu giả. Nếu các tín hiệu giả này được kích hoạt vào thời điểm dừng ngắn hạn, chúng sẽ trực tiếp gây ra tổn thất thực tế.
Chiến lược này có thể được tối ưu hóa theo các khía cạnh sau:
Thêm thêm các chỉ số để kết hợp, chẳng hạn như KDJ, MACD, v.v., sử dụng nhiều chiều hơn để đánh giá cấu trúc thị trường, tăng độ chính xác của tín hiệu
Thêm cơ chế tối ưu hóa thích ứng cho các thiết lập tham số của RSI và ROC, cho phép tham số chỉ số được điều chỉnh động theo biến động thời gian thực
Tối ưu hóa logic đầu vào, thiết lập một cơ chế xác nhận khi chỉ số xu hướng và chỉ số đảo ngược đạt được điều kiện, tránh tín hiệu sai xuất hiện trong chấn động
Mở rộng phạm vi dừng lỗ hoặc thiết lập dừng chân tự do, cho phép có nhiều không gian để đảo ngược để giảm lợi nhuận bị bỏ lỡ do dừng lỗ quá chặt
Chiến lược giao dịch mạnh mẽ với hai đường trung bình di chuyển kết hợp thành công các chỉ số định hướng và đảo ngược để nắm bắt cơ hội cấu trúc dựa trên xác nhận xu hướng đường dài và dài. Chiến lược này cũng có khả năng cấu hình mạnh mẽ, các nhà giao dịch có thể tối ưu hóa tham số cho từng loại cổ phiếu và tình huống. Cơ chế bảo vệ kép được xây dựng cũng làm cho nó trở thành một rủi ro có thể kiểm soát được.
/*backtest
start: 2024-01-05 00:00:00
end: 2024-02-04 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/
// © GlobalMarketSignals
//@version=4
strategy("GMS: RSI & ROC Strategy", overlay=true)
LongShort = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
RSIroc = input(title="RSI Only, ROC Only, Both?", type=input.string, defval="Both", options=["Both", "RSI Only", "ROC Only"])
RSILength = input(title="RSI Length", type = input.integer ,defval=14)
RSIUpper = input(title="RSI Upper Threshold", type = input.float ,defval=70)
RSILower = input(title="RSI Lower Threshold", type = input.float ,defval=30)
ROCLength = input(title="ROC Length", type = input.integer ,defval=14)
ROCUpper = input(title="ROC Upper Threshold", type = input.float ,defval=0.01)
ROCLower = input(title="ROC Lower Threshold", type = input.float ,defval=-0.01)
LongExit = input(title="Long Exit SMA Length", type = input.integer ,defval=5)
ShortExit = input(title="Short Exit SMA Length", type = input.integer ,defval=5)
AboveBelow = input(title="Trend SMA Filter?", type=input.string, defval="Above", options=["Above", "Below", "Don't Include"])
TrendLength = input(title="Trend SMA Length", type = input.integer ,defval=200)
//RSI ONLY
//Long Side
if LongShort =="Long Only" and AboveBelow == "Above" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Below" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Don't Include" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
//RSI ONLY
//SHORT SIDE
if LongShort =="Short Only" and AboveBelow == "Above" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Below" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Don't Include" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))
///////-----------------/////////////
///////-----------------/////////////
///////-----------------/////////////
//ROC ONLY
//Long Side
if LongShort =="Long Only" and AboveBelow == "Above" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Below" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Don't Include" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = rsi(close,ROCLength)<ROCLower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
//ROC ONLY
//SHORT SIDE
if LongShort =="Short Only" and AboveBelow == "Above" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Below" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Don't Include" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))
///////-----------------/////////////
///////-----------------/////////////
///////-----------------/////////////
//BOTH
//Long Side
if LongShort =="Long Only" and AboveBelow == "Above" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Below" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Don't Include" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
//BOTH
//SHORT SIDE
if LongShort =="Short Only" and AboveBelow == "Above" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Below" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Don't Include" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))