private static void TestPipesData(SequentialIndicator <IndicatorDataPoint> sequential) { var data1 = new IndicatorDataPoint(DateTime.UtcNow, 1m); var data2 = new IndicatorDataPoint(DateTime.UtcNow, 2m); var data3 = new IndicatorDataPoint(DateTime.UtcNow, 3m); var data4 = new IndicatorDataPoint(DateTime.UtcNow, 4m); var data5 = new IndicatorDataPoint(DateTime.UtcNow, 5m); // sma has one item sequential.Update(data1); Assert.IsFalse(sequential.IsReady); Assert.AreEqual(0m, sequential.Current.Value); // sma has two items sequential.Update(data2); Assert.IsFalse(sequential.IsReady); Assert.AreEqual(0m, sequential.Current.Value); // sma is ready, delay will repeat this value sequential.Update(data3); Assert.IsFalse(sequential.IsReady); Assert.AreEqual(2.5m, sequential.Current.Value); // delay is ready, and repeats its first input sequential.Update(data4); Assert.IsTrue(sequential.IsReady); Assert.AreEqual(2.5m, sequential.Current.Value); // now getting the delayed data sequential.Update(data5); Assert.IsTrue(sequential.IsReady); Assert.AreEqual(3.5m, sequential.Current.Value); }
public override void Initialize() { SetStartDate(2009, 01, 01); SetEndDate(2015, 01, 01); AddSecurity(SecurityType.Equity, Symbol, Resolution.Minute); int count = 6; int offset = 5; int period = 15; // define our sma as the base of the ribbon var sma = new SimpleMovingAverage(period); ribbon = Enumerable.Range(0, count).Select(x => { // define our offset to the zero sma, these various offsets will create our 'displaced' ribbon var delay = new Delay(offset*(x+1)); // define an indicator that takes the output of the sma and pipes it into our delay indicator var delayedSma = delay.Of(sma); // register our new 'delayedSma' for automaic updates on a daily resolution RegisterIndicator(Symbol, delayedSma, Resolution.Daily, data => data.Value); return delayedSma; }).ToArray(); }
private static void TestPipesData(SequentialIndicator<IndicatorDataPoint> sequential) { var data1 = new IndicatorDataPoint(DateTime.UtcNow, 1m); var data2 = new IndicatorDataPoint(DateTime.UtcNow, 2m); var data3 = new IndicatorDataPoint(DateTime.UtcNow, 3m); var data4 = new IndicatorDataPoint(DateTime.UtcNow, 4m); var data5 = new IndicatorDataPoint(DateTime.UtcNow, 5m); // sma has one item sequential.Update(data1); Assert.IsFalse(sequential.IsReady); Assert.AreEqual(0m, sequential.Current.Value); // sma has two items sequential.Update(data2); Assert.IsFalse(sequential.IsReady); Assert.AreEqual(0m, sequential.Current.Value); // sma is ready, delay will repeat this value sequential.Update(data3); Assert.IsFalse(sequential.IsReady); Assert.AreEqual(2.5m, sequential.Current.Value); // delay is ready, and repeats its first input sequential.Update(data4); Assert.IsTrue(sequential.IsReady); Assert.AreEqual(2.5m, sequential.Current.Value); // now getting the delayed data sequential.Update(data5); Assert.IsTrue(sequential.IsReady); Assert.AreEqual(3.5m, sequential.Current.Value); }
public void PipesDataFromFirstToSecond() { var first = new SimpleMovingAverage(2); var second = new Delay(1); var sequential = new SequentialIndicator <IndicatorDataPoint>(first, second); TestPipesData(sequential); }
public void PipesDataFromFirstToSecond() { var first = new SimpleMovingAverage(2); var second = new Delay(1); var sequential = new SequentialIndicator<IndicatorDataPoint>(first, second); TestPipesData(sequential); }
public void ResetsProperly() { var first = new Delay(1); var second = new Delay(1); var sequential = new SequentialIndicator <IndicatorDataPoint>(first, second); foreach (var data in TestHelper.GetDataStream(3)) { sequential.Update(data); } Assert.IsTrue(first.IsReady); Assert.IsTrue(second.IsReady); Assert.IsTrue(sequential.IsReady); sequential.Reset(); TestHelper.AssertIndicatorIsInDefaultState(first); TestHelper.AssertIndicatorIsInDefaultState(second); TestHelper.AssertIndicatorIsInDefaultState(sequential); }
public void ResetsProperly() { var first = new Delay(1); var second = new Delay(1); var sequential = new SequentialIndicator<IndicatorDataPoint>(first, second); foreach (var data in TestHelper.GetDataStream(3)) { sequential.Update(data); } Assert.IsTrue(first.IsReady); Assert.IsTrue(second.IsReady); Assert.IsTrue(sequential.IsReady); sequential.Reset(); TestHelper.AssertIndicatorIsInDefaultState(first); TestHelper.AssertIndicatorIsInDefaultState(second); TestHelper.AssertIndicatorIsInDefaultState(sequential); }