//---------------------------------------------------//
//PRC TrendLevels
//version = 0
//10.01.24
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//---------------------------------------------------//
// inputs
//---------------------------------------------------//
length=30
atr=averagetruerange[14](close)
//---------------------------------------------------//
// Highest and Lowest values
//---------------------------------------------------//
hi=highest[length](high)
lo=lowest[length](low)
//---------------------------------------------------//
// Trend direction calculation
//---------------------------------------------------//
if hi=high then
trend=1
elsif lo=low then
trend=-1
endif
//---------------------------------------------------//
// Indicator calculation
//---------------------------------------------------//
if trend <> trend[1] then
bars=1
a=0
if trend=1 then
drawarrowUp(barindex,low-atr)coloured("lime")
elsif trend=-1 then
drawarrowdown(barindex,high+atr)coloured("fuchsia")
endif
else
bars=bars+1
a=255
endif
if bars>0 then
h1=highest[bars](high)
l1=lowest[bars](low)
m1=(h1+l1)/2
endif
//---------------------------------------------------//
// Last levels
//---------------------------------------------------//
if islastbarupdate then
drawsegment(barindex,h1,barindex+10,h1)coloured("lime",a)
drawsegment(barindex,l1,barindex+10,l1)coloured("fuchsia",a)
drawsegment(barindex,m1,barindex+10,m1)coloured("grey",a)style(dottedline3)
drawtext("#h1#",barindex+10,h1+0.5*atr)coloured("lime",a)
drawtext("#l1#",barindex+10,l1+0.5*atr)coloured("fuchsia",a)
drawtext("#m1#",barindex+10,m1+0.5*atr)coloured("grey",a)
endif
//---------------------------------------------------//
return h1 coloured("lime",a), l1 coloured("fuchsia",a), m1 coloured("grey",a)style(dottedline3)