Esempio n. 1
0
 /// <summary>
 /// Resets this indicator and all sub-indicators (StandardDeviation, LowerBand, MiddleBand, UpperBand, BandWidth, %B)
 /// </summary>
 public override void Reset()
 {
     StandardDeviation.Reset();
     MiddleBand.Reset();
     UpperBand.Reset();
     LowerBand.Reset();
     BandWidth.Reset();
     PercentB.Reset();
     base.Reset();
 }
Esempio n. 2
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            int tmpPeriod = Math.Min(CurrentBar, Period);

            double average = Close[0];

            switch (averageType)
            {
            case BollingerPercentB_MATypes.EMA:
                average = EMA(tmpPeriod)[0];
                break;

            case BollingerPercentB_MATypes.SMA:
                average = SMA(tmpPeriod)[0];
                break;
            }

            double stdDevValue = StdDev(tmpPeriod)[0];
            double upperValue  = average + numStdDev * stdDevValue;
            double lowerValue  = average - numStdDev * stdDevValue;

            //PercentB.Set((Input[0] - lowerValue)/(upperValue - lowerValue) * 100);
            PercentB.Set((Close[0] - lowerValue) / (upperValue - lowerValue) * 100);
        }