Whats the easiest way to check past swing high or swing low? I need to check if swing low or high i rising or lowering to strengthen my systems knowledge of the trend. If the past 2 or 3 swing lows is rising i don’t want to trade short and vice versa if the past 2 or 3 swing high is lower to each other i don’t want to trade long…
Have anybody done something similar before and want to share that code?
A swing is when there are two opposite candlesticks, with the leftmost one making a new high/low within the last N periods:
ONCE Periods = 20
ONCE hi1 = 0
ONCE hi2 = 0
ONCE hi3 = 0
ONCE lo1 = 0
ONCE lo2 = 0
ONCE lo3 = 0
Bullish = close > open
Bearish = close < open
NewHigh = (high = highest[Periods](high))
NewLow = (low = lowest[Periods](low))
HIswing = Bullish[1] AND Bearish AND NewHigh[1]
LOswing = Bearish[1] AND Bullish AND NewLow[1]
IF HIswing THEN
hi3 = hi2
hi2 = hi1
hi1 = high[1]
ENDIF
IF LOswing THEN
lo3 = lo2
lo2 = lo1
lo1 = low[1]
ENDIF
hi3 is the oldest swing high, hi2 is the previous one and hi1 is the current one. The same if the LOWs. You can compare them as suits you best.
You may also filter SWINGs with other indicators or price action, to get rid of as many false signals as possible.