Exemple #1
0
        /// <summary>
        /// Heikan-Ashi bar levels
        /// </summary>
        /// <returns></returns>
        public HAMedians HAMedians(Data.IDataSeries input, double alpha)
        {
            if (cacheHAMedians != null)
            {
                for (int idx = 0; idx < cacheHAMedians.Length; idx++)
                {
                    if (Math.Abs(cacheHAMedians[idx].Alpha - alpha) <= double.Epsilon && cacheHAMedians[idx].EqualsInput(input))
                    {
                        return(cacheHAMedians[idx]);
                    }
                }
            }

            lock (checkHAMedians)
            {
                checkHAMedians.Alpha = alpha;
                alpha = checkHAMedians.Alpha;

                if (cacheHAMedians != null)
                {
                    for (int idx = 0; idx < cacheHAMedians.Length; idx++)
                    {
                        if (Math.Abs(cacheHAMedians[idx].Alpha - alpha) <= double.Epsilon && cacheHAMedians[idx].EqualsInput(input))
                        {
                            return(cacheHAMedians[idx]);
                        }
                    }
                }

                HAMedians indicator = new HAMedians();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Alpha = alpha;
                Indicators.Add(indicator);
                indicator.SetUp();

                HAMedians[] tmp = new HAMedians[cacheHAMedians == null ? 1 : cacheHAMedians.Length + 1];
                if (cacheHAMedians != null)
                {
                    cacheHAMedians.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheHAMedians      = tmp;
                return(indicator);
            }
        }
 protected override void OnStartUp()
 {
     ham = HAMedians(hAAlpha);
     med = zSortedWindow(ham.Value, windowLength);
 }