# Fractal Pitchfork

> Fractal Pitchfork is an indicator drawn over the price chart.

Source: https://algobarsx.com/docs/ex-53-fractal-pitchfork/

```algobarsx
indicator "Fractal Pitchfork"
    pane: price

state points: list<tuple<int, price>> = []

f = fractals(2)

if f.up:
    points.push((bar.index - 2, high[2]))
if f.down:
    points.push((bar.index - 2, low[2]))
points = points.keep_last(3)

if points.len == 3:
    pitchfork points: points
    polygon points: points, fill: blue.fade(90), border: blue
    arrow 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.
