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

Line Trading – OpenAlgo Automation Module for Amibroker Users

The line Trading Automation tool is designed for Manual traders who want to perform level-based trade execution faster and also bring some advanced trade...
Rajandran R
55 sec read

Mini Certification Course on Algorithmic Trading

Welcome to the Mini Certification on Algorithmic Trading using Amibroker and OpenAlgo! This comprehensive 4-part series is designed to equip you with the knowledge...
Rajandran R
1 min read

Pivot Reversal Strategy – Tradingview Pinescript to Amibroker AFL…

Pivot Reversal Strategy is a popular in-built strategy in Tradingview Platform. Here I had attempted to convert the pinescript v5 to Amibroker AFL Code....
Rajandran R
3 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