Beispiel #1
0
        public KVO(Bars bars, int period1, int period2, string description)
            : base(bars, description)
        {
            FirstValidValue = Math.Max(period1, period2) * 3;
            if (FirstValidValue < 2)
            {
                FirstValidValue = 2;
            }

            WealthLab.Indicators.EMACalculation m = WealthLab.Indicators.EMACalculation.Modern;
            DataSeries TSum   = bars.High + bars.Low + bars.Close;
            DataSeries Range  = bars.High - bars.Low;
            DataSeries VForce = new DataSeries(bars, ("VForce(" + period1 + "," + period2 + ")"));

            double[] trend = new double[2];
            double[] cm    = new double[2];

            for (int bar = FirstValidValue; bar < bars.Count; bar++)
            {
                if (TSum[bar] > TSum[bar - 1])
                {
                    trend[1] = 1;
                }
                else
                {
                    trend[1] = -1;
                }
                if (trend[1] == trend[0])
                {
                    cm[1] = cm[0] + Range[bar];
                }
                else
                {
                    cm[1] = Range[bar] + Range[bar - 1];
                }
                if (cm[1] != 0)
                {
                    VForce[bar] = bars.Volume[bar] * Math.Abs(2 * (Range[bar] / cm[1] - 1)) * trend[1] * 100;
                }
            }

            EMA FXAvg = EMA.Series(VForce, period1, m);
            EMA SXAvg = EMA.Series(VForce, period2, m);

            for (int bar = 1; bar < bars.Count; bar++)
            {
                base[bar] = FXAvg[bar] - SXAvg[bar];
            }
        }
Beispiel #2
0
        public PPO(DataSeries ds, int period1, int period2, string description)
            : base(ds, description)
        {
            FirstValidValue = Math.Max(period1, period2) * 3;
            if (FirstValidValue < 2)
            {
                FirstValidValue = 2;
            }

            WealthLab.Indicators.EMACalculation m = WealthLab.Indicators.EMACalculation.Modern;
            EMA ema1 = EMA.Series(ds, period1, m);
            EMA ema2 = EMA.Series(ds, period2, m);

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                base[bar] = (ema1[bar] - ema2[bar]) / ema2[bar];
            }
        }