Acceleration Bands free

by qualitiedx2 in category Trend at 16/05/2012
Description

Price Headley's Acceleration Bands serve as a trading envelope that factor in a stock\'s typical volatility over standard settings of 20 or 80 bars. They can be used across any time frame, though Headley prefers to use them most across weekly and monthly timeframes as breakout indicators outside these bands, while using the shorter time frames to define likely support and resistance levels at the lower and upper Acceleration Bands. Acceleration Bands are plotted around a simple moving average as the midpoint, and the upper and lower bands are of equal distance from this midpoint

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class AccelerationBands : Indicator
    {
        [Parameter(DefaultValue = 0.0005)]
        public double Factor { get; set; }
        
        [Parameter(DefaultValue = 25)]
        public int Period { get; set; }
        [Output("UpperBand")]
        public IndicatorDataSeries upperband { get; set; }

        [Output("LowerBand")]
        public IndicatorDataSeries lowerband { get; set; }

    	double sumupper;
		double sumlower;
		public IndicatorDataSeries upperbandholder;
		public IndicatorDataSeries lowerbandholder;
		protected override void Initialize()
        {
        	upperbandholder = CreateDataSeries();
        	lowerbandholder = CreateDataSeries();
		}
		
        public override void Calculate(int index)
        {
			upperbandholder[index] = (MarketSeries.High[index] * ( 1 + 2 * (((( MarketSeries.High[index] - MarketSeries.Low[index] )
			/(( MarketSeries.High[index] + MarketSeries.Low[index] ) / 2 )) * 1000 ) * Factor )));
			lowerbandholder[index]= ( MarketSeries.Low[index] * ( 1 - 2 * (((( MarketSeries.High[index] - MarketSeries.Low[index] )
			/(( MarketSeries.High[index] + MarketSeries.Low[index] ) / 2 )) * 1000 ) * Factor )));
			sumupper=0;
			sumlower=0;
			for(int i=0;i<Period;i++)
			{
				sumupper+=upperbandholder[index-i];
				sumlower+=lowerbandholder[index-i];
			}
			sumupper=sumupper/Period;
			sumlower=sumlower/Period;
			
			lowerband[index]=sumlower;
			upperband[index]=sumupper;
        }
    }
}
Comments
5