public void AddIntervalWhileRunning() { OHLCBarStream blt = new OHLCBarStream(new ForexSecurity("TST")); blt.AddInterval(BarInterval.Minute); blt.AddInterval(BarInterval.FiveMin); blt.GotNewBar += new SymBarIntervalDelegate(blt_GotNewBar); Tick[] tape = TestBarList.SampleData(); blt.Initialize(); // add ticks from tape to tracker for (int i = 0; i < tape.Length; i++) { blt.GotTick(tape[i]); if (i == 1) { blt.AddInterval(120); } } //make sure we got one symbol as bar events Assert.Equal(1, syms.Count); // make sure our symbols matched barlist count Assert.Equal(blt.SymbolCount, syms.Count); // make sure same on individual bars Assert.True(blt[120].Count > 0); }
public void IntervalRequestDuringRun() { OHLCBarStream blt = new OHLCBarStream(new ForexSecurity("TST")); blt.AddInterval(BarInterval.FiveMin); blt.GotNewBar += new SymBarIntervalDelegate(blt_GotNewBar); Tick[] tape = TestBarList.SampleData(); blt.Initialize(); // add ticks from tape to tracker for (int i = 0; i < tape.Length; i++) { blt.GotTick(tape[i]); var value = blt[BarInterval.Minute].RecentBar; } // Check if the data differs per interval Assert.NotEqual(blt[BarInterval.Minute][-2].Close, blt[BarInterval.FiveMin][-2].Close); }
private static PortfolioManager Get(string symbol) { //Initialize TradingPortfolio np = new TradingPortfolio(); //ADD INITIAL SECURITIES ForexSecurity security = new ForexSecurity(symbol); security.LotSize = 100000; //Lots security.PipSize = 0.0001M; //PipSize in 4 decimal places security.TickSize = 0.00001M; //Size of one tick security.PipValue = 1M; //PipValue, if unable to calculate to base currency security.Digits = 5; var account = new SimAccount("SIMULATED", "Sim account for backtesting", 10000, 100, "SIM"); np.SetAccount(account); np.Securities.AddSecurity(security); //ADD AGENT AND INJECT TEMPLATES np.InjectAgent <ExampleTradingAgent>(); //Set streams TradingAgent agent = (TradingAgent)np.Agents[0]; agent.AgentId = 115230; agent.TimeFrame = TimeSpan.FromSeconds(TimeFrameInSeconds); OHLCBarStream ls = new OHLCBarStream(np.Securities[symbol], np.Agents[0].TimeFrame); agent.SetDefaultStream(ls); ls.Initialize(); agent.Initialize(); agent.Start(); SimpleBacktester.OnMessage += SimpleBacktester_OnMessage; SimpleBacktester.OnProgress += SimpleBacktester_OnProgress; return(np); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorCommodityChannelIndex() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new CommodityChannelIndex(Period, stream.DefaultInterval, stream); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorTrueRange() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new TrueRange(stream, stream.DefaultInterval); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorSimpleMovingAverage() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new SimpleMovingAverage(Period, stream.DefaultInterval, stream); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorRelativeStrenghtIndex() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new RelativeStrengthIndex(Period, stream, stream.DefaultInterval); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorRateOfChange() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new RateOfChange(Period, stream.DefaultInterval, stream); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorMovingAverage() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new MovingAverage(Period, MovingAverageType.Weighted, stream, stream.DefaultInterval); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorMomentum() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new Momentum(Period, stream.DefaultInterval, stream); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorAverageTrueRange() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new Quantler.Indicators.AverageTrueRange(Period, stream.DefaultInterval, stream); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorWilliamsR() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new WilliamsR(Period, stream, stream.DefaultInterval); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorParabolicSAR() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new ParabolicSar(Period / 2, Period * 2, Period, stream, stream.DefaultInterval); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorMovingAverageConDiv() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new MovingAverageConDiv(Period / 2, Period * 2, Period, stream, stream.DefaultInterval); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorDirectionalIndex() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new DirectionalIndex(Period, stream, TimeSpan.FromMinutes(5)); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorAroonOscillator() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new AroonOscillator(Period, stream.DefaultInterval, stream); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorBollingerBands() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new BollingerBands(Period, 2, 2, stream, stream.DefaultInterval); }
/// <summary> /// Initialize test /// </summary> public TestIndicatorBalanceOfPower() { DataStream stream = new OHLCBarStream(new ForexSecurity("EURUSD"), BarInterval.FiveMin); _sut = new BalanceOfPower(stream, TimeSpan.FromMinutes(5)); }