This indicator draws support and resistance lines that are an extension of the last two swing highs and last two swing lows (or fractal points).
The pivot /fractals definition can be adjusted by changing the number of bars before and the number of bars after the high or low. So for example you can have a new pivot whenever a high has one candle lower either side of it or when it has two candles lower either side of it.
Whenever a new pivot point is formed a new support or resistance line starts to be drawn that lines up with the last two pivot points.
This indicator can be used to easily see if price is either bouncing off of the last two pivots support and resistance or if it is breaking out from that support or resistance.
Download and import the ITF file to get full functionality.
//Last Pivots Support and Resistance Lines
//DEFPARAM CalculateOnLastBars = 1000
//BarsAfter = 1
//BarsBefore = 1
BarLookBack = BarsAfter + 1
IF low[BarsAfter] < lowest[BarsBefore](low)[BarLookBack] THEN
IF low[BarsAfter] = lowest[BarLookBack](low) THEN
Support = low[BarsAfter]
IF high[BarsAfter] > highest[BarsBefore](high)[BarLookBack] THEN
IF high[BarsAfter] = highest[BarLookBack](high) THEN
Resistance = high[BarsAfter]
cr = 255
cs = 255
if resistance <> resistance then
hi2 = hi1
hi2index = hi1index
hi1 = high[BarsAfter]
hi1index = BarIndex[BarsAfter]
cr = 0
if support <> support then
lo2 = lo1
lo2index = lo1index
lo1 = low[BarsAfter]
lo1index = BarIndex[BarsAfter]
cs = 0
if hi2 > hi1 then
nexthi = hi1 - (((hi2 - hi1) / (hi1index - hi2index)) * (barindex - hi1index))
if hi2 < hi1 then
nexthi = hi1 + (((hi1 - hi2) / (hi1index - hi2index)) * (barindex - hi1index))
if lo2 > lo1 then
nextlo = lo1 - (((lo2 - lo1) / (lo1index - lo2index)) * (barindex - lo1index))
if lo2 < lo1 then
nextlo = lo1 + (((lo1 - lo2) / (lo1index - lo2index)) * (barindex - lo1index))
RETURN nexthi coloured(0,128,0,cr) as "Resistance", nextlo coloured (128,0,0,cs) as "Support"
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.ProRealTime ITF files and other attachments :