0bps

Strategy vault / Machine learning

Fibonacci HMA AI Buy Sell Signal Strategy

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…

Author
ChaoZhang
Complexity
Starter · 43 lines
Parameters
0
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

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.

Summary

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.

Source Pine Script

/*backtest
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"}]
*/

//@version=4
// © 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, color=color.blue, title="HMA 233")
plot(hma21, color=color.green, 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)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-29. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Fibonacci-HMA-AI-Buy-Sell-Signal-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open