Skip to content
All library documents

Harmonic Pattern Detection with Fibonacci Ratios and Tolerance Bands

Article TradingView scripts

Summary

This Pine library provides functions for measuring price and time ratios between swing points and checking whether those ratios fit named chart patterns. It covers harmonic structures such as AB=CD, Bat, Butterfly, Gartley, Crab, and other formations, alongside repeated tops and bottoms, triangles, and head-and-shoulders patterns. Pattern checks compare supplied ratios with target values or ranges derived largely from Fibonacci relationships.

A shared range function supports additive or multiplicative tolerance margins, with a default margin specified by the library. The pattern functions expect ratios in a backward, negative-value convention, and the broader library checks combinations of points before returning matching pattern labels. This is a detection utility rather than a complete trading system: it does not establish how to identify swing points robustly, when to enter or exit, or whether the formations predict profitable moves. The document provides no empirical validation, so users would need to define those rules and test their reliability on relevant data.

Key ideas

  • The library compares price and time ratios between swing points with predefined pattern relationships.
  • Its pattern checks include Fibonacci-based harmonic formations and repeated tops or bottoms.
  • Tolerance can be applied additively or multiplicatively when testing a ratio against a target or range.
  • The functions expect ratios using the documented negative, backward-point convention.
  • Pattern detection alone does not specify trading decisions or demonstrate predictive performance.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.