A SWING LOW :–
A swing Low is defined as: a bar where:
– the high of the middle bar is lower than the high of the bar before it and after it
– and the low of the middle bar is lower that the low of the bar before and after it.
A SWING HIGH :—
A swing high is defined as: a bar where:
– the high of the middle bar is higher than the high of the bar before it and after it
– and the low of the middle bar is higher that the low of the bar before and after it.
res = 0
// Swing high
c1 = high[1] > high AND high[1] > high[2]
c2 = low[1] > low AND low[1] > low[2]
// Swing low
c3 = high[1] < high AND high[1] < high[2]
c4 = low[1] < low AND low[1] < low[2]
IF c1 and c2 THEN
res = 1
ELSIF c3 and c4 THEN
res = -1
ENDIF
return res