I'm making simple Swing High and Swing Low finder/alert and everything works grate, except there are a lot of cases that Swing High comes after another Swing high.
Logic is simple - a swing high is defined if two candles before have been lower than this one and two candles after are lower as well
What I want to achieve is to plot swing high only if previous plot has not been swing high.
Here will be the code
//@version=4
study("Swing Point Finder")
hhCondition = high[4] < high[2] and high[3] < high[2] and high[1] < high[2] and high < high[2]
llCondition = low[4] > low[2] and low[3] > low[2] and low[1] > low[2] and low > low[2]
plot(hhCondition ? 1 : 0, "Swing High found", color.green, offset = -2)
plot(llCondition ? 1 : 0, "Swing Low found", color.red, offset = -2)