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"