
Chiến lược này là một hệ thống giao dịch dựa trên phân tích nhiều chu kỳ thời gian, chủ yếu sử dụng khoảng giá trung tâm (CPR), chỉ số di chuyển trung bình (EMA) và chỉ số tương đối mạnh (RSI) để giao dịch. Chiến lược này xác định xu hướng thị trường và các mức kháng cự hỗ trợ quan trọng thông qua mức CPR hàng ngày, giá mở cửa hàng tuần và 20 chu kỳ EMA và kết hợp xác nhận giao dịch để thực hiện giao dịch.
Trung tâm của chiến lược là tìm kiếm cơ hội giao dịch bằng cách phân tích mối quan hệ giữa giá và mức CPR. CPR bao gồm điểm trung tâm chính (Pivot), đường trung tâm dưới (BC) và đường trung tâm trên (TC). Khi giá vượt qua TC và thị trường ở giai đoạn nhiều đầu, hệ thống sẽ phát ra nhiều tín hiệu; Khi giá giảm xuống BC và thị trường ở giai đoạn trống, hệ thống sẽ phát ra tín hiệu trống.
Đây là một chiến lược theo dõi xu hướng có cấu trúc, logic rõ ràng, kiểm soát rủi ro giao dịch một cách hiệu quả thông qua việc sử dụng nhiều chỉ số kỹ thuật. Ưu điểm chính của chiến lược là thiết lập tham số linh hoạt và cơ chế quản lý rủi ro tốt, nhưng đồng thời cũng yêu cầu các nhà giao dịch chú ý đến sự thay đổi của môi trường thị trường và điều chỉnh các tham số chiến lược kịp thời.
//@version=5
strategy("Ahmad Ali Khan CPR Strategy", overlay=true, margin_long=100, margin_short=100)
// ———— Inputs ————
use_daily_cpr = input.bool(true, "Use Daily CPR Levels")
ema_length = input.int(20, "EMA Trend Filter Length")
show_week_open = input.bool(true, "Show Weekly Open Price")
enable_divergence = input.bool(true, "Enable RSI Divergence Check")
// ———— Daily CPR Calculation ————
daily_high = request.security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
daily_low = request.security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)
daily_close = request.security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_on)
pivot = (daily_high + daily_low + daily_close) / 3
bc = (daily_high + daily_low) / 2
tc = pivot + (pivot - bc)
// ———— Weekly Open Price ————
weekly_open = request.security(syminfo.tickerid, "W", open, lookahead=barmerge.lookahead_on)
// ———— Trend Analysis ————
ema_trend = ta.ema(close, ema_length)
market_phase = close > ema_trend ? "Bullish" : "Bearish"
// ———— Momentum Confirmation ————
rsi_length = 14
rsi = ta.rsi(close, rsi_length)
bullish_div = ta.valuewhen(ta.crossover(rsi, 30), low, 0) > ta.valuewhen(ta.crossover(rsi, 30), low, 1)
bearish_div = ta.valuewhen(ta.crossunder(rsi, 70), high, 0) < ta.valuewhen(ta.crossunder(rsi, 70), high, 1)
// ———— Plotting ————
// CPR Levels
plot(pivot, "Pivot", color=color.blue, linewidth=2)
plot(bc, "BC", color=color.red, linewidth=2)
plot(tc, "TC", color=color.green, linewidth=2)
fill(plot(bc), plot(tc), color=color.new(color.purple, 90))
// Weekly Open
plot(show_week_open ? weekly_open : na, "Weekly Open", color=color.orange, linewidth=2)
// EMA Trend
plot(ema_trend, "EMA Trend", color=color.white, linewidth=2)
// ———— Strategy Logic ————
long_condition =
close > tc and
market_phase == "Bullish" and
(not enable_divergence or bullish_div) and
volume > ta.sma(volume, 20)
short_condition =
close < bc and
market_phase == "Bearish" and
(not enable_divergence or bearish_div) and
volume > ta.sma(volume, 20)
// ———— Risk Management ————
cpr_width = tc - bc
stop_loss_long = bc - (0.5 * cpr_width)
take_profit_long = tc + (1.5 * cpr_width)
stop_loss_short = tc + (0.5 * cpr_width)
take_profit_short = bc - (1.5 * cpr_width)
// ———— Execute Orders ————
if long_condition
strategy.entry("Long", strategy.long)
strategy.exit("XL", "Long", stop=stop_loss_long, limit=take_profit_long)
if short_condition
strategy.entry("Short", strategy.short)
strategy.exit("XS", "Short", stop=stop_loss_short, limit=take_profit_short)
// ———— Signal Plotting ————
plotshape(long_condition, "Buy", shape.labelup, location.belowbar, color=color.green, text="BUY", textcolor=color.white)
plotshape(short_condition, "Sell", shape.labeldown, location.abovebar, color=color.red, text="SELL", textcolor=color.white)