Chiến lược giao dịch tỷ lệ phần trăm của Heikin Ashi ROC

Tác giả:ChaoZhang, Ngày: 2023-10-23 15:41:40
Tags:

img

Tổng quan

Chiến lược này được gọi là Heikin Ashi ROC Percentile Trading Strategy. Nó nhằm mục đích cung cấp một khuôn khổ giao dịch dễ sử dụng dựa trên Heikin Ashi ROC và các phần trăm của nó.

Chiến lược logic

Chiến lược này tính toán ROC của Heikin Ashi giá đóng cửa trong những khoảng thời gian trước đó. Sau đó nó tính toán các giá trị cao nhất rocHigh và thấp nhất rocLow của ROC trong 50 khoảng thời gian qua. Đường sắt trên upperKillLine và đường sắt dưới dưới KillLine được tạo ra dựa trên một số tỷ lệ phần trăm của rocHigh và rocLow. Khi ROC vượt qua trên lowerKillLine, một vị trí dài được mở. Khi ROC vượt qua dưới upperKillLine, vị trí dài được đóng. Ngược lại, khi ROC vượt qua dưới upperKillLine, một vị trí ngắn được mở. Khi ROC vượt qua trên lowerKillLine, vị trí ngắn được đóng.

Phân tích lợi thế

Lợi thế lớn nhất của chiến lược này là sử dụng khả năng theo dõi xu hướng mạnh mẽ của chỉ số ROC, kết hợp với tính năng làm mịn thông tin giá của Heikin Ashi. Điều này cho phép chiến lược xác định hiệu quả những thay đổi xu hướng và thực hiện giao dịch kịp thời. So với các đường trung bình động đơn giản, ROC phản ứng nhạy cảm hơn với những thay đổi giá. Ngoài ra, các đường ray trên và dưới được tạo ra từ các phần trăm có thể lọc hiệu quả các hợp nhất và tránh các giao dịch không cần thiết từ các đột phá giả. Nhìn chung, chiến lược này kết hợp cả việc theo xu hướng và lọc dao động để đạt được tỷ lệ rủi ro-lợi nhuận tốt trong các xu hướng chính.

Phân tích rủi ro

Rủi ro chính của chiến lược này là việc cài đặt tham số không đúng có thể dẫn đến quá mức giao dịch hoặc độ nhạy không đủ. Thời gian xem lại độ dài và tỷ lệ phần trăm cần được thiết lập một cách thận trọng, nếu không đường ray có thể trở nên quá mờ hoặc cứng, gây ra các giao dịch bị bỏ lỡ hoặc thua lỗ không cần thiết. Ngoài ra, các thiết lập tỷ lệ phần trăm cần phải được kiểm tra lại nhiều lần và điều chỉnh cho các thị trường khác nhau để tìm kết hợp tối ưu. Chiến lược cũng chịu một số lỗ nhất định khi xu hướng đảo ngược, do nó phụ thuộc vào các chỉ số theo xu hướng. Các vị trí nên được đóng kịp thời hoặc dừng lỗ được thiết lập để kiểm soát rủi ro.

Hướng dẫn tối ưu hóa

Chiến lược có thể được tối ưu hóa theo các cách sau: 1) Thêm các bộ lọc với các chỉ số khác như RSI; 2) Tối ưu hóa các tham số một cách năng động với máy học; 3) Đặt dừng lỗ và lấy lợi nhuận để quản lý rủi ro tự động; 4) Kết hợp với các chiến lược không theo xu hướng để cân bằng rủi ro.

Tóm lại

Tóm lại, chiến lược này sử dụng khả năng theo dõi xu hướng mạnh mẽ của chỉ số ROC, kết hợp với Heikin Ashi để xác định xu hướng và theo dõi. Các đường ray phía trên và phía dưới được tạo ra từ tỷ lệ phần trăm ROC cho phép lọc lỗ hiệu quả. Điều này đạt được hiệu suất theo dõi xu hướng tốt.


/*backtest
start: 2023-09-22 00:00:00
end: 2023-10-22 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/
// © jensenvilhelm

//@version=5
strategy("Heikin Ashi ROC Percentile Strategy", shorttitle="ROC ON" , overlay=false)

// User Inputs
zerohLine = input(0, title="Midline")  // Zero line, baseline for ROC (customer can modify this to adjust midline)
rocLength = input(100, title="roc Length")  // Lookback period for SMA and ROC (customer can modify this to adjust lookback period)

stopLossLevel = input(2, title="Stop Loss (%)")  // Level at which the strategy stops the loss (customer can modify this to adjust stop loss level)
startDate = timestamp("2015 03 03")  // Start date for the strategy (customer can modify this to adjust start date)

// Heikin Ashi values
var float haClose = na  // Define Heikin Ashi close price
var float haOpen = na  // Define Heikin Ashi open price
haClose := ohlc4  // Calculate Heikin Ashi close price as average of OHLC4 (no customer modification needed here)
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2  // Calculate Heikin Ashi open price (no customer modification needed here)

// ROC Calculation
roc = ta.roc(ta.sma(haClose, rocLength), rocLength)  // Calculate Rate of Change (ROC) (customer can modify rocLength in the inputs)
rocHigh = ta.highest(roc, 50)  // Get the highest ROC of the last 50 periods (customer can modify this to adjust lookback period)
rocLow = ta.lowest(roc, 50)  // Get the lowest ROC of the last 50 periods (customer can modify this to adjust lookback period)
upperKillLine = ta.percentile_linear_interpolation(rocHigh, 10, 75)  // Calculate upper kill line (customer can modify parameters to adjust this line)
lowerKillLine = ta.percentile_linear_interpolation(rocLow, 10, 25)  // Calculate lower kill line (customer can modify parameters to adjust this line)

// Trade conditions
enterLong = ta.crossover(roc, lowerKillLine)  // Define when to enter long positions (customer can modify conditions to adjust entry points)
exitLong = ta.crossunder(roc, upperKillLine)  // Define when to exit long positions (customer can modify conditions to adjust exit points)
enterShort = ta.crossunder(roc, upperKillLine)  // Define when to enter short positions (customer can modify conditions to adjust entry points)
exitShort = ta.crossover(roc, lowerKillLine )  // Define when to exit short positions (customer can modify conditions to adjust exit points)

// Strategy execution
if(time >= startDate)  // Start strategy from specified start date
    if (enterLong)
        strategy.entry("Long", strategy.long)  // Execute long trades
    if (exitLong)
        strategy.close("Long")  // Close long trades
    if (enterShort)
        strategy.entry("Short", strategy.short)  // Execute short trades
    if (exitShort)
        strategy.close("Short")  // Close short trades

// Plotting
plot(zerohLine,title="Zeroline")  // Plot zero line
plot(roc, "RSI", color=color.rgb(248, 248, 248))  // Plot ROC
plot(rocHigh, "Roc High", color = color.rgb(175, 78, 76))  // Plot highest ROC
plot(rocLow, "Roc Low", color = color.rgb(175, 78, 76))  // Plot lowest ROC
plot(upperKillLine, "Upper Kill Line", color = color.aqua)  // Plot upper kill line
plot(lowerKillLine, "Lower Kill Line", color = color.aqua)  // Plot lower kill line


Thêm nữa