Fibonacci HMA AI Buy Sell Signal Strategy

Author: ChaoZhang, Date: 2023-12-29 11:24:34



This strategy introduces a trading approach leveraging Fibonacci-based Hull Moving Averages (HMA) aimed at identifying potential buy and sell signals. By employing distinct HMA lines associated with Fibonacci numbers, it seeks to provide insights into entry and exit points within the trading landscape.

Strategy Logic

The strategy utilizes specific HMA lines linked to the Fibonacci numbers 1, 2, and 3, denoted as HMA 1, HMA 2, and HMA 3. When these HMA lines cross each other, automatic buy and sell signals are generated. For instance, a buy signal is triggered when HMA 3 crosses above HMA 2, while a sell signal occurs when HMA 3 crosses below HMA 2. These HMA lines are visually distinguished by colors to facilitate spotting trading opportunities.

Advantage Analysis

This strategy combines the strengths of Fibonacci analysis and Hull Moving Averages. Fibonacci analysis helps identify key support and resistance levels, while HMA lines smooth out price data and generate more reliable trading signals. Additionally, the simplified visualization makes determining the start and end of trends straightforward.

Risk Analysis

The strategy may produce false signals during periods of price whipsaws. Improper parameter settings can also impact performance. The periods of the HMA lines need adjusting to suit different market environments.

Optimization Directions

Consider adding other indicators like RSI for signal filtration to avoid false signals. Backtesting various parameter combinations to find optimal settings is also worthwhile. Combining this strategy with other trading systems is another enhancement possibility.


This strategy aptly utilizes the efficacy of Fibonacci analysis in financial markets and combines it with the signal filtering capacity of HMA to form an effective instrument for uncovering potential trends. Simple and intuitive, it warrants further testing and refinements.

start: 2022-12-22 00:00:00
end: 2023-12-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]

// © Blackynator
strategy("AI Fibonacci HMA Strategy | Buy / Sell Indicator")

// Set the parameters for the moving averages
hma377Period = 377
hma233Period = 233
hma21Period = 21

// Calculate the moving averages
hma377 = hma(close, hma377Period)
hma233 = hma(close, hma233Period)
hma21 = hma(close, hma21Period)

// Plot the moving averages on the chart with different colors and titles
plot(hma377, color=color.white, title="HMA 377")
plot(hma233,, title="HMA 233")
plot(hma21,, title="HMA 21")

// Create variables to hold the HMA 21 value and its previous value
hmaValue = hma21
hmaValuePrev = nz(hmaValue[1], hmaValue)

// Create variables to hold the HMA 200 value and its previous value
hma233Value = hma233
hma233ValuePrev = nz(hma233Value[1], hma233Value)

// Check if the HMA 21 has crossed up the HMA 200 and create a buy signal if it has
if (hmaValue > hma233Value) and (hmaValuePrev < hma233ValuePrev)
    strategy.entry("Buy", true)

// Check if the HMA 21 has crossed down the HMA 200 and create a sell signal if it has
if (hmaValue < hma233Value) and (hmaValuePrev > hma233ValuePrev)
    strategy.entry("Sell", false)