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 and Co-Creator of Algomojo (Algorithmic Trading Platform for DIY Traders)

PercentRank Based Smooth ATR to Predict Change in Volatility – Amibroker AFL Code

1 min read

Is there a way where one can identify market regime shift from low volatility zone to high volatility zone and vice versa? How I can identify stocks with increasing volatility? Is there a way one can identify the regime shift in volatility? These are the bugging question from many short-term traders.

To kickstart ATR is a measure of volatility and not a directional indicator. when the market participants are active & interested eventually it will result in large trading range. However, if the participants are uninterested which will result in smaller trading range. And the volatility behavior can be seen in cycles where the market moves from high volatile zones to low volatile zones and vice versa.

PercentRank Based Smooth ATR – Nifty Daily Charts

But ATR values alone we cannot use it to predict the change in regime shift from low to high or high to low volatility shift. In order to predict the regime-shift, we need to smooth the ATR. Here smoothing of the ATR data points are done using linear regression to reduce lag in end result and equally responsive as the actual ATR values.

Now Percentrank is applied over smooth ATR to predict the change in regime shift. Percent rank value of 100 indicates that the smooth ATR is the highest for the given lookback range, while a value of 0 indicates that the smooth ATR value is the lowest for the given lookback range(Default lookback range = 20 bars).

From Zero to Increasing Percent Rank indicates regime change from low volatility zones to high volatility zone (Blue Color)

whereas,

From 100 to Decreasing Percent Rank indicates regime shift from high volatility to low volatility zone. (Red Color)

Here are the Amibroker AFL codes for Percent Rank based smooth ATR and colored candles according to the high volatility or low volatility zones. High volatility zones are colored blue and low volatile zones are colored red. Exploration feature is added to find increasing/decreasing Percent rank with values.

Note: Exploration can be used only on 1 recent bar or 1 recent day if on a daily timeframe to get accurate values.

PercentRank Based Smooth ATR Color-coded Candles – Amibroker AFL Code

// Coded by Rajandran R
// Coded Date : 14-09-2018
// Author - Maketcalls (www.marketcalls.in )
// Co-Founder - Traderscafe (www.traderscafe.in)

_SECTION_BEGIN("PRBATR colored Candles");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

periods = Param( "Periods", 20, 1, 200, 1 );
PRBATR=PercentRank(LinearReg(ATR(periods),periods),periods);

color = IIf(PRBATR > Ref(PRBATR,-1) OR PRBATR == 100,colorBlue,colorRed);

Plot( C, "Close", color, styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

PercentRank Based Smooth ATR – Amibroker AFL Code

// Coded by Rajandran R
// Coded Date : 14-09-2018
// Author - Maketcalls (www.marketcalls.in )
// Co-Founder - Traderscafe (www.traderscafe.in)

_SECTION_BEGIN("Percent Rank Based ATR");
periods = Param( "Periods", 20, 1, 200, 1 );
PRBATR=PercentRank(LinearReg(ATR(periods),periods),periods);

color = IIf(PRBATR > Ref(PRBATR,-1) OR PRBATR == 100,colorBlue,colorRed);
prbstatus = WriteIf(PRBATR > Ref(PRBATR,-1) OR PRBATR == 100,"Increasing","Decreasing");

Plot( PRBATR, "PRB-ATR", color, styleLine | styleThick );
_SECTION_END();

_SECTION_BEGIN("Exploration");

Filter = 1; //allow all
AddColumn(Close,"LTP",1.2);
AddColumn(PRBATR,"PRBATR",1.2,colorWhite,color);
AddtextColumn(prbstatus,"Status",1,colorWhite,color);

_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 and Co-Creator of Algomojo (Algorithmic Trading Platform for DIY Traders)

Stoploss, Multi Target, and Trailing Stoploss Module – Amibroker…

After Intraday V2.0 Amibroker Module - a readymade drag and drop module to convert any trading strategy into the intraday trading system with alerts,...
Rajandran R
6 min read

Line Trading – Algomojo 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
58 sec read

Plotting Day Wise Equity Curve using Amibroker

We know that Amibroker provides an equity curve for the whole strategy. Is there a way where we can build a simple Day Wise...
Rajandran R
1 min read

One Reply to “PercentRank Based Smooth ATR to Predict Change in Volatility…”

  1. PercentRank Based Smooth ATR – Amibroker AFL Code

    Hello Sir

    Can you please share python code for this indicator ?

    It would be of great help

Leave a Reply

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