Acceleration Bands AFL Code

Acceleration Bands is a momentum indicator that factors in the stock’s volatility over a predefined period (usually 20 days or weeks). It’s typically plotted as an envelope over a chart with an upper band, lower band and middle band.

The upper and lower bands represent a trading range, while any breakout above or below the upper and lower band respectively indicates a rapid ‘acceleration’. So, if the stock breaks out from the upper band, it’s very likely that the price is going to rapidly accelerate over the next few days or weeks.

The middle band is simply a moving average line.

This indicator was formulated by Price Headley, the founder of bigtrends.com

Preferred Timeframe

The indicator works well in higher timeframes i.e. Daily or Weekly.

Screenshot

Below is the screenshot of Acceleration bands plotted in an Amibroker chart. The blue line represents an upper band, the red line represents a lower band and the white line represents a middle band.

Acceleration Bands AFL Screenshot

Acceleration Bands AFL Download

Download the AFL code for acceleration bands from the below link:

Acceleration Bands AFL Code 

AFL Explanation

It’s a fairly simple AFL code where the values of upper, lower and middle bands are calculated using the below formulas:

Upperband=MA(H*(1+2*((2*range)*100)*.01),LookbackPeriods);

Lowerband= MA(L*(1-2*((2*range)*100)*.01),LookbackPeriods);

Middleband=MA(C,LookbackPeriods);

where

MA = Simple moving average

Range = (High – Low) / (High + Low)/2

LookbackPeriods = Moving average time period, by default it is set to 20

And then, these bands are plotted on a candlestick chart by using the standard Amibroker “plot” function.

You may also use EMA instead of MA to get more accurate and timely breakout signals.

Do you want to learn AFL coding from scratch and build your own profitable trading systems? Check out our best-selling Algorithmic Trading Bootcamp course bundle.

Long and Short Rules

You can go long if the price crosses above the upper band and close the long position when it crosses below the upper band. Similarly, you can go short when the price crosses below the lower band and square off when it crosses above the lower band. Based on your risk appetite you can also use middle band crossovers for closing the open positions.

Disclaimer

All the AFL’s posted in this section are for learning purposes. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *