コード例 #1
0
        public static BBandLower2 Series(DataSeries ds, int period, double stdDevs, StdDevCalculation sd)
        {
            string description = string.Concat(new object[] { "Lower Bollinger Band(", ds.Description, ",", period, ",", stdDevs, ",", sd, ")" });

            if (ds.Cache.ContainsKey(description))
            {
                return((BBandLower2)ds.Cache[description]);
            }

            BBandLower2 _BBandLower2 = new BBandLower2(ds, period, stdDevs, sd, description);

            ds.Cache[description] = _BBandLower2;
            return(_BBandLower2);
        }
コード例 #2
0
        public BBPctB(DataSeries ds, int period, double SD, string description)
            : base(ds, description)
        {
            DataSeries BBUp   = BBandUpper2.Series(ds, period, SD, StdDevCalculation.Sample);
            DataSeries BBDown = BBandLower2.Series(ds, period, SD, StdDevCalculation.Sample);
            DataSeries PctBBW = ((ds - BBDown) / (BBUp - BBDown));  //%B = (Price - Lower Band)/(Upper Band - Lower Band)

            base.FirstValidValue = ds.FirstValidValue;

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                double v = PctBBW[bar];
                base[bar] = (double.IsInfinity(v) || double.IsNaN(v)) ? 0 : v;
                //base[bar] = ((ds[bar] - BBDown[bar]) / (BBUp[bar] - BBDown[bar]));
            }
        }
コード例 #3
0
        public BBWidth(DataSeries ds, int period, double SD, bool percent, string description)
            : base(ds, description)
        {
            DataSeries BBUp   = BBandUpper2.Series(ds, period, SD, StdDevCalculation.Sample);
            DataSeries BBDown = BBandLower2.Series(ds, period, SD, StdDevCalculation.Sample);

            Community.Indicators.FastSMA sma = Community.Indicators.FastSMA.Series(ds, period);
            DataSeries bbWidth = (BBUp - BBDown) / sma;     //BandWidth = (upperBB − lowerBB) / middleBB

            base.FirstValidValue = ds.FirstValidValue;

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                if (!percent)
                {
                    base[bar] = bbWidth[bar];
                }
                else
                {
                    base[bar] = bbWidth[bar] * 100;
                }
            }
        }