Fractal Pitchfork

Fractal Pitchfork is an indicator drawn over the price chart.

state

fractal-pitchfork.abx
1indicator "Fractal Pitchfork"
2pane: price
3
4state points: list<tuple<int, price>> = []
5
6f = fractals(2)
7
8if f.up:
9points.push((bar.index - 2, high[2]))
10if f.down:
11points.push((bar.index - 2, low[2]))
12points = points.keep_last(3)
13
14if points.len == 3:
15pitchfork points: points
16polygon points: points, fill: blue.fade(90), border: blue
17arrow from: points.get(0), to: points.get(2), color: gray
What this script says

Fractal Pitchfork is an indicator drawn over the price chart.

It remembers points from one bar to the next.

It calculates f as the fractals (periods 2) and points as points.keep_last(3).

On each bar, it checks whether f.up and, if so, adds (bar.index - 2, high[2]) to points.

On each bar, it checks whether f.down and, if so, adds (bar.index - 2, low[2]) to points.

On each bar, it checks whether the number of points is 3 and, if so, draws a pitchfork, draws a polygon and draws an arrow.

Try this in the Terminal. AlgoBars is free: $0 a month, no card needed.

Create my free account