예제 #1
0
        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);
            //    }

            //}
        }
예제 #2
0
        public StrategyCacheNavigator(string cacheFolder, BarItemType barType, Guid cacheId, string[] strategyIdentityCodes)
        {
            this.pricebarCache = new PricebarCache(barType, cacheId, CacheModeOption.Read);

            this.barType = barType;
            this.cacheId = cacheId;

            strategyCacheProfiles = new Dictionary <string, StrategyCacheProfile>();

            foreach (string strategyIdentity in strategyIdentityCodes)
            {
                strategyCacheProfiles.Add(strategyIdentity, new StrategyCacheProfile(strategyIdentity, barType, cacheId));
            }

            InitializeDataFrame();
        }
예제 #3
0
        public TimeBasedDataFeed(TimeBarItemType timeBarItemType, BarItem openingBar, Guid cacheId, bool cachingEnabled = true)
        {
            this.timeBarItemType = timeBarItemType;
            this.period          = timeBarItemType.Value;
            this.startTime       = openingBar.Time;
            this.Restart(startTime);
            this.ResetPrice(openingBar.Open);
            this.Update(openingBar);
            this.SetNextRange();

            this.cachingEnabled = cachingEnabled;
            this.cacheId        = cacheId;
            if (cachingEnabled)
            {
                cachedPricebar = new PricebarCache(timeBarItemType, cacheId);
                cachedPricebar.Initialize();
            }
        }