public void BuildCore(ISessionIndicator sessionIndicator) { string coreIdentityCode = StochasticsCore.CreateIdentityCode(periods); core = sessionIndicator.CoreIndicators.ContainsKey(coreIdentityCode) ? sessionIndicator.CoreIndicators[coreIdentityCode].IndicatorInstance as StochasticsCore : null; if (core == null) { string priceChangeIdentityCode = PriceChangeCore.CreateIdentityCode(); PriceChangeCore priceChangeCore = sessionIndicator.CoreIndicators.ContainsKey(priceChangeIdentityCode) ? sessionIndicator.CoreIndicators[priceChangeIdentityCode].IndicatorInstance as PriceChangeCore : null; if (priceChangeCore == null) { priceChangeCore = PriceChangeCore.CreateInstance(barType); sessionIndicator.CoreIndicators.Add(priceChangeCore.IdentityCode, new CoreIndicator(priceChangeCore)); } string highsAndLowsIdentityCode = HighsAndLowsCore.CreateIdentityCode(periods); HighsAndLowsCore highsAndLowsCore = sessionIndicator.CoreIndicators.ContainsKey(highsAndLowsIdentityCode) ? sessionIndicator.CoreIndicators[highsAndLowsIdentityCode].IndicatorInstance as HighsAndLowsCore : null; if (highsAndLowsCore == null) { highsAndLowsCore = HighsAndLowsCore.CreateInstance(barType, periods); sessionIndicator.CoreIndicators.Add(highsAndLowsCore.IdentityCode, new CoreIndicator(highsAndLowsCore)); } if (smoothedPercentK) { core = StochasticsCore.CreateInstance(barType, periods, smoothedPercentKPeriods, smoothedPercentDPeriods, priceChangeCore, highsAndLowsCore, this.OnCalculationCompleted); } else { core = StochasticsCore.CreateInstance(barType, periods, smoothedPercentK, priceChangeCore, highsAndLowsCore, this.OnCalculationCompleted); } sessionIndicator.CoreIndicators.Add(core.IdentityCode, new CoreIndicator(core)); } }
private void Init(BarItemType barItemType, int periods, PriceChangeCore priceChangeCore, HighsAndLowsCore highsAndLowsCore, IndicatorDelegates.CalculationCompletedHandler onCalculationCompleted = null) { this.barCount = periods; this.maxBarIndex = barCount - 1; this.percentDSmoothingConstant = (double)2 / (smoothedPercentDPeriods + 1); this.AddDependency(barItemType, highsAndLowsCore); this.AddDependency(barItemType, priceChangeCore); this.highsAndLows = highsAndLowsCore; this.priceChange = priceChangeCore; this.identityCode = CreateIdentityCode(periods); if (onCalculationCompleted != null) { this.Calculated += onCalculationCompleted; } }
public static StochasticsCore CreateInstance(BarItemType barItemType, int periods, int smoothedPercentKPeriods, int smoothedPercentDPeriods, PriceChangeCore priceChangeCore, HighsAndLowsCore highsAndLowsCore, IndicatorDelegates.CalculationCompletedHandler onCalculationCompleted = null) { return(new StochasticsCore(barItemType, periods, smoothedPercentKPeriods, smoothedPercentDPeriods, priceChangeCore, highsAndLowsCore, onCalculationCompleted)); }
//Full stochastics private StochasticsCore(BarItemType barItemType, int periods, int smoothedPercentKPeriods, int smoothedPercentDPeriods, PriceChangeCore priceChangeCore, HighsAndLowsCore highsAndLowsCore, IndicatorDelegates.CalculationCompletedHandler onCalculationCompleted = null) : base(DISPLAY_NAME, SHORT_NAME, DESCRIPTION, barItemType) { this.smoothedPercentK = true; this.smoothedPercentKPeriods = smoothedPercentKPeriods; this.smoothedPercentDPeriods = smoothedPercentDPeriods; Init(barItemType, periods, priceChangeCore, highsAndLowsCore, onCalculationCompleted); }