Exemple #1
0
 public MyRSI(int period, int smooth)
 {
     this.Period = period;
     this.Smooth = smooth;
     downSMA     = new MySMA(period);
     upSMA       = new MySMA(period);
     val         = 0;
     avg         = 0;
 }
Exemple #2
0
 public MyStochastics(int d, int k, int smooth)
 {
     this.Smooth  = smooth;
     this.PeriodD = d;
     this.PeriodK = k;
     minK         = new MyMIN(PeriodK);
     maxK         = new MyMAX(PeriodK);
     sumD         = new MySUM(PeriodD);
     sumNom       = new MySUM(PeriodD);
     kSMA         = new MySMA(Smooth);
 }
        /// <summary>
        /// Simple Moving Average
        /// </summary>
        /// <returns></returns>
        public MySMA MySMA(Data.IDataSeries input, int period)
        {
            if (cacheMySMA != null)
            {
                for (int idx = 0; idx < cacheMySMA.Length; idx++)
                {
                    if (cacheMySMA[idx].Period == period && cacheMySMA[idx].EqualsInput(input))
                    {
                        return(cacheMySMA[idx]);
                    }
                }
            }

            lock (checkMySMA)
            {
                checkMySMA.Period = period;
                period            = checkMySMA.Period;

                if (cacheMySMA != null)
                {
                    for (int idx = 0; idx < cacheMySMA.Length; idx++)
                    {
                        if (cacheMySMA[idx].Period == period && cacheMySMA[idx].EqualsInput(input))
                        {
                            return(cacheMySMA[idx]);
                        }
                    }
                }

                MySMA indicator = new MySMA();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input  = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                MySMA[] tmp = new MySMA[cacheMySMA == null ? 1 : cacheMySMA.Length + 1];
                if (cacheMySMA != null)
                {
                    cacheMySMA.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheMySMA          = tmp;
                return(indicator);
            }
        }
Exemple #4
0
 public MyCCI(int Period)
 {
     this.Period = Period;
     buff        = new ArrayList(Period + 1);
     sma         = new MySMA(Period);
 }