percentB free

by qualitiedx2 in category Oscilator at 04/08/2012
Description

The percentB indicatorpercentb

 

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;
using cAlgo.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class percentB : Indicator
    {
    	[Parameter]
        public DataSeries Source { get; set; }

		[Parameter("MAType")]
		public MovingAverageType matype { get; set; }

        [Parameter("Period", DefaultValue =20)]
        public int Period { get; set; }

        [Parameter("Standard Deviation", DefaultValue = 2.0)]
        public double std { get; set; }

        [Output("Main", Color = Colors.Yellow)]
        public IndicatorDataSeries Result { get; set; }

		BollingerBands bb;

        protected override void Initialize()
        {
			bb = Indicators.BollingerBands(Source, Period, std, matype);
        }

        public override void Calculate(int index)
        {
			Result[index] = (Source[index] - bb.Bottom[index]) / (bb.Top[index] - bb.Bottom[index]);
        }
    }
}
Comments
2.5