Nicolas

ALMA VHF Filter (MA & Signal Band)

Category: Indicators By: Nicolas Created: November 11, 2018, 1:58 PM
November 11, 2018, 1:58 PM
Indicators
11 Comments
ALMA VHF Filter (MA & Signal Band)

2 indicators in this post, the ALMA moving average with its offset  automatically adjusted with a VHF (Vertical Horizontal Filter). The second one is a signals band made of 2 moving average calculated separately with Highs and Lows of the last X periods (Window setting).

I made it first as a rough idea and found it interesting for scalping trading as it reacts quickly enough to find good entries of potential new movement (and quickly revert on false signals), and automatically adapt the band due to volatility while in good trend, resulting of a “keep on trading” technique.

The VHFp controls the period of the VHF filter.

//PRC_ALMA VHF filter | indicator
//11.11.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

// --- settings 
Window = 7
Sigma = 3
VHFp = 21
// --- end of settings 

Price = customClose

//VHF
Length=VHFp

CloseDiff = 0
SumDiff = 0

Serie = Price

For Counter = 0 to Length - 1 do
 CloseDiff = Abs(serie[Counter] - serie[Counter + 1])
 SumDiff = SumDiff + CloseDiff
next

If SumDiff = 0 Then
 SumDiff = 1
endif

VHF = (Highest[Length](serie) - Lowest[Length](serie)) / SumDiff
//

Offset = max(0.01,1- VHF)

m = (Offset * (Window - 1))
s = Window/Sigma

WtdSum = 0
CumWt  = 0

for k = 0 to Window - 1 do
 Wtd = Exp(-((k-m)*(k-m))/(2*s*s))
 WtdSum = WtdSum + Wtd * Price[Window - 1 - k]
 CumWt = CumWt + Wtd
next

ALAverage = WtdSum / CumWt

RETURN ALAverage

Hi/Lo bands made of this moving average:

//PRC_ALMA VHF Filter Hi/Lo band | indicator
//11.11.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

// --- settings
Window = 10
Sigma = 3
VHFp = 21
// --- end of settings

hh = CALL "PRC_ALMA VHF filter"[window, sigma, VHFp](high)
ll = CALL "PRC_ALMA VHF filter"[window, sigma, VHFp](low)

if hh<hh[1] and low<ll then
 trend=-1
elsif ll>ll[1] and high>hh then
 trend=1
endif

if trend=1 then
 iline=ll
 r=0
 g=255
 b=0
else
 iline=hh
 r=255
 g=0
 b=0
endif

return iline coloured(r,g,b) style(line,3) as "ALMA VHF Filter Hi/Lo band"

 

Download
Filename: PRC_ALMA-VHF-Filter-HiLo-band.itf
Downloads: 540
Download
Filename: ALMA-VHF-filter.png
Downloads: 218
Nicolas
Nicolas Legend
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

JosephFelix
8 years ago
#

Hi, Could I please have help with adding these indicators 'on price'? Every indicator that I add plots as a sub-graph. What am I doing wrong here?

Nicolas
8 years ago
#

Just add it on price by clicking the wrench on the left upper side of the price chart.

atxeel
8 years ago
#

Hello Nicolas, the Indi is really great. Unfortunately, I get an error message that takes a long time to calculate, up to 2 seconds. Have it tried with defparam calculateonlastbars unfortunately without success, Maybe you have another solution. Thank you.

Nicolas
8 years ago
#

Yes, that's how it goes when using loops..

carlvan
8 years ago
#

That works now, thank you !

carlvan
8 years ago
#

Dear Nicolas, as usual big thank you for sharing those gems! I imported your code of Alma HiLo bands into PRT and it charts perfectly. However, when I tried to build a system and backtest it, it charts the result automatically but the entry/exit signals are mished mashed, at the wrong place - very strange. My opinion is that it might be due to the "CALL" routines you used in the code. I tried to fix this but unlucky so far. Do you think this can be fixed? Here is your code, with the trade signals (long and exit only for simplicity): defparam cumulateorders=false //PRC_ALMA VHF Filter Hi/Lo band | indicator //11.11.2018 //Nicolas @ www.prorealcode.com //Sharing ProRealTime knowledge Window = 7 Sigma = 3 VHFp = 21 // --- end of settings HH = CALL "PRC_ALMA VHF filter"[window, sigma, VHFp](high) LL = CALL "PRC_ALMA VHF filter"[window, sigma, VHFp](low) if hh<hh[1] and lowLL[1] and high>hh then trend=1 endif if trend=1 then iline=LL else iline=HH endif if not longonmarket and close[1] crosses over iline[1] and Close>High[1] then buy at market endif if longonmarket and close < iline then sell at market

Nicolas
8 years ago
#

You should not use offset in this case. Delete all the [1] references in your code. BTW, trend of the indicator doesn't change when price go through the line, so in order to launch orders according to the indicator, you should use the "trend" variable and its change between 2 candlesticks.

Stenozar
8 years ago
#

Thanks Nicolas!

Stenozar
8 years ago
#

Hi Nicolas, I see two itf files; we should put both on them on the graph? thank you!

Nicolas
8 years ago
#

Only the second one if you want to have the same indicator as the one presented in the picture.

soulintact
8 years ago
#

A very good combination Nicolas, thanks!

ProRealCode ProRealCode
Loading...