ADXVMA is a volatility moving average using ADX as a core concept to identify trends. The trend filter acts as support during uptrending markets (color green) and resistance during downtrending markets(color red). The indicator also plots the neutral zone (color yellow) which can be used to identify sideways/volatile markets.
Above is a 3min charts of Nifty Futures
Here is the Amibroker AFL Code for ADXVMA Indicator
//Coded by Rajandran R
//Founder of www.marketcalls.in
//Coded on 20th Sep 2023
_SECTION_BEGIN("ADXVMA Indicator");
adxvma_period = param("ADXVMA Period",15,1,100,1);
atr_period = Param("ATR Period",200,1,300,1);
ups = 0.0;
downs = 0.0;
index = 0.0;
adxvma = 0.0;
trend = 0;
up = 0.0;
down = 0.0;
k = 1.0 / adxvma_period;
volatility = atr(atr_period);
currentUp = Max((Close - Ref(Close,-1)),0);
currentDown = Max((Ref(Close,-1) - Close),0);
for(i=1;i<BarCount;i++)
{
up[i] = (1 - k) * nz(up[i-1]) + (k * currentUp[i]);
down[i] = (1 - k) * nz(down[i-1]) + (k * currentDown[i]);
}
//Plot(up,"up",colorGreen,styleLine|styleThick);
//Plot(down,"down",colorRed,styleLine|styleThick);
isum = up + down;
fractionUp = 0.0;
fractionDown = 0.0;
fractionUp = IIf(iSum>0,up/iSum,0);
fractionDown = IIf(iSum>0,down/iSum,0);
for(i=1;i<BarCount;i++)
{
ups[i] = (1 - k) * nz(ups[i-1]) + (k * fractionUp[i]);
downs[i] = (1 - k) * nz(downs[i-1]) + (k * fractionDown[i]);
}
normDiff = abs(ups - downs);
normSum = ups + downs;
normFraction = IIf(normSum > 0.0, normDiff / normSum, 0);
for(i=1;i<BarCount;i++)
{
index[i]= (1 - k) * Nz(index[i-1]) + (k * normFraction[i]);
ups[i]= (1 - k) * Nz(ups[i-1]) + (k * fractionUp[i]);
downs[i] = (1 - k) * Nz(downs[i-1]) + (k * fractionDown[i]);
}
epsilon = 0.1 * Nz(Ref(volatility,-1));
hhp = Ref(hhv(index, adxvma_period),-1);
llp = Ref(llv(index, adxvma_period),-1);
ihhv = max(index, hhp);
illv = min(index, llp);
vIndex = 0.0;
vIndex = IIf((ihhv - illv) > 0.0, (index - illv) / (ihhv - illv), 0);
adxvma = 0;
for(i=1;i<BarCount;i++)
{
adxvma[i] = (1 - k * vIndex[i]) * Nz(adxvma[i-1]) + (k * vIndex[i] * close[i]);
}
color = IIf(adxvma>Ref(adxvma,-1),colorGreen,IIf(adxvma<Ref(adxvma,-1),colorRed,colorYellow));
Plot(adxvma,"ADXVMA",color,styleThick);
Plot( C, "Price", ParamColor( "Color", colorDefault ), ParamStyle( "Style", styleCandle, maskPrice ) );
_SECTION_END();
ERRORES OF WARNING 505
Warnings can be ignored!
Hi Sir,
very interesting stuff, thanks a lot for sharing.
One question:
the PARAM : ATR Period is just used to calculate “epsilon” , but epsilon is not used in the afl-code.
What’s the purpose of “epsilon”, where might it be used?
Kind Regards
Alex