Chart of what I am trying to achieve
Hi!
I've tried to define a swing top as an upbar followed by a downbar. And the swing top being the high of the first bar, the upbar that is.
The ST in green is where my indicator paints the Swing Top
upbar = high>high[1] and low>low[1] downbar = low<low[1]
//Up Bar Down Bar barcolor(showdubar and upbar[1] and downbar? color.gray: na, title='Swing top') plotchar(upbar[1] and downbar, title = 'swing top', location=location.belowbar, color=color.new(color.lime, 50), size=size.tiny, text='ST')
I'm happy with the results but I need it to move one bar to the left. Also how to define that it is the high of that bar that is the swing top?