コード例 #1
0
 protected override void OnStartUp()
 {
     opens    = zKAMA(Open, lookback, lowSmoothing, maxSmoothing);
     highs    = zKAMA(High, lookback, lowSmoothing, maxSmoothing);
     lows     = zKAMA(Low, lookback, lowSmoothing, maxSmoothing);
     closes   = zKAMA(Close, lookback, lowSmoothing, maxSmoothing);
     isRising = true;
 }
コード例 #2
0
ファイル: zKAMA.cs プロジェクト: Sandy4321/NinjaIndicators
        /// <summary>
        /// kaufman adaptive
        /// </summary>
        /// <returns></returns>
        public zKAMA zKAMA(Data.IDataSeries input, int lookback, int lowSmooth, int maxSmooth)
        {
            if (cachezKAMA != null)
            {
                for (int idx = 0; idx < cachezKAMA.Length; idx++)
                {
                    if (cachezKAMA[idx].Lookback == lookback && cachezKAMA[idx].LowSmooth == lowSmooth && cachezKAMA[idx].MaxSmooth == maxSmooth && cachezKAMA[idx].EqualsInput(input))
                    {
                        return(cachezKAMA[idx]);
                    }
                }
            }

            lock (checkzKAMA)
            {
                checkzKAMA.Lookback  = lookback;
                lookback             = checkzKAMA.Lookback;
                checkzKAMA.LowSmooth = lowSmooth;
                lowSmooth            = checkzKAMA.LowSmooth;
                checkzKAMA.MaxSmooth = maxSmooth;
                maxSmooth            = checkzKAMA.MaxSmooth;

                if (cachezKAMA != null)
                {
                    for (int idx = 0; idx < cachezKAMA.Length; idx++)
                    {
                        if (cachezKAMA[idx].Lookback == lookback && cachezKAMA[idx].LowSmooth == lowSmooth && cachezKAMA[idx].MaxSmooth == maxSmooth && cachezKAMA[idx].EqualsInput(input))
                        {
                            return(cachezKAMA[idx]);
                        }
                    }
                }

                zKAMA indicator = new zKAMA();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input     = input;
                indicator.Lookback  = lookback;
                indicator.LowSmooth = lowSmooth;
                indicator.MaxSmooth = maxSmooth;
                Indicators.Add(indicator);
                indicator.SetUp();

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