Twin Range Filter

Category: Indicators By: Nicolas Created: March 28, 2023, 9:43 AM
March 28, 2023, 9:43 AM
Indicators
10 Comments

An experiment to combine two range filters and plot the average of both to smooth out the signals.

This works significantly better than the typical ATR set-up, but there’s still too much noise here to set and forget with bots. Use it as the basis of your own system with additional filtering on top.

(original description from author: colinmck)

//PRC_Twing Range Filter | indicator
//28.03.2023
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//author: colinmck

// --- settings 
per1 = 27 //"Fast period"
mult1 = 1.6 //"Fast range"
per2 = 55 //"Slow period"
mult2 = 2 //"Slow range"
// --- end of settings 

source = customclose

once wper1 = per1 * 2 - 1
avrng1 = average[per1,1](abs(source - source[1]))
smrng1 = average[wper1,1](avrng1) * mult1
once wper2 = per2 * 2 - 1
avrng2 = average[per2,1](abs(source - source[1]))
smrng2 = average[wper2,1](avrng2) * mult2
smrng = (smrng1 + smrng2) / 2

r = smrng
if source>rngfilt[1] then
if (source-r)<rngfilt[1] then
rngfilt=rngfilt[1]
else
rngfilt=source-r
endif
elsif (source+r)>rngfilt[1] then
rngfilt=rngfilt[1]
else
rngfilt=source+r
endif

if rngfilt > rngfilt[1] then 
upward=upward+1
downward=0
endif 
if rngfilt < rngfilt[1] then
upward=0
downward=downward+1
endif

longCond = (source > rngfilt and source > source[1] and upward > 0) or (source > rngfilt and source < source[1] and upward > 0)
shortCond = (source < rngfilt and source < source[1] and downward > 0) or (source < rngfilt and source > source[1] and downward > 0)

if longcond then 
colorr=0
colorg=255
elsif shortcond then 
colorr=255 
colorg=0
endif 

if colorr=0 and colorr[1]=255 then 
drawarrowup(barindex,min(low,rngfilt)-averagetruerange[14]/2) coloured("green")
endif 
if colorr=255 and colorr[1]=0 then 
drawarrowdown(barindex,max(high,rngfilt)+averagetruerange[14]/2) coloured("crimson")
endif 

return rngfilt coloured(colorr,colorg,0) style(line,2)

Download
Filename: PRC_Twin-Range-Filter.itf
Downloads: 444
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...