Follow Line Indicator

Category: Indicators By: Nicolas Created: April 3, 2020, 10:42 AM
April 3, 2020, 10:42 AM
Indicators
10 Comments

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)

 

Download
Filename: PRC_FollowLine-indicator.itf
Downloads: 937
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...