I am trying to create an indicator to plot swing points on the chart.
Basically after 3 bullish bars and 3 bearish bars I want the indicator to look back to the last 6 bars and plot a point figure on the highest bar to illustrate the Swing High and that after 3 bearish bars and 3 bullish bars the indicator must look back to the last 6 bars and plot a point figure on the lowest bar to illustrate the Swing low.
I use the heikin-ashi candles.
this is what I am doing:
SH = open[5] < close[5] and open[4] < close[4] and open[3] < close[3] and open[2] > close[2] and open[1] > close[1] and open[0] > close[0]
SL = open[5] > close[5] and open[4] > close[4] and open[3] > close[3] and open[2] < close[2] and open[1] < close[1] and open[0] < close[0]
plotchar(SH, title='Swing High', char='•', location=location.abovebar, color=color.blue, offset = highestbars(6))
plotchar(SL, title='Swing Low', char='•', location=location.belowbar, color=color.red, offset = lowestbars(6))
For some reason sometimes it does not plot the • on the correct bar. As it shows on the chart below the red or blue point should be where the arrow is pointing. Thanks in advance