
Chiến lược này là một hệ thống giao dịch theo dõi xu hướng dựa trên lý thuyết hành vi giá Albrooks và MACD. Nó xác định xu hướng thị trường bằng cách kết hợp đường trung bình di chuyển (SMA) và MACD và giao dịch vào thời điểm thích hợp. Chiến lược sử dụng tỷ lệ lợi nhuận rủi ro cố định để quản lý mức dừng lỗ và dừng chân cho mỗi giao dịch, để kiểm soát rủi ro hiệu quả.
Logic cốt lõi của chiến lược bao gồm các yếu tố chính sau:
Đây là một hệ thống giao dịch hoàn chỉnh kết hợp lý thuyết hành vi giá cổ điển với các chỉ số kỹ thuật. Chiến lược đạt được hiệu quả giao dịch tương đối ổn định thông qua cơ chế xác nhận tín hiệu nghiêm ngặt và phương pháp quản lý rủi ro. Mặc dù có một số rủi ro vốn có, nhưng sự ổn định và lợi nhuận của chiến lược có thể được nâng cao hơn nữa thông qua hướng tối ưu hóa được đề xuất.
/*backtest
start: 2024-11-15 00:00:00
end: 2025-02-18 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"DOGE_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Abdulhossein
//@version=6
strategy(title="Al Brooks Price Action with MACD Signals", shorttitle="Al Brooks PA + MACD", overlay=true)
// Inputs
length = input.int(52, title="Moving Average Length", minval=1)
riskRewardRatio = input.float(2.0, title="Risk/Reward Ratio", minval=1.0)
stopLossBuffer = input.float(0.01, title="Stop Loss Buffer (in %)", minval=0.001)
candleType = input.string("Close", title="Candle Type", options=["Close", "Open"])
// Indicators
sma = ta.sma(close, length)
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
price = candleType == "Close" ? close : open
// Trend Conditions
uptrend = price > sma
downtrend = price < sma
// Buy/Sell Signals
buySignal = price > sma and macdLine > 0 and macdLine > signalLine
sellSignal = price < sma and macdLine < 0 and macdLine < signalLine
// Trade Execution
if (buySignal)
longStopLoss = close * (1 - stopLossBuffer)
longTakeProfit = close + (close - longStopLoss) * riskRewardRatio
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit", "Buy", limit=longTakeProfit, stop=longStopLoss)
if (sellSignal)
shortStopLoss = close * (1 + stopLossBuffer)
shortTakeProfit = close - (shortStopLoss - close) * riskRewardRatio
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit", "Sell", limit=shortTakeProfit, stop=shortStopLoss)
// Plot Signals
plotarrow(buySignal[2] ? 1 : na, colorup=color.new(color.green, 50), title="Buy Signal Arrow", offset=-1)
plotarrow(sellSignal[2] ? -1 : na, colordown=color.new(color.red, 50), title="Sell Signal Arrow", offset=-1)
// Close Positions
if (not buySignal and not sellSignal)
strategy.close("Sell")
strategy.close("Buy")
// Support and Resistance
support = ta.lowest(low, length)
resistance = ta.highest(high, length)
plot(support, title="Support", color=color.green, linewidth=1, style=plot.style_stepline)
plot(resistance, title="Resistance", color=color.red, linewidth=1, style=plot.style_stepline)
plot(sma, title="SMA", color=color.blue, linewidth=2)
// Alerts
alertcondition(buySignal[2], title="Buy Alert", message="Buy Signal Triggered")
alertcondition(sellSignal[2], title="Sell Alert", message="Sell Signal Triggered")