ZigZag Fibonacci
ZigZag Fibonacci is an indicator drawn over the price chart.
core language
indicator "ZigZag Fibonacci"pane: priceinput deviation = 3%swings = zigzag(deviation: deviation, depth: 12)if swings.len >= 2:last_swing = swings.last()previous_swing = swings.get(swings.len - 2)fib from: (previous_swing.bar, previous_swing.price), to: (last_swing.bar, last_swing.price), levels: [0.382, 0.5, 0.618, 0.786]polyline points: swings.map(s => (s.bar, s.price)), color: gray, width: 1Sample data. Not a result. The real AlgoBarsX engine ran this exact script on made-up bars, and this replays what it drew and did. It shows no profit or loss, and it says nothing about how the script would do in a real market.
Replay of this script on 150 sample bars: 0 lines drawn.
ZigZag Fibonacci is an indicator drawn over the price chart.
You can change one input: deviation (default 3%).
It calculates swings as the zigzag swings (deviation deviation, depth 12).
On each bar, it checks whether the number of swings is at or above 2 and, if so, sets last_swing to swings.last(), sets previous_swing to swings.get(swings.len - 2), draws Fibonacci levels and draws a polyline.