DEFPARAM CalculateOnLastBars = 1000
//DEFPARAM DrawOnLastBarOnly = true
myrsi = rsi[14](close)
PivotBAR = 2
LookBack = 4
BarLookBack = PivotBAR + 1
//IF myrsi[PivotBAR] < lowest[LookBack](myrsi)[BarLookBack] THEN
//IF myrsi[PivotBAR] = lowest[BarLookBack](myrsi) THEN
//PrevSupp3 = PrevSupp2
//PrevSuppRSI3 = PrevSuppRSI2
//PrevSupp2 = PrevSupp1
//PrevSuppRSI2 = PrevSuppRSI1
//PrevSupp1 = PrevSupp
//PrevSuppRSI1 = PrevSuppRSI
//PrevSupp = MySupport
//PrevSuppRSI = SupportRSI
//MySupport = BarIndex - PivotBAR
//SupportRSI = myrsi[PivotBAR]
//ENDIF
//ENDIF
IF myrsi[PivotBAR] > highest[LookBack](myrsi)[BarLookBack] and myrsi[PivotBar]>48 THEN
IF myrsi[PivotBAR] = highest[BarLookBack](myrsi) THEN
Index4 = Index3
RSI4 = RSI3
Pricepoint4 =Pricepoint3
Index3 = Index2
RSI3 = RSI2
Pricepoint3 =Pricepoint2
Index2 = Index1
RSI2 = RSI1
Pricepoint2 =Pricepoint1
Index1 = Index0
RSI1 = RSI0
Pricepoint1 = Pricepoint0
Index0 = BarIndex - PivotBAR
RSI0 = myrsi[PivotBAR]
Pricepoint0 = high[PivotBAR]
//Slope = (PrevResRSI-RSI0)/(Index0-PrevRes)
//y = PrevResRSI-((barindex-PrevRes)*Slope)
ENDIF
endif
If Pricepoint0<Pricepoint1 and RSI0>RSI1 and ya then
DRAWSEGMENT(Index1,RSI1,Index0,RSI0) COLOURED(0,0,255) //Diagonal frm 1-0
Slope = (RSI0-RSI1)/(Index0-Index1)
y = RSI1+((barindex-Index1)*Slope)
else
y=0
endif
if Pricepoint0<Pricepoint2 and RSI0>RSI2 and yb then
DRAWSEGMENT(Index2,RSI2,Index0,RSI0) COLOURED(0,0,255)//Diagonal from 2-0
Slope2 = (RSI0-RSI2)/(Index0-Index2)
y2 = RSI2+((barindex-Index2)*Slope2)
else
y2=0
endif
if Pricepoint0<Pricepoint3 and RSI0>RSI3 and yc then
DRAWSEGMENT(Index3,RSI3,Index0,RSI0) COLOURED(0,0,255)//Diagonal from 3-0
Slope3 = (RSI0-RSI3)/(Index0-Index3)
y3 = RSI3+((barindex-Index3)*Slope3)
else
y3 = 0
endif
if Pricepoint0<Pricepoint4 and RSI0>RSI4 and yd then
DRAWSEGMENT(Index4,RSI4,Index0,RSI0) COLOURED(0,0,255)//Diagonal from 4-0
Slope4 = (RSI0-RSI4)/(Index0-Index4)
y4 = RSI4+((barindex-Index4)*Slope4)
else
y4=0
endif
RETURN Slope2 as "slope", y2 as "y" style(line,1)COLOURED(255,0,0)//y as "ya", y2 as "yb", y3 as "yc", y4 as "yd"