Discussing the article: "Graph Theory: Traversal Depth-First Search (DFS) Applied in Trading"

 

Check out the new article: Graph Theory: Traversal Depth-First Search (DFS) Applied in Trading.

This article applies Depth-First Search to market structure by modeling swing highs and lows as graph nodes and tracking one structural path as deeply as conditions remain valid. When a key swing is broken, the algorithm backtracks and explores an alternative branch. Readers gain a practical framework to formalize structural bias and test whether the current path aligns with targets like liquidity pools or supply and demand zones.

In the pursuit of trying to figure out how the market moves, in this part we apply the Depth-First Search (DFS) algorithm from graph theory to the structure of price action in trading. A major challenge when attempting to algorithmize price action is that concepts such as swing highs, swing lows, and market continuation are usually described qualitatively rather than with strict, testable rules. To address this, market structure is formalized as a graph, where each confirmed swing becomes a node and the transitions between swings become edges connecting those nodes. As price forms new candles and new swings are confirmed, this graph evolves dynamically, creating a structured representation of how the market progresses through time.

Within this framework, DFS allows the system to follow one structural branch deeply, such as a progression from a swing low to higher highs and higher lows, before considering alternative structural possibilities. The algorithm commits to this path as long as the structural conditions remain valid, measuring its strength through objective criteria such as path depth, key structural levels, and target tolerance. When the path breaks—such as when a critical swing level is invalidated—the algorithm deterministically backtracks to the previous node and explores other potential paths. By doing this, the sequence of price swings is treated as a traversable route through the market’s structure, transforming subjective price action analysis into a disciplined, codable process suitable for systematic and automated trading.

Author: Hlomohang John Borotho

 

It doesn't look like a graph - just a lookup for 2 types of extremums in a chronologically assembled array. Reminds me a zigzag, inspected with nested loops.

It would be more graph-oriented to generalize on history and find statistically meaningful weights for edges between most probable swing sequences when calculate probablity of future routes.