斐波那契黄金分割回撤买入策略是一种基于斐波那契回撤水平和趋势跟踪止损的交易策略。该策略利用斐波那契回撤水平作为潜在的支撑位和阻力位,并结合趋势跟踪止损来确定买入和卖出时机。当价格在上涨趋势中回撤到某个斐波那契水平并且高于趋势跟踪止损时,策略会发出买入信号;当价格跌破趋势跟踪止损或某个斐波那契水平时,策略会发出卖出信号。
斐波那契黄金分割回撤买入策略是一种结合斐波那契回撤水平和趋势跟踪止损的交易策略。该策略利用斐波那契回撤水平作为潜在的支撑位和阻力位,并结合趋势跟踪止损来确定买入和卖出时机。策略的优势在于结合技术分析和趋势跟踪,适应不同市场状况,并提供明确的进场和出场条件。然而,策略也面临市场波动风险、参数设置风险和趋势识别风险。为了优化策略表现,可以考虑结合其他技术指标、动态调整参数以及引入风险管理措施。
/*backtest start: 2023-04-23 00:00:00 end: 2024-04-28 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy(title='Fibonacci BFSP', overlay=true) // Define Fibonacci retracement levels fib0 = input(0, title="Fibonacci 0% Level") fib1 = input(1, title="Fibonacci 1% Level") fib23 = input(0.236, title="Fibonacci 23.6% Level") fib38 = input(0.382, title="Fibonacci 38.2% Level") fib50 = input(0.5, title="Fibonacci 50% Level") fib61 = input(0.618, title="Fibonacci 61.8% Level") fib78 = input(0.786, title="Fibonacci 78.6% Level") Price = input(50, title="Price") // Calculate Fibonacci levels priceHigh = ta.highest(high, Price) priceLow = ta.lowest(low, Price) priceRange = priceHigh - priceLow fibRetracement0 = priceHigh - fib0 * priceRange fibRetracement1 = priceHigh - fib1 * priceRange fibRetracement23 = priceHigh - fib23 * priceRange fibRetracement38 = priceHigh - fib38 * priceRange fibRetracement50 = priceHigh - fib50 * priceRange fibRetracement61 = priceHigh - fib61 * priceRange fibRetracement78 = priceHigh - fib78 * priceRange // Plot Fibonacci retracement levels plot(fibRetracement0, color=color.gray, linewidth=2) plot(fibRetracement1, color=color.gray, linewidth=2) plot(fibRetracement23, color=color.green, linewidth=2) plot(fibRetracement38, color=color.olive, linewidth=2) plot(fibRetracement50, color=color.white, linewidth=2) plot(fibRetracement61, color=color.orange, linewidth=2) plot(fibRetracement78, color=color.red, linewidth=2) // Inputs no = input(1, title="Swing") // Calculate swing highs and lows res = ta.highest(high, no) sup = ta.lowest(low, no) // Calculate trailing stop loss avd = close > res[1] ? 1 : close < sup[1] ? -1 : 0 avn = ta.valuewhen(avd != 0, avd, 0) tsl = avn == 1 ? sup : res // Define buy and sell conditions buyCondition = (close > tsl) and (close > fibRetracement23 or close > fibRetracement38 or close > fibRetracement50 or close > fibRetracement61 or close > fibRetracement78) sellCondition = (close < tsl) and (close < fibRetracement23 or close < fibRetracement38 or close < fibRetracement50 or close < fibRetracement61 or close < fibRetracement78) // Entry strategy if (buyCondition) strategy.entry("Buy", strategy.long) // Exit strategy if (sellCondition) strategy.close("Buy") // Color bars based on buy and sell conditions barColor = buyCondition ? color.green : sellCondition ? color.red : na barcolor(barColor)