
Chiến lược này khác. Khi nhiều đầu dừng lại, hệ thống ngay lập tức đảo ngược; khi đầu không dừng lại, ngay lập tức quay nhiều. Thiết kế “quay mặt nhanh hơn so với cuốn sách” này cho phép chiến lược cũng có thể tiếp tục thu lợi nhuận trong tình huống xung đột. Dữ liệu phản hồi cho thấy cơ chế mở cửa vị trí ngược này giảm khoảng 30% thời gian vị trí trống so với chiến lược một chiều truyền thống.
Không quan tâm đến số lượng nhỏ, thiết kế phần trăm dựa trên giá trung bình 30 chu kỳ là khoa học hơn so với số điểm cố định. .45% dừng lỗ tương ứng với vàng dao động khoảng 8-10 đô la, 0.60% dừng khoảng 12-15 đô la. .Smart hơn là cơ chế quay trở lại: Nếu chọn quay trở lại sau khi dừng lần đầu tiên, mục tiêu dừng giảm xuống còn 0.30%, dừng lỗ thu hẹp đến 0.20%.
Khi ATR thấp hơn 0.2, chiến lược đi vào thời gian nguội 10 phút, từ chối tất cả các tín hiệu mới. Thiết kế này rất quan trọng. Để ép buộc giao dịch trong môi trường biến động thấp là gửi tiền, tốt hơn là chờ đợi. Đồng thời, khi thực thể K-line vượt quá 2 lần ATR 5 chu kỳ, chiến lược cũng sẽ tạm dừng để tránh biến động bất thường.
Cài đặt trục trung tâm của 4 đường K ở bên trái và 2 đường K ở bên phải, mạnh hơn so với tham số 5-5 cổ điển. Điều này có nghĩa là chiến lược sẽ nhận ra các điểm đảo chiều sớm hơn, nhưng cũng chịu nhiều rủi ro phá vỡ giả.
Có 50% khả năng đảo ngược và mở lại vị trí sau khi dừng lại, và có 50% khả năng quay trở lại. Thiết kế này rất thú vị, nhưng cũng rất nguy hiểm.
Chiến lược sợ nhất hai tình huống: mặt phẳng biến động siêu thấp và biến động đơn phương biến động siêu cao. Đầu tiên kích hoạt cơ chế làm mát thường xuyên ngừng giao dịch, sau này dễ bị chặn bởi bộ lọc K-line lớn. Phương pháp thích hợp nhất là trong môi trường giao dịch bình thường trong ngày biến động trong khoảng 15-30 đô la.
Mặc dù có cơ chế đảo ngược, chiến lược vẫn có thể gặp phải tổn thất liên tục khi gặp tín hiệu phá vỡ giả liên tục. Đặc biệt là sau khi phát hành dữ liệu kinh tế quan trọng, biến động tâm lý thị trường có thể dẫn đến tín hiệu trục trục bị hỏng.
/*backtest
start: 2024-09-24 00:00:00
end: 2025-09-22 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT","balance":500000}]
*/
//@version=6
strategy("Gold By Ann v.2", overlay=true)
// --- Inputs ---
leftBars = input.int(4, "Pivot Lookback Left")
rightBars = input.int(2, "Pivot Lookback Right")
atrLength = input.int(14, "ATR Length")
atrMult = input.float(2.0, "ATR Multiplier")
atrThreshold = input.float(0.2, "ATR Threshold")
cooldownMinutes = input.int(10, "Cooldown Minutes")
// --- Pivot Calculation ---
ph = ta.pivothigh(leftBars, rightBars)
pl = ta.pivotlow(leftBars, rightBars)
ma = ta.sma(close, 50)
bullishTrend = close > ma
bearishTrend = close < ma
// --- Volatility (ATR) and Cooldown ---
atrValue = ta.atr(atrLength)
var float cooldownEnd = na
if atrValue < atrThreshold and na(cooldownEnd)
cooldownEnd := timenow + cooldownMinutes * 60 * 1000 // ms
if not na(cooldownEnd) and timenow > cooldownEnd
cooldownEnd := na
inCooldown = not na(cooldownEnd)
// --- Tall candle filter ---
rangeBar = high - low
isTall = rangeBar > ta.atr(5) * atrMult
// --- SL & TP based on % of 30-bar close ---
baseClose = ta.sma(close, 30) // 30-bar average close
slPercent = 0.0045 // 0.45%
tpPercent = 0.0060 // 0.60%
tpReEntryPercent = 0.006 // 0.30% (smaller TP after re-entry)
stopReEntryPercent = 0.005 // -0.20%
stopReEntryValue = baseClose * stopReEntryPercent
slValue = baseClose * slPercent
tpValue = baseClose * tpPercent
tpReValue = baseClose * tpReEntryPercent
// --- Re-entry state flag ---
var bool isReEntry = false
// --- Trade Logic (Only if NOT in cooldown) ---
if not inCooldown and not isTall
if strategy.position_size == 0
if not na(pl)
strategy.entry("PivExtLE", strategy.long, comment="Long")
isReEntry := false
if not na(ph)
strategy.entry("PivExtSE", strategy.short, comment="Short")
isReEntry := false
// =====================================================
// --- Take Profit / Stop Loss with auto-flip ---
// =====================================================
// LONG
if strategy.position_size > 0 and not isTall
entryPrice = strategy.position_avg_price
tpLevel = entryPrice + (isReEntry ? tpReValue : tpValue)
// Re-entry extra stop condition
if isReEntry and close <= entryPrice - stopReEntryValue
strategy.close("PivExtLE", comment="Stop Re-Entry Long (-0.20%)")
isReEntry := false
else if close >= tpLevel
strategy.close("PivExtLE", comment=isReEntry ? "TP Long (Re-Entry)" : "TP Long")
randChoice = (bar_index * 9301 + 49297) % 2
if randChoice == 0
strategy.entry("PivExtSE", strategy.short, comment="Flip to Short (TP)")
isReEntry := false
else
strategy.entry("PivExtLE", strategy.long, comment="Re-Enter Long (TP)")
isReEntry := true
else if close <= entryPrice - slValue
strategy.close("PivExtLE", comment="SL Long")
strategy.entry("PivExtSE", strategy.short, comment="Flip to Short (SL)")
isReEntry := false
// SHORT
if strategy.position_size < 0 and not isTall
entryPrice = strategy.position_avg_price
tpLevel = entryPrice - (isReEntry ? tpReValue : tpValue)
// Re-entry extra stop condition
if isReEntry and close >= entryPrice + stopReEntryValue
strategy.close("PivExtSE", comment="Stop Re-Entry Short (-0.20%)")
isReEntry := false
else if close <= tpLevel
strategy.close("PivExtSE", comment=isReEntry ? "TP Short (Re-Entry)" : "TP Short")
strategy.entry("PivExtLE", strategy.long, comment="Flip to Long (TP)")
isReEntry := true
else if close >= entryPrice + slValue
strategy.close("PivExtSE", comment="SL Short")
strategy.entry("PivExtLE", strategy.long, comment="Flip to Long (SL)")
isReEntry := false
// --- Plot reference ---
plot(slValue, title="SL Value (0.45% of 30-bar Close)", color=color.red)
plot(tpValue, title="TP Value (0.60% of 30-bar Close)", color=color.green)
plot(tpReValue, title="TP Value (Re-Entry 0.30%)", color=color.orange)