This strategy is an advanced trend-following system based on Fibonacci retracement principles. It identifies potential support and resistance zones by dynamically calculating key Fibonacci retracement levels (23.6%, 38.2%, 50%, 61.8%, 78.6%). The system uses a 100-period lookback window to determine the highest and lowest points, which serve as the basis for calculating retracement levels. The strategy incorporates precise entry signals and risk management mechanisms, triggering trading signals at key Fibonacci level breakouts.
The core logic is built on the theory that prices tend to reverse near key Fibonacci retracement levels during major trends. Specifically:
This is a systematic trading strategy built on classic technical analysis theory. Its programmatic implementation provides objectivity and repeatability. The core advantage lies in combining Fibonacci theory with strict risk control, suitable for trending markets. Through continuous optimization and improvement, the strategy has the potential to maintain stable performance across various market conditions.
/*backtest start: 2024-11-11 00:00:00 end: 2024-12-10 08:00:00 period: 1h basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Fibonacci Retracement Strategy", overlay=true) // Inputs lookback_period = input.int(100, title="Lookback Period") level_1 = input.float(0.236, title="Fibonacci Level 1") level_2 = input.float(0.382, title="Fibonacci Level 2") level_3 = input.float(0.5, title="Fibonacci Level 3") level_4 = input.float(0.618, title="Fibonacci Level 4") level_5 = input.float(0.786, title="Fibonacci Level 5") // Calculate highest high and lowest low over the lookback period high_level = ta.highest(high, lookback_period) low_level = ta.lowest(low, lookback_period) // Calculate Fibonacci retracement levels fib_236 = low_level + (high_level - low_level) * level_1 fib_382 = low_level + (high_level - low_level) * level_2 fib_50 = low_level + (high_level - low_level) * level_3 fib_618 = low_level + (high_level - low_level) * level_4 fib_786 = low_level + (high_level - low_level) * level_5 // Plot Fibonacci levels on the chart plot(fib_236, color=color.green, title="Fib 23.6%") plot(fib_382, color=color.blue, title="Fib 38.2%") plot(fib_50, color=color.orange, title="Fib 50%") plot(fib_618, color=color.red, title="Fib 61.8%") plot(fib_786, color=color.purple, title="Fib 78.6%") // Entry and Exit Conditions buy_signal = ta.crossover(close, fib_618) sell_signal = ta.crossunder(close, fib_382) // Strategy Orders if buy_signal strategy.entry("Buy", strategy.long) // Exit based on stop-loss and take-profit conditions take_profit = high_level // Exit at the highest Fibonacci level (100%) stop_loss = low_level // Exit at the lowest Fibonacci level (0%) strategy.exit("Sell", from_entry="Buy", limit=take_profit, stop=stop_loss) // Visualization of Signals plotshape(series=buy_signal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY") plotshape(series=sell_signal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")