
Chiến lược này được thiết kế dựa trên chỉ số Ichimoku Cloud Chart, một hệ thống giao dịch định lượng, chủ yếu dành cho các tài sản có xu hướng tốt. Chiến lược này kết hợp các chức năng như dừng lỗ, dừng lỗ và theo dõi lỗ để đạt được lợi nhuận ổn định.
Bảng Ichimoku được tạo thành từ các đường chuyển đổi, đường chuẩn, đường trục 1, đường trục 2 và đường trục. Các tín hiệu giao dịch của chiến lược này được lấy từ mối quan hệ giữa giá và đường trục. Cụ thể, khi giá lên vượt qua đường trục 1 tạo ra tín hiệu mua; khi giá xuống vượt qua đường trục 1 tạo ra tín hiệu bán. Ngoài ra, đường trục 2 cũng có thể được sử dụng như một chỉ số phán đoán phụ trợ.
Chiến lược này cũng thiết lập các điểm dừng lỗ và điểm dừng dựa trên chỉ số ATR. Chỉ số ATR có thể nắm bắt hiệu quả mức độ biến động của thị trường. Điểm dừng lỗ là 2 lần so với ATR và điểm dừng là 4 lần so với ATR. Điều này có thể kiểm soát hiệu quả tổn thất đơn lẻ và khóa phần lợi nhuận.
Cuối cùng, chiến lược này sử dụng cơ chế theo dõi dừng lỗ. Cụ thể là, cho đặt hàng nhiều, sẽ sử dụng gấp 2 lần ATR để rút lui, điều chỉnh đường dừng lỗ trong thời gian thực để khóa lợi nhuận; cho đặt hàng không, sẽ sử dụng gấp 2 lần ATR để rút lui, điều chỉnh đường dừng lỗ trong thời gian thực để khóa lợi nhuận.
Giải pháp đối phó với rủi ro:
Chiến lược này nói chung là một chiến lược theo dõi xu hướng ổn định. Xác định hướng xu hướng dựa trên chỉ số biểu đồ đám mây Ichimoku; sử dụng chỉ số ATR để thiết lập điểm dừng lỗ; sử dụng theo dõi dừng lỗ để khóa lợi nhuận. Ưu điểm là logic đơn giản, dễ hiểu; có thể kiểm soát tổn thất đơn; có thể theo dõi xu hướng hiệu quả.
/*backtest
start: 2023-01-05 00:00:00
end: 2024-01-11 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Ichimoku Cloud Strategy with SL, TP, and Trailing Stop", overlay=true)
conversionPeriods = input(9, "Conversion Line Length")
basePeriods = input(26, "Base Line Length")
laggingSpan2Periods = input(52, "Leading Span B Length")
displacement = input(26, "Lagging Span")
atrLength = input(14, title="ATR Length")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
// Plot the Ichimoku Cloud components
plot(conversionLine, color=color.blue, title="Conversion Line")
plot(baseLine, color=color.red, title="Base Line")
plot(leadLine1, color=color.green, title="Leading Span A")
plot(leadLine2, color=color.orange, title="Leading Span B")
plot(leadLine1 > leadLine2 ? leadLine1 : leadLine2, color=color.green, title="Kumo Cloud Upper Line")
plot(leadLine1 < leadLine2 ? leadLine1 : leadLine2, color=color.red, title="Kumo Cloud Lower Line")
// ATR for stop loss and take profit
atrValue = ta.atr(atrLength)
stopLoss = atrValue * 2
takeProfit = atrValue * 4
// Strategy entry and exit conditions
longCondition = ta.crossover(close, leadLine1) and close > leadLine2
shortCondition = ta.crossunder(close, leadLine1) and close < leadLine2
// Plot buy and sell signals
plotshape(series=longCondition ? leadLine1 : na, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(series=shortCondition ? leadLine1 : na, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
// Execute strategy orders with stop loss and take profit
strategy.entry("Buy", strategy.long, when=longCondition)
strategy.close("Buy", when=shortCondition) // Close buy position when sell condition is met
strategy.entry("Sell", strategy.short, when=shortCondition)
strategy.close("Sell", when=longCondition) // Close sell position when buy condition is met
// Trailing stop
strategy.cancel("Trailing Stop")
var float trailingStopPrice = na
if (longCondition)
trailingStopPrice := math.max(trailingStopPrice, close - atrValue * 2)
strategy.exit("Trailing Stop", from_entry="Buy", trail_offset=atrValue * 2, trail_price=trailingStopPrice)
else if (shortCondition)
trailingStopPrice := math.min(trailingStopPrice, close + atrValue * 2)
strategy.exit("Trailing Stop", from_entry="Sell", trail_offset=atrValue * 2, trail_price=trailingStopPrice)