public void ComputesCorrectly() { var momp = new MomentumPercent(50); double epsilon = 1e-3; TestHelper.TestIndicator(momp, "spy_with_roc50.txt", "Rate of Change 50", (ind, expected) => Assert.AreEqual(expected, (double)ind.Current.Value, epsilon)); }
/// <summary> /// Creates a new MomentumPercent indicator. This will compute the n-period percent change in the security. /// The indicator will be automatically updated on the given resolution. /// </summary> /// <param name="symbol">The symbol whose momentum we want</param> /// <param name="period">The period over which to compute the momentum</param> /// <param name="resolution">The resolution</param> /// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param> /// <returns>The momentum indicator for the requested symbol over the specified period</returns> public MomentumPercent MOMP(string symbol, int period, Resolution?resolution = null, Func <BaseData, decimal> selector = null) { string name = CreateIndicatorName(symbol, "MOMP" + period, resolution); var momentum = new MomentumPercent(name, period); RegisterIndicator(symbol, momentum, resolution, selector); return(momentum); }
/// <summary> /// Creates a new MomentumPercent indicator. This will compute the n-period percent change in the security. /// The indicator will be automatically updated on the given resolution. /// </summary> /// <param name="symbol">The symbol whose momentum we want</param> /// <param name="period">The period over which to compute the momentum</param> /// <param name="resolution">The resolution</param> /// <returns>The momentum indicator for the requested symbol over the specified period</returns> public MomentumPercent MOMP(string symbol, int period, Resolution?resolution = null) { string name = CreateIndicatorName(symbol, "MOMP" + period, resolution); var momentum = new MomentumPercent(name, period); RegisterIndicator(symbol, momentum, resolution, x => x.Value); return(momentum); }
public void ComputesCorrectly() { var momp = new MomentumPercent(50); double epsilon = 1e-3; TestHelper.TestIndicator(momp, "spy_with_rocp50.txt", "Rate of Change % 50", (ind, expected) => ((double)ind.Current.Price).Should().BeApproximately(expected, epsilon)); }
public void ResetsProperly() { var momp = new MomentumPercent(50); foreach (var data in TestHelper.GetDataStream(51)) { momp.Update(data); } Assert.IsTrue(momp.IsReady); momp.Reset(); TestHelper.AssertIndicatorIsInDefaultState(momp); }
public void ComputesCorrectly() { var delay = new Delay(3); var sma = new SimpleMovingAverage(3); var momp = new MomentumPercent(3); foreach (var data in TestHelper.GetDataStream(4)) { delay.Update(data); sma.Update(data); momp.Update(data); if (sma == 0m) { Assert.AreEqual(0m, momp.Current.Value); } else { decimal abs = data - delay; decimal perc = abs / sma; Assert.AreEqual(perc, momp.Current.Value); } } }