Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, 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. Building Algo Platforms, 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 Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, 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. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

Interactive Brokers – Smart Order Chart Trading Module using…

The IB Controller is an interface designed to facilitate automatic trading with AmiBroker and Interactive Brokers (IB) TWS (Trader Workstation). It serves as a...
Rajandran R
8 min read

Introducing OpenAlgo V1.0: The Ultimate Open-Source Algorithmic Trading Framework…

OpenAlgo V1.0 is an open-source algorithmic trading platform to automate your trading strategies using Amibroker, Tradingview, Metatrader, Python etc. Designed with the modern trader...
Rajandran R
2 min read

[Live Coding Webinar] Build Your First Trading Bridge for…

In this course, you will be learning to build your own trading bridge using Python. This 60-minute session is perfect for traders, Python enthusiasts,...
Rajandran R
1 min read

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

  1. 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

Leave a Reply

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