public void BuildCore(ISessionIndicator sessionIndicator) { string coreIdentityCode = ADXCore.CreateIdentityCode(periods); core = sessionIndicator.CoreIndicators.ContainsKey(coreIdentityCode) ? sessionIndicator.CoreIndicators[coreIdentityCode].IndicatorInstance as ADXCore : null; if (core == null) { string trueRangeIdentityCode = TrueRangeCore.CreateIdentityCode(); TrueRangeCore trueRangeCore = sessionIndicator.CoreIndicators.ContainsKey(trueRangeIdentityCode) ? sessionIndicator.CoreIndicators[trueRangeIdentityCode].IndicatorInstance as TrueRangeCore : null; if (trueRangeCore == null) { trueRangeCore = TrueRangeCore.CreateInstance(barType); sessionIndicator.CoreIndicators.Add(trueRangeCore.IdentityCode, new CoreIndicator(trueRangeCore)); } string dmIdentityCode = DirectionalMovementCore.CreateIdentityCode(); DirectionalMovementCore dmCore = sessionIndicator.CoreIndicators.ContainsKey(dmIdentityCode) ? sessionIndicator.CoreIndicators[dmIdentityCode].IndicatorInstance as DirectionalMovementCore : null; if (dmCore == null) { dmCore = DirectionalMovementCore.CreateInstance(barType); sessionIndicator.CoreIndicators.Add(dmCore.IdentityCode, new CoreIndicator(dmCore)); } string dxIdentityCode = DirectionalMovementIndexCore.CreateIdentityCode(periods); DirectionalMovementIndexCore dxCore = sessionIndicator.CoreIndicators.ContainsKey(dxIdentityCode) ? sessionIndicator.CoreIndicators[dxIdentityCode].IndicatorInstance as DirectionalMovementIndexCore : null; if (dxCore == null) { dxCore = DirectionalMovementIndexCore.CreateInstance(barType, periods, trueRangeCore, dmCore); sessionIndicator.CoreIndicators.Add(dxCore.IdentityCode, new CoreIndicator(dxCore)); } core = ADXCore.CreateInstance(barType, periods, dxCore, this.OnCalculationCompleted); sessionIndicator.CoreIndicators.Add(core.IdentityCode, new CoreIndicator(core)); } }
private ADXCore(BarItemType barItemType, int periods, DirectionalMovementIndexCore directionalMovementIndexCore, IndicatorDelegates.CalculationCompletedHandler onCalculationCompleted = null) : base(DISPLAY_NAME, SHORT_NAME, DESCRIPTION, barItemType) { this.barCount = periods; this.maxBarIndex = periods - 1; this.AddDependency(barItemType, directionalMovementIndexCore); this.dxCore = directionalMovementIndexCore; this.identityCode = CreateIdentityCode(periods); if (onCalculationCompleted != null) { this.Calculated += onCalculationCompleted; } }
public static ADXCore CreateInstance(BarItemType barItemType, int periods, DirectionalMovementIndexCore directionalMovementIndexCore, IndicatorDelegates.CalculationCompletedHandler onCalculationCompleted = null) { return(new ADXCore(barItemType, periods, directionalMovementIndexCore, onCalculationCompleted)); }