// Repeat Indicator
//
// https://www.prorealcode.com/topic/repeat-indicator-on-time-intervals/
//
DEFPARAM DrawOnLastBarOnly = True
//YesterdayFrom = 140000
//YesterdayTo = 150000
//TodayTime = 140000
//Multiplier1 = 0.5
//Multiplier2 = 1.0
//Multiplier3 = 1.5
//Multiplier4 = 2.0
//FutureBARS = 5
//
ONCE HH = 0
ONCE LL = 0
ONCE prevHH = 0
ONCE prevLL = 0
ONCE TodayHH = 0
ONCE TodayLL = 0
ONCE TodayBarHH = 0
ONCE TodayBarLL = 0
ONCE Amplitude = 0
//
IF (OpenTime >= YesterdayFrom) AND (OpenTime <= YesterdayTo) THEN
IF (OpenTime = YesterdayFrom) OR ((OpenTime > YesterdayFrom) AND (OpenTime[1] < YesterdayFrom)) THEN
Amplitude = HH - LL
Ampli1 = Amplitude * Multiplier1
Ampli2 = Amplitude * Multiplier2
Ampli3 = Amplitude * Multiplier3
Ampli4 = Amplitude * Multiplier4
prevHH = HH
prevLL = LL
HH = high
LL = low
ENDIF
HH = max(HH,high)
LL = min(LL,low)
ENDIF
//
IF (OpenTime >= TodayTime) THEN
IF (OpenTime = TodayTime) OR ((OpenTime > TodayTime) AND (OpenTime[1] < TodayTime)) THEN
TodayHH = high
TodayLL = low
ENDIF
TodayHH = max(TodayHH,high)
TodayLL = min(TodayLL,low)
IF TodayHH <> TodayHH[1] THEN
TodayBarHH = BarIndex
ENDIF
IF TodayLL <> TodayLL[1] THEN
TodayBarLL = BarIndex
ENDIF
Max1 = TodayHH - Ampli1
Max2 = TodayHH - Ampli2
Max3 = TodayHH - Ampli3
Max4 = TodayHH - Ampli4
//
Min1 = TodayLL + Ampli1
Min2 = TodayLL + Ampli2
Min3 = TodayLL + Ampli3
Min4 = TodayLL + Ampli4
ENDIF
DrawSegment(TodayBarHH,TodayHH,BarIndex + FutureBARS,TodayHH) coloured("SkyBlue") style(Line,4) //SkyBlue (Main HIGH line)
DrawSegment(TodayBarLL,TodayLL,BarIndex + FutureBARS,TodayLL) coloured("SkyBlue") style(Line,4) //SkyBlue (Main LOW line)
//
DrawSegment(TodayBarHH,Min1,BarIndex + FutureBARS,Min1) coloured("Tomato") style(DottedLine,2) //Tomato
DrawSegment(TodayBarHH,Min2,BarIndex + FutureBARS,Min2) coloured("OrangeRed") style(DottedLine,2) //OrangeRed
DrawSegment(TodayBarHH,Min3,BarIndex + FutureBARS,Min3) coloured("Red") style(DottedLine,2) //Red
DrawSegment(TodayBarHH,Min4,BarIndex + FutureBARS,Min4) coloured("Crimson") style(DottedLine,2) //Crimson
DrawSegment(TodayBarLL,Max1,BarIndex + FutureBARS,Max1) coloured("DeepSkyBlue") style(DottedLine,2) //DeepSkyBlue
DrawSegment(TodayBarLL,Max2,BarIndex + FutureBARS,Max2) coloured("LightBlue" ) style(DottedLine,2) //LightBlue
DrawSegment(TodayBarLL,Max3,BarIndex + FutureBARS,Max3) coloured("DodgeBlue") style(DottedLine,2) //DodgeBlue
DrawSegment(TodayBarLL,Max4,BarIndex + FutureBARS,Max4) coloured("Blue") style(DottedLine,2) //Blue
RETURN