Exemplo n.º 1
0
        public double Value()
        {
            double v = 0;

            if (isPrimed())
            {
                v = shortSMA.Value() + (shortSMA.Value() - longSMA.Value());
            }

            return(v);
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
0
 public void Value(out double Stochastics, out double Signal)
 {
     if (isPrimed())
     {
         Stochastics = KSmooth.Value();
         Signal      = D.Value();
     }
     else
     {
         Stochastics = 0;
         Signal      = 0;
     }
 }