Bollinger Bands code
28 Aug 2012, 13:02
I need some help writing the code for a strategy that uses Bollinger Bands. How do I code something that indicates that the Bands have tightened up?

admin
29 Aug 2012, 10:03
Hello
You can use the following code to express that the Bollinger Bands have tightened up:
[Parameter] public DataSeries Source { get; set; } [Parameter(DefaultValue = 20)] public int Period { get; set; } [Parameter(DefaultValue = 2.5)] public double bbSTD { get; set; } [Parameter("MA Type", DefaultValue = MovingAverageType.Exponential)] public MovingAverageType MAType { get; set; } [Output("Main")] public IndicatorDataSeries Result { get; set; } BollingerBands bbands; protected override void Initialize() { bbands = Indicators.BollingerBands(Source,Period,bbSTD,MAType); } public override void Calculate(int index) { if( bbands.Top.IsFalling && bbands.Bottom.IsRising ){ //Code Logic goes here } }@admin