
Chiến lược này là một hệ thống giao dịch thông minh dựa trên tín hiệu chéo MACD. Nó tạo ra tín hiệu mua và bán bằng cách phân tích chéo của đường MACD với đường tín hiệu và hiển thị trực quan trên biểu đồ. Hệ thống này tích hợp các thông báo thời gian thực để thông báo cho các nhà giao dịch về cơ hội giao dịch tiềm năng.
Trung tâm của chiến lược là sử dụng chỉ số MACD để nắm bắt sự thay đổi động lực của thị trường. Thực hiện cụ thể bao gồm một số bước quan trọng sau:
Đây là một hệ thống chiến lược giao dịch MACD có cấu trúc và logic rõ ràng. Nó cung cấp cho các nhà giao dịch một công cụ giao dịch khách quan bằng cách hiển thị trực quan và thực hiện tự động. Mặc dù có một số rủi ro bị tụt hậu, nhưng bằng hướng tối ưu hóa được đề xuất, bạn có thể nâng cao hơn nữa sự ổn định và độ tin cậy của chiến lược.
/*backtest
start: 2024-02-10 00:00:00
end: 2025-02-09 00:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("ETH/USD MACD Crossover", overlay=true)
// MACD settings
fastLength = input(12, title="Fast EMA Length")
slowLength = input(26, title="Slow EMA Length")
signalLength = input(9, title="Signal Line Length")
// MACD calculation
[macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalLength)
// Plot MACD and Signal Line
plot(macdLine, color=color.blue, title="MACD Line", linewidth=2)
plot(signalLine, color=color.orange, title="Signal Line", linewidth=2)
hline(0, "Zero Line", color=color.gray)
// MACD Histogram
macdHistogram = macdLine - signalLine
plot(macdHistogram, color=macdHistogram >= 0 ? color.green : color.red, style=plot.style_histogram, title="MACD Histogram")
// Buy and Sell Conditions
buyCondition = ta.crossover(macdLine, signalLine) // MACD crosses above Signal Line
sellCondition = ta.crossunder(macdLine, signalLine) // MACD crosses below Signal Line
// Plot buy/sell signals on the chart
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Alerts for buy/sell conditions
if (buyCondition)
alert("MACD Crossover: BUY signal for ETH/USD", alert.freq_once_per_bar)
if (sellCondition)
alert("MACD Crossover: SELL signal for ETH/USD", alert.freq_once_per_bar)
// Strategy entry/exit
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.close("Buy")