The FollowLine indicator is a trend following indicator. The blue/red lines are activated when the price closes above the upper Bollinger band or below the lower one.
Once the trigger of the trend direction is made, the FollowLine will be placed at High or Low (depending of the trend).
An ATR filter can be selected to place the line at a more distance level than the normal mode settled at candles Highs/Lows.
//PRC_FollowLine | indicator
//03.04.2020
//Nicolas @ www.prorealcode.com
//converted from MT4 code
//Sharing ProRealTime knowledge
// --- settings
BBperiod = 21
BBdeviations = 1
ATRperiod = 5
UseATRfilter = 0 //0=false ; 1=true
// --- end of settings
BBUpper=average[BBperiod](close)+std[BBperiod]*BBdeviations
BBLower=average[BBperiod](close)-std[BBperiod]*BBdeviations
//-----------------------------------------------------------------------------------
if(close>BBUpper) then
BBSignal=1
endif
if(close<BBLower) then
BBSignal=-1
endif
if(BBSignal>0) then
if(UseATRfilter) then
TrendLine=low-averagetruerange[ATRperiod]
endif
if(not UseATRfilter) then
TrendLine=low
endif
if(TrendLine<TrendLine[1]) then
TrendLine=TrendLine[1]
endif
endif
//---
if(BBSignal<0) then
if(UseATRfilter) then
TrendLine=high+averagetruerange[ATRperiod]
endif
if(not UseATRfilter) then
TrendLine=high
endif
if(TrendLine>TrendLine[1]) then
TrendLine=TrendLine[1]
endif
endif
//---
iTrend=iTrend[1]
if(TrendLine>TrendLine[1]) then
iTrend=1
endif
if(TrendLine<TrendLine[1]) then
iTrend=-1
endif
if itrend>0 then
r=0
g=191
b=255
else
r=220
g=20
b=60
endif
return trendline coloured(r,g,b) style(line,2)