//-------------------------------------//
//PRC_Zero Lag Trend Signals
//version = 0
//15.11.24
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-------------------------------------//
//---Inputs
//-------------------------------------//
length=70
mult=1.2
src=close
//-------------------------------------//
// Zlema calculation
//-------------------------------------//
lag=floor((length-1)/2)
myzlema=average[length,1](src+(src-src[lag]))
//-------------------------------------//
// Volatility calculation
//-------------------------------------//
atr=averagetruerange[length](close)
volatil=highest[length*3](atr)*mult
//-------------------------------------//
// Trend condition
//-------------------------------------//
once trend=0
if close crosses over myzlema+volatil then
trend=1
r=0
g=255
elsif close crosses under myzlema-volatil then
trend=-1
r=255
g=0
endif
//-------------------------------------//
// Signals and colors
//-------------------------------------//
if trend=-1 then
upper=myzlema+volatil
alpha1=90
lower=myzlema
alpha2=0
if trend<>trend[1] then
drawarrowdown(barindex,upper+0.25*atr)coloured(r,g,0,175)
endif
else
upper=myzlema
alpha1=0
lower=myzlema-volatil
alpha2=90
if trend<>trend[1] then
drawarrowup(barindex,lower-0.25*atr)coloured(r,g,0,175)
endif
endif
if close crosses over myzlema and trend=1 and trend[1]=1 then
drawtext("▲",barindex,myzlema-volatil*1.5)coloured("green")
elsif close crosses under myzlema and trend=-1 and trend[1]=-1 then
drawtext("▼",barindex,myzlema+volatil*1.5)coloured("red")
endif
if barindex > 4*length then
colorbetween(myzlema,upper,r,g,0,alpha1)
colorbetween(myzlema,lower,r,g,0,alpha2)
endif
//-------------------------------------//
return myzlema as "Zero Lag Basis"style(line,2)coloured(r,g,0)