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"
You must be logged in to post a comment.
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
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.
A very good combination Nicolas, thanks!
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?