Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

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 Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

[Free Webinar] Starting Amibroker AFL Coding Right from the…

Interested in Creating your own indicators/Buy or Sell Trading System. Learn How to build your own trading system using Amibroker. If you are new...
Rajandran R
27 sec read

Angel Broking Multi-Client Amibroker Trading Module

Got frequent requirements from Angel Broking Customers to automate Amibroker based trading system where one single generation from charts could punch orders in multiple...
Rajandran R
6 min read

Option Button Trading to Trade ATM, ITM, OTM Options…

Here is a simple button trading module which can be used to send option trading order with buttons. Users can configure the button to...
Rajandran R
7 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