public void Start(int barsPause = 0) { this.barsPause = barsPause; if (dataStreamSource is string) { string barDataFile = dataStreamSource as string; BacktestBroker backtestBroker = new BacktestBroker(); brokerAccount = new BrokerAccount(); backtestBroker.LoadAccount(brokerAccount, cacheId); backtestSession = backtestBroker.CreateSession(brokerAccount.AccountId, tickerType, barType, dataStreamSource.ToString(), cacheId); foreach (AnalyticsItem item in registeredAnalytics) { if (item.AnaylticsType == AnalyticsTypeOption.Indicator) { backtestSession.Indicators.Add <IIndicatorCore>(item.Instance as IIndicatorCore); } if (item.AnaylticsType == AnalyticsTypeOption.Signal) { backtestSession.Signals.Add <ISignal>(item.Instance as ISignal); } } barCount = 0; backtestSession.NewBar += OnNewBar; backtestSession.Signals.OpenCache(barType); backtestSession.Start(); backtestSession.Signals.CloseCache(barType); //SignalCacheNavigator signalCacheNavigator = new SignalCacheNavigator("cache", barType, cacheId, registeredAnalytics[0].IdentityCode); //ignalDataFrame signalDataFrame= signalCacheNavigator.GetSignalDataFrame(signalCacheNavigator.StartBarDate, 300); chartControl.Initialize(200, 100, "cache", barType, cacheId, registeredAnalytics[0].IdentityCode); if (barsPause == 0) { //Refresh(); } //double profit= brokerAccount.Orders.GetTotalProfit(SpotForex.EURUSD); //double loss = brokerAccount.Orders.GetTotalLoss(SpotForex.EURUSD); } }
public void M2Timeframe() { BacktestBroker backtestBroker = new BacktestBroker(); BrokerAccount brokerAccount = new BrokerAccount(); backtestBroker.LoadAccount(new BrokerAccount(), Guid.Empty); BacktestSession backtestSession = backtestBroker.CreateSession(brokerAccount.AccountId, SpotForex.EURUSD, Timeframes.M1, @"data\EURUSD-M1.bar", Guid.Empty); BollingerBands bollingerBands = new BollingerBands(Timeframes.M2, 21); backtestSession.Indicators.Add(bollingerBands); backtestSession.Start(); }
public void MACDTest() { BacktestBroker backtestBroker = new BacktestBroker(); BrokerAccount brokerAccount = new BrokerAccount(); backtestBroker.LoadAccount(new BrokerAccount(), Guid.Empty); BacktestSession backtestSession = backtestBroker.CreateSession(brokerAccount.AccountId, SpotForex.EURUSD, Timeframes.M1, @"data\EURUSD-M1.bar", Guid.Empty); MACD macd = new MACD(Timeframes.M1, 12, 26, 9); backtestSession.Indicators.Add(macd); backtestSession.Start(); }
public void EMATest() { BacktestBroker backtestBroker = new BacktestBroker(); BrokerAccount brokerAccount = new BrokerAccount(); backtestBroker.LoadAccount(new BrokerAccount(), Guid.Empty); BacktestSession backtestSession = backtestBroker.CreateSession(brokerAccount.AccountId, SpotForex.EURUSD, Timeframes.M1, @"data\EURUSD-M1.bar", Guid.Empty); EMA ema = new EMA(Timeframes.M1, 100); backtestSession.Indicators.Add(ema); backtestSession.Start(); }
public BrokerAccount Start(int barsPause = 0) { this.barsPause = barsPause; BrokerAccount brokerAccount = null; if (dataStreamSource is string) { string barDataFile = dataStreamSource as string; BacktestBroker backtestBroker = new BacktestBroker(); brokerAccount = new BrokerAccount(); backtestBroker.LoadAccount(brokerAccount, cacheId); backtestSession = backtestBroker.CreateSession(brokerAccount.AccountId, tickerType, barType, dataStreamSource.ToString(), cacheId); foreach (AnalyticsItem item in registeredAnalytics) { if (item.AnaylticsType == AnalyticsTypeOption.Indicator) { backtestSession.Indicators.Add <IIndicatorCore>(item.Instance as IIndicatorCore); } if (item.AnaylticsType == AnalyticsTypeOption.Signal) { backtestSession.Signals.Add <ISignal>(item.Instance as ISignal); } //if (item.AnaylticsType == AnalyticsTypeOption.Strategy) //{ // backtestSession.Strategies.Add<IStrategy>(item.Instance as IStrategy); //} } barCount = 0; backtestSession.NewBar += OnNewBar; backtestSession.Start(); } return(brokerAccount); }