
Chiến lược này giao dịch dựa trên các đặc tính thống kê khi thị trường giảm mạnh. Bằng cách phân tích thống kê về sự rút lui, sử dụng chênh lệch tiêu chuẩn để đo mức độ cực đoan của biến động thị trường, mua khi thị trường giảm vượt quá phạm vi bình thường. Ý tưởng cốt lõi của chiến lược là nắm bắt cơ hội giảm mạnh do cảm xúc hoảng loạn của thị trường và xác định cơ hội đầu tư do hành vi phi lý của thị trường thông qua các phương pháp thống kê toán học.
Chiến lược sử dụng các tính năng thống kê về mức thu hồi và thu hồi tối đa của giá trong cửa sổ thời gian cuộn. Đầu tiên, tính giá cao nhất trong 50 chu kỳ qua, sau đó tính phần trăm thu hồi so với giá cao nhất hiện tại. Tiếp theo, tính trung bình và chênh lệch chuẩn của thu hồi, đặt chênh lệch chuẩn gấp 1 lần để kích hoạt ngưỡng thấp.
Chiến lược này có cơ sở lý thuyết và giá trị thực tế tốt. Lập luận chiến lược đơn giản và rõ ràng, tham số có thể điều chỉnh được, phù hợp để mở rộng và tối ưu hóa chiến lược cơ bản. Bằng cách thêm các chỉ số kỹ thuật khác và các biện pháp kiểm soát rủi ro, bạn có thể nâng cao hơn nữa sự ổn định và khả năng lợi nhuận của chiến lược. Trong giao dịch trực tiếp, nên kết hợp các đặc điểm của môi trường thị trường và loại giao dịch, đặt tham số cẩn thận, kiểm soát rủi ro tốt.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-28 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Buy When There's Blood in the Streets Strategy", overlay=false, shorttitle="BloodInTheStreets")
//This strategy identifies opportunities to buy during extreme market drawdowns based on standard deviation thresholds.
//It calculates the maximum drawdown over a user-defined lookback period, identifies extreme deviations from the mean,
//and triggers long entries when specific conditions are met. The position is exited after a defined number of bars.
// User Inputs
lookbackPeriod = input.int(50, title="Lookback Period", minval=1, tooltip="Period to calculate the highest high for drawdown")
stdDevLength = input.int(50, title="Standard Deviation Length", minval=1, tooltip="Length of the period to calculate standard deviation")
stdDevThreshold = input.float(-1.0, title="Standard Deviation Threshold", tooltip="Trigger level for long entry based on deviations")
exitBars = input.int(35, title="Exit After (Bars)", minval=1, tooltip="Number of bars after which to exit the trade")
// Drawdown Calculation
peakHigh = ta.highest(high, lookbackPeriod)
drawdown = ((close - peakHigh) / peakHigh) * 100
// Standard Deviation Calculation
drawdownStdDev = ta.stdev(drawdown, stdDevLength)
meanDrawdown = ta.sma(drawdown, stdDevLength)
// Define Standard Deviation Levels
stdDev1 = meanDrawdown - drawdownStdDev
stdDev2 = meanDrawdown - 2 * drawdownStdDev
stdDev3 = meanDrawdown - 3 * drawdownStdDev
// Plot Drawdown and Levels
plot(drawdown, color=color.red, linewidth=2, title="Drawdown (%)")
plot(meanDrawdown, color=color.blue, linewidth=2, title="Mean Drawdown")
plot(stdDev1, color=color.green, linewidth=1, title="1st Std Dev")
plot(stdDev2, color=color.orange, linewidth=1, title="2nd Std Dev")
plot(stdDev3, color=color.purple, linewidth=1, title="3rd Std Dev")
// Entry Condition
var float entryBar = na
goLong = drawdown <= meanDrawdown + stdDevThreshold * drawdownStdDev
if (goLong and strategy.position_size == 0)
strategy.entry("Long", strategy.long)
entryBar := bar_index
// Exit Condition
if (strategy.position_size > 0 and not na(entryBar) and bar_index - entryBar >= exitBars)
strategy.close("Long")