
Chiến lược này là một hệ thống giao dịch theo dõi xu hướng kết hợp kênh Donchian và đường trung bình di chuyển đơn giản 200 chu kỳ (SMA). Chiến lược này xác định các cơ hội mua và bán tiềm năng bằng cách quan sát giá phá vỡ đường truyền Donchian và kết hợp với chuyển động SMA.
Logic cốt lõi của chiến lược này dựa trên các yếu tố chính sau:
Đề xuất kiểm soát rủi ro:
Tối ưu hóa tín hiệu:
Tối ưu hóa Stop Loss:
Tối ưu hóa quản lý vị trí:
Tối ưu hóa thời gian:
Chiến lược này được xây dựng bằng cách kết hợp các thông tin cổ điển của đường Đông Dương và các chỉ số trung bình di chuyển, một hệ thống theo dõi xu hướng có logic rõ ràng, có thể kiểm soát rủi ro. Ưu điểm chính của chiến lược là tín hiệu rõ ràng, kiểm soát rủi ro hợp lý, nhưng có thể không hoạt động tốt trong thị trường biến động.
/*backtest
start: 2024-02-21 00:00:00
end: 2024-03-18 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ardhankurniawan
//@version=5
strategy("Donchian Channel Strategy with SMA 200 and Custom SL", overlay=true)
// Parameters
length = 20
smaLength = 200 // Changed SMA to 200
// Calculate Donchian Channel
upper = ta.highest(high, length)
lower = ta.lowest(low, length)
mid = (upper + lower) / 2 // Mid Line
// Calculate SMA 200
sma200 = ta.sma(close, smaLength)
// Plot Donchian Channel, SMA 200, and Mid Line
plot(upper, color=color.green, linewidth=2, title="Upper Line")
plot(lower, color=color.red, linewidth=2, title="Lower Line")
plot(mid, color=color.orange, linewidth=1, title="Mid Line")
plot(sma200, color=color.blue, linewidth=2, title="SMA 200")
// Long and Short logic based on SMA 200
longCondition = upper > ta.highest(upper[1], length) and close > sma200
shortCondition = lower < ta.lowest(lower[1], length) and close < sma200
// Calculate Stop Loss for Long and Short based on new conditions
longSL = mid - 0.45 * (mid - lower) // SL for Long when price crosses down mid line
shortSL = mid + 0.45 * (upper - mid) // SL for Short when price crosses up mid line
// Enter Long or Short position
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Place Stop Loss
strategy.exit("Exit Long", from_entry="Long", stop=longSL)
strategy.exit("Exit Short", from_entry="Short", stop=shortSL)