Пример #1
0
        public void ReceiveTick(double pO, double pH, double pL, double pC)
        {
            double min, max;

            H[tickcount % KPeriods] = pH;
            L[tickcount % KPeriods] = pL;
            C = pC;

            if (tickcount >= KPeriods)
            {
                max = H[0];
                min = L[0];

                for (int i = 0; i < KPeriods; i++)
                {
                    if (H[i] > max)
                    {
                        max = H[i];
                    }
                    if (L[i] < min)
                    {
                        min = L[i];
                    }
                }

                K = 100 * ((C - min) / (max - min + 0.000000001));

                KSmooth.ReceiveTick(K);
                if (KSmooth.Value() != 0)
                {
                    D.ReceiveTick(KSmooth.Value());
                }
            }

            tickcount++;
            if (tickcount == (4 * KPeriods))
            {
                // avoid overflow by restricting range of tickcount
                // when indicator is fully primed

                // 3*KPeriods satisfies ( tickcount > (KPeriods+KSPeriods+DPeriods) )
                // when (KPeriods > KSPeriods) and (KPeriods > DPeriods)

                tickcount = 3 * KPeriods;
            }
        }
Пример #2
0
 public void ReceiveTick(double Val)
 {
     longSMA.ReceiveTick(Val);
     shortSMA.ReceiveTick(Val);
 }