Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

ADXVMA – Indicator – Amibroker AFL Code

1 min read

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();
Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

Elevate Your Trading with AlgoStudio: A Comprehensive Webinar

We're excited to invite you to our exclusive webinar on December 9th, 2023, from 7 p.m. to 8 p.m. IST, introducing AlgoStudio—an innovative addon...
Rajandran R
55 sec read

Generating Real-Time Equity Curve Using Amibroker and Enhancing Backtesting…

Amibroker, a popular trading system development platform, offers robust tools for creating and analyzing trading strategies. Complementing it with the Quantstats Python library, traders...
Rajandran R
2 min read

Things that Amibroker Can Do Which Tradingview Cannot

When it comes to trading and technical analysis, having the right tools at your disposal can make all the difference. Two popular software platforms,...
Rajandran R
1 min read

2 Replies to “ADXVMA – Indicator – Amibroker AFL Code”

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More