From where the levels originate & about the proper resolutions we'll discuss later. Soz again for the order xD, but I decided to do that in order to highlight 2 of the most important concepts most people seem to miss for centuries. A level can not be broken, switch direction or suddenly stop working. A level:
1) Can be positioned first as support / resistance;
2) Then it will be cleared.
Positioning
After a level finishes it's formation (it's origin becomes well defined and confirmed), regardless of it's type, at this point of time this level is just a level, it's only a potential support/resistance or supply/demand, whatever you call it. In order to become a confirmed support/resistance, a level must be positioned. In other words, a level becomes supply & demand only after its positioning is over, until that it's only a potential supply/demand.
So:
Price comes back to the not yet positioned level for the first time.
The first bar that touches a level initiates positioning, which ends with the first bar that doesn't touch the level (a free bar).
One free bar above the level means your level just got positioned as supply/support.
One free bar below the level means your level just got positioned as resistance/demand.
A positioned level has two prices: front and back.
If it's a supply level, the front level will be the original level, the back level will be the lowest low of all the bars participated in positioning.
If it's a demand level, the front level will be the original level, the back level will be the highest high of all the bars participated in positioning.
All the pictures show literally the same - positioning of levels as supports/resistances. Dash lines are level themselves, which will become front levels after positioning, dot lines are theirs back levels. Circles are the hypothetical origins of the levels.
Case 1: after completion of the 5th bar the level got positioned as demand, high of the 2nd bar is the back level.
Case 2: after completion of the 3rd bar the level got positioned as supply, low of the 2nd bar is the back level.
Process the other cases yourself just to get a feel.
Clearing
After a level got positioned, later it might be tested or not, regardless, eventually it will be cleared either by:
1) Time. Can be elaborated further, but as an "ok" general rule, when the distance in bars between the level's origin and the current bar is higher than 256 bars, almost surely the level has expired some time ago;
2) Price. When price tests the positioned level deep and touches the back level, or a new free bar forms past the front level. Chances the level got cleared;
3) Volume. Depends on the type of a level, gonna explain later.
In essence, clearing of a level means removing the responsive activity from it: limit orders, MIT orders etc.