예제 #1
0
        /// <summary>
        /// Pivot Points.
        /// </summary>
        /// <returns></returns>
        public Pivots Pivots(Data.IDataSeries input, Data.PivotRange pivotRangeType, Data.HLCCalculationMode priorDayHLC, double userDefinedClose, double userDefinedHigh, double userDefinedLow, int width)
        {
            if (cachePivots != null)
                for (int idx = 0; idx < cachePivots.Length; idx++)
                    if (cachePivots[idx].PivotRangeType == pivotRangeType && cachePivots[idx].PriorDayHLC == priorDayHLC && Math.Abs(cachePivots[idx].UserDefinedClose - userDefinedClose) <= double.Epsilon && Math.Abs(cachePivots[idx].UserDefinedHigh - userDefinedHigh) <= double.Epsilon && Math.Abs(cachePivots[idx].UserDefinedLow - userDefinedLow) <= double.Epsilon && cachePivots[idx].Width == width && cachePivots[idx].EqualsInput(input))
                        return cachePivots[idx];

            lock (checkPivots)
            {
                checkPivots.PivotRangeType = pivotRangeType;
                pivotRangeType = checkPivots.PivotRangeType;
                checkPivots.PriorDayHLC = priorDayHLC;
                priorDayHLC = checkPivots.PriorDayHLC;
                checkPivots.UserDefinedClose = userDefinedClose;
                userDefinedClose = checkPivots.UserDefinedClose;
                checkPivots.UserDefinedHigh = userDefinedHigh;
                userDefinedHigh = checkPivots.UserDefinedHigh;
                checkPivots.UserDefinedLow = userDefinedLow;
                userDefinedLow = checkPivots.UserDefinedLow;
                checkPivots.Width = width;
                width = checkPivots.Width;

                if (cachePivots != null)
                    for (int idx = 0; idx < cachePivots.Length; idx++)
                        if (cachePivots[idx].PivotRangeType == pivotRangeType && cachePivots[idx].PriorDayHLC == priorDayHLC && Math.Abs(cachePivots[idx].UserDefinedClose - userDefinedClose) <= double.Epsilon && Math.Abs(cachePivots[idx].UserDefinedHigh - userDefinedHigh) <= double.Epsilon && Math.Abs(cachePivots[idx].UserDefinedLow - userDefinedLow) <= double.Epsilon && cachePivots[idx].Width == width && cachePivots[idx].EqualsInput(input))
                            return cachePivots[idx];

                Pivots indicator = new Pivots();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.PivotRangeType = pivotRangeType;
                indicator.PriorDayHLC = priorDayHLC;
                indicator.UserDefinedClose = userDefinedClose;
                indicator.UserDefinedHigh = userDefinedHigh;
                indicator.UserDefinedLow = userDefinedLow;
                indicator.Width = width;
                Indicators.Add(indicator);
                indicator.SetUp();

                Pivots[] tmp = new Pivots[cachePivots == null ? 1 : cachePivots.Length + 1];
                if (cachePivots != null)
                    cachePivots.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cachePivots = tmp;
                return indicator;
            }
        }
예제 #2
0
        /// <summary>
        /// Pivot Points.
        /// </summary>
        /// <returns></returns>
        public Pivots Pivots(Data.IDataSeries input, Data.PivotRange pivotRangeType, Data.HLCCalculationMode priorDayHLC, double userDefinedClose, double userDefinedHigh, double userDefinedLow, int width)
        {
            if (cachePivots != null)
            {
                for (int idx = 0; idx < cachePivots.Length; idx++)
                {
                    if (cachePivots[idx].PivotRangeType == pivotRangeType && cachePivots[idx].PriorDayHLC == priorDayHLC && Math.Abs(cachePivots[idx].UserDefinedClose - userDefinedClose) <= double.Epsilon && Math.Abs(cachePivots[idx].UserDefinedHigh - userDefinedHigh) <= double.Epsilon && Math.Abs(cachePivots[idx].UserDefinedLow - userDefinedLow) <= double.Epsilon && cachePivots[idx].Width == width && cachePivots[idx].EqualsInput(input))
                    {
                        return(cachePivots[idx]);
                    }
                }
            }

            lock (checkPivots)
            {
                checkPivots.PivotRangeType = pivotRangeType;
                pivotRangeType             = checkPivots.PivotRangeType;
                checkPivots.PriorDayHLC    = priorDayHLC;
                priorDayHLC = checkPivots.PriorDayHLC;
                checkPivots.UserDefinedClose = userDefinedClose;
                userDefinedClose             = checkPivots.UserDefinedClose;
                checkPivots.UserDefinedHigh  = userDefinedHigh;
                userDefinedHigh            = checkPivots.UserDefinedHigh;
                checkPivots.UserDefinedLow = userDefinedLow;
                userDefinedLow             = checkPivots.UserDefinedLow;
                checkPivots.Width          = width;
                width = checkPivots.Width;

                if (cachePivots != null)
                {
                    for (int idx = 0; idx < cachePivots.Length; idx++)
                    {
                        if (cachePivots[idx].PivotRangeType == pivotRangeType && cachePivots[idx].PriorDayHLC == priorDayHLC && Math.Abs(cachePivots[idx].UserDefinedClose - userDefinedClose) <= double.Epsilon && Math.Abs(cachePivots[idx].UserDefinedHigh - userDefinedHigh) <= double.Epsilon && Math.Abs(cachePivots[idx].UserDefinedLow - userDefinedLow) <= double.Epsilon && cachePivots[idx].Width == width && cachePivots[idx].EqualsInput(input))
                        {
                            return(cachePivots[idx]);
                        }
                    }
                }

                Pivots indicator = new Pivots();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input            = input;
                indicator.PivotRangeType   = pivotRangeType;
                indicator.PriorDayHLC      = priorDayHLC;
                indicator.UserDefinedClose = userDefinedClose;
                indicator.UserDefinedHigh  = userDefinedHigh;
                indicator.UserDefinedLow   = userDefinedLow;
                indicator.Width            = width;
                Indicators.Add(indicator);
                indicator.SetUp();

                Pivots[] tmp = new Pivots[cachePivots == null ? 1 : cachePivots.Length + 1];
                if (cachePivots != null)
                {
                    cachePivots.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cachePivots         = tmp;
                return(indicator);
            }
        }