
Chiến lược này là một hệ thống giao dịch đảo chiều và theo dõi xu hướng tiên tiến dựa trên các mức thoái lui Fibonacci. Công cụ này thực hiện điều này bằng cách xác định mức giá cao và thấp một cách linh hoạt, tự động tính toán và vẽ biểu đồ bảy mức thoái lui Fibonacci chính (0%, 23,6%, 38,2%, 50%, 61,8%, 78,6% và 100%). Xác định các mức hỗ trợ và kháng cự tiềm năng. Hệ thống áp dụng cơ chế giao dịch hai chiều, có thể nắm bắt cơ hội mua vào khi xu hướng tăng và cơ hội bán khống khi xu hướng giảm.
Logic cốt lõi của chiến lược này dựa trên các yếu tố chính sau:
Chiến lược này xây dựng một hệ thống giao dịch toàn diện bằng cách kết hợp lý thuyết thoái lui Fibonacci cổ điển với các kỹ thuật giao dịch định lượng hiện đại. Ưu điểm của nó là có thể tự động xác định các mức giá quan trọng và cung cấp tín hiệu giao dịch rõ ràng, nhưng cũng cần phải chú ý đến tác động của môi trường thị trường đến hiệu suất chiến lược. Thông qua các hướng tối ưu hóa được đề xuất, tính ổn định và lợi nhuận của chiến lược dự kiến sẽ được cải thiện hơn nữa.
/*backtest
start: 2024-01-06 00:00:00
end: 2025-01-05 00:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Fibonacci Retracement Strategy for Crypto", overlay=true)
// Input parameters
lookback = input.int(50, title="Lookback Period", minval=1)
plotLevels = input.bool(true, title="Plot Fibonacci Levels?")
compactLines = input.bool(true, title="Compact Fibonacci Lines?")
// Calculate highest high and lowest low for the lookback period
highestHigh = ta.highest(high, lookback)
lowestLow = ta.lowest(low, lookback)
// Fibonacci retracement levels
diff = highestHigh - lowestLow
level0 = highestHigh
level23_6 = highestHigh - diff * 0.236
level38_2 = highestHigh - diff * 0.382
level50 = highestHigh - diff * 0.5
level61_8 = highestHigh - diff * 0.618
level78_6 = highestHigh - diff * 0.786
level100 = lowestLow
// Plot Fibonacci levels (compact mode to make lines shorter)
// if plotLevels
// lineStyle = compactLines ? line.style_dashed : line.style_solid
// line.new(bar_index[lookback], level0, bar_index, level0, color=color.green, width=1, style=lineStyle)
// line.new(bar_index[lookback], level23_6, bar_index, level23_6, color=color.blue, width=1, style=lineStyle)
// line.new(bar_index[lookback], level38_2, bar_index, level38_2, color=color.blue, width=1, style=lineStyle)
// line.new(bar_index[lookback], level50, bar_index, level50, color=color.orange, width=1, style=lineStyle)
// line.new(bar_index[lookback], level61_8, bar_index, level61_8, color=color.red, width=1, style=lineStyle)
// line.new(bar_index[lookback], level78_6, bar_index, level78_6, color=color.red, width=1, style=lineStyle)
// line.new(bar_index[lookback], level100, bar_index, level100, color=color.green, width=1, style=lineStyle)
// Long trade: Buy when price crosses above 61.8% retracement
longCondition = ta.crossover(close, level61_8)
if longCondition
strategy.entry("Long", strategy.long, alert_message="Price bounced off Fibonacci level - Enter Long")
// Short trade: Sell when price crosses below 38.2% retracement
shortCondition = ta.crossunder(close, level38_2)
if shortCondition
strategy.entry("Short", strategy.short, alert_message="Price crossed below Fibonacci level - Enter Short")
// Exit conditions
exitLong = close >= level23_6
if exitLong
strategy.close("Long", alert_message="Price reached 23.6% Fibonacci level - Exit Long")
exitShort = close <= level78_6
if exitShort
strategy.close("Short", alert_message="Price reached 78.6% Fibonacci level - Exit Short")