public void Initialize(int maxBars, int barsViewable, string cacheFolder, BarItemType barType, Guid cacheId, string strategyIdentityCode) { multiChart1.Initialize(maxBars, barsViewable); this.SelectedTimeframe = barType; pricebarCache = new PricebarCache(barType, cacheId, CacheModeOption.Read); this.strategyDataFrame = new StrategyDataFrame(strategyIdentityCode, 300, pricebarCache); timeNavigator1.Initialize(pricebarCache.StartBarDate, pricebarCache.EndBarDate); strategyFrameReader = strategyDataFrame.GetFrameReader(pricebarCache.StartBarDate); IPriceActionChart priceChart = this.PriceActionChart; priceChart.Show(); priceChart.SetDataPoints(strategyFrameReader.PriceBars); List <ChartSignalItem> signalItems = new List <ChartSignalItem>(); foreach (BarItem barItem in strategyFrameReader.PriceBars) { MarketOrderState marketOrderState = strategyFrameReader.Read(barItem.Time); if (marketOrderState != MarketOrderState.NoOrder) { signalItems.Add(new ChartSignalItem(marketOrderState == MarketOrderState.Long ? SignalState.Long : marketOrderState == MarketOrderState.Short ? SignalState.Short : SignalState.NoSignal, barItem.Time)); } } priceChart.PlotSignal(signalItems.ToArray()); //foreach (IndicatorChartingInfo chartingInfo in strategyDataFrame.GetIndicatorChartingInfo()) //{ // ChartIndicatorItem[] chartIndicators = strategyDataFrame.GetIndicators(chartingInfo.IdentityCode, chartingInfo.SeriesLabel); // if (chartingInfo.ChartRange == ChartRangeOption.PriceActionRange) // { // priceChart.PlotIndicator(GetSeriesLabel(chartingInfo), chartIndicators, chartingInfo.ChartType); // } // else if (chartingInfo.ChartRange == ChartRangeOption.PositiveHundredRange) // { // if (!PercentageChart.Visible) // { // PercentageChart.Show(); // } // PercentageChart.PlotIndicator(GetSeriesLabel(chartingInfo), chartIndicators, chartingInfo.ChartType); // } // else if (chartingInfo.ChartRange == ChartRangeOption.PipRange) // { // if (!OscillatorChart.Visible) // { // OscillatorChart.Show(); // } // OscillatorChart.PlotIndicator(GetSeriesLabel(chartingInfo), chartIndicators, chartingInfo.ChartType); // } //} }
private void InitializeDataFrame() { this.strategyDataFrame = new StrategyDataFrame(); strategies = new List <string>(); uniqueSignals = new Dictionary <string, List <AnalyticsOwnerItem> >(); uniqueIndicators = new Dictionary <string, List <AnalyticsOwnerItem> >(); foreach (KeyValuePair <string, StrategyCacheProfile> strategyProfile in this.strategyCacheProfiles) { strategies.Add(strategyProfile.Key); foreach (SignalCacheProfile signalProfile in strategyProfile.Value.Signals) { if (uniqueSignals.ContainsKey(signalProfile.Header.IdentityCode)) { uniqueSignals[signalProfile.Header.IdentityCode].Add(new AnalyticsOwnerItem(strategyProfile.Key, AnalyticsTypeOption.Strategy)); } else { List <AnalyticsOwnerItem> ownerStrategy = new List <AnalyticsOwnerItem>(); ownerStrategy.Add(new AnalyticsOwnerItem(strategyProfile.Key, AnalyticsTypeOption.Strategy)); uniqueSignals.Add(signalProfile.Header.IdentityCode, ownerStrategy); } //Signal level indicators foreach (KeyValuePair <string, IndicatorCache> indicator in signalProfile.Indicators) { if (uniqueIndicators.ContainsKey(indicator.Key)) { uniqueIndicators[indicator.Key].Add(new AnalyticsOwnerItem(signalProfile.Header.IdentityCode, AnalyticsTypeOption.Signal)); } else { List <AnalyticsOwnerItem> ownerSignal = new List <AnalyticsOwnerItem>(); ownerSignal.Add(new AnalyticsOwnerItem(signalProfile.Header.IdentityCode, AnalyticsTypeOption.Signal)); uniqueSignals.Add(signalProfile.Header.IdentityCode, ownerSignal); } } //TODO: Do the same for Alerts } //Strategy level indicators foreach (KeyValuePair <string, IndicatorCache> indicator in strategyProfile.Value.Indicators) { if (uniqueIndicators.ContainsKey(indicator.Key)) { uniqueIndicators[indicator.Key].Add(new AnalyticsOwnerItem(strategyProfile.Value.Header.IdentityCode, AnalyticsTypeOption.Strategy)); } else { List <AnalyticsOwnerItem> ownerStrategy = new List <AnalyticsOwnerItem>(); ownerStrategy.Add(new AnalyticsOwnerItem(strategyProfile.Value.Header.IdentityCode, AnalyticsTypeOption.Strategy)); uniqueSignals.Add(strategyProfile.Value.Header.IdentityCode, ownerStrategy); } } //TODO: Do the same for Alerts } timeKeyedStrategies = this.strategyCache.SelectAllStrategies(); }