Support and Resistance

Support and Resistance is an indicator drawn over the price chart.

core language

support-and-resistance.abx
1indicator "Support and Resistance"
2pane: price
3
4input lookback = 300
5input min_touches = 3
6
7found = support_resistance(lookback, touches: min_touches).filter(l => l.touches >= min_touches)
8strongest = found.sort_by(l => -l.strength)
9
10for level in strongest.keep_last(6):
11line from: (bar.index - 50, level.price), to: (bar.index, level.price), extend: right, color: if level.price > close then red.fade(40) else green.fade(40), width: 2
12label "{level.touches} touches", at: (bar.index, level.price), color: gray
What this script says

Support and Resistance is an indicator drawn over the price chart.

You can change 2 inputs: lookback (default 300) and min_touches (default 3).

It calculates found as support_resistance(lookback, touches: min_touches).filter(l => l.touches >= min_touches) and strongest as found.sort_by(l => -l.strength).

On each bar, it goes through each level in strongest.keep_last(6) and draws a line and labels "{level.touches} touches".

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

Create my free account