You are on page 1of 1

//@version=4

study("Auto S/R", overlay=true)

//Variables

R1 = highest (close, 200)


R2 = highest (close, 400)
R3 = highest (close, 800)
R4 = highest (close, 1600)
R5 = highest (close, 3200)
S1 = lowest (close, 200)
S2 = lowest (close, 400)
S3 = lowest (close, 800)
S4 = lowest (close, 1600)
S5 = lowest (close, 3200)

//Plots
plot(R1, title='Resistance 1', color=#FF5E59, linewidth=1, style=plot.style_cross,
transp=100, trackprice=true)
plot(R2, title='Resistance 2', color=#FF5E59, linewidth=1, style=plot.style_cross,
transp=100, trackprice=true)
plot(R3, title='Resistance 3', color=#FF5E59, linewidth=2, style=plot.style_cross,
transp=100, trackprice=true)
plot(R4, title='Resistance 4', color=#FF5E59, linewidth=2, style=plot.style_cross,
transp=100, trackprice=true)
plot(R5, title='Resistance 5', color=#FF5E59, linewidth=3, style=plot.style_cross,
transp=100, trackprice=true)

plot(S1, title='Support 1', color=#59FF8E, linewidth=1, style=plot.style_cross,


transp=100, trackprice=true)
plot(S2, title='Support 2', color=#59FF8E, linewidth=1, style=plot.style_cross,
transp=100, trackprice=true)
plot(S3, title='Support 3', color=#59FF8E, linewidth=2, style=plot.style_cross,
transp=100, trackprice=true)
plot(S4, title='Support 4', color=#59FF8E, linewidth=2, style=plot.style_cross,
transp=100, trackprice=true)
plot(S5, title='Support 5', color=#59FF8E, linewidth=3, style=plot.style_cross,
transp=100, trackprice=true)

//Alerts

support1Alert = (S1 < S1[1])


resistance1Alert = R1 > R1[1]

alertcondition(support1Alert, title='New S1 low', message='Breakdown of current


short term support')
alertcondition(resistance1Alert, title='New R1 high', message='Breakout of current
short term resistance')

You might also like