public void IndicatorShouldRetrieveTickMaxPrice() { for (var i = 0; i < 10; i++) { var tick = _timeSeries.GetTick(i); var typicalPrice = tick.MaxPrice.Plus(tick.MinPrice).Plus(tick.ClosePrice).DividedBy(Decimal.Three); Assert.AreEqual(typicalPrice, _typicalPriceIndicator.GetValue(i)); } }
public void indicatorShouldRetrieveBarMaxPrice() { for (int i = 0; i < 10; i++) { IBar bar = timeSeries.GetBar(i); decimal typicalPrice = bar.MaxPrice.Plus(bar.MinPrice).Plus(bar.ClosePrice) .DividedBy(Decimals.THREE); Assert.AreEqual(typicalPrice, typicalPriceIndicator.GetValue(i)); } }
protected override Decimal Calculate(int index) { var typicalPrice = _typicalPriceInd.GetValue(index); var typicalPriceAvg = _smaInd.GetValue(index); var meanDeviation = _meanDeviationInd.GetValue(index); if (meanDeviation.IsZero) { return(Decimal.Zero); } return((typicalPrice.Minus(typicalPriceAvg)).DividedBy(meanDeviation.MultipliedBy(Factor))); }
protected override decimal Calculate(int index) { decimal typicalPrice = _typicalPriceInd.GetValue(index); decimal typicalPriceAvg = _smaInd.GetValue(index); decimal meanDeviation = _meanDeviationInd.GetValue(index); if (meanDeviation.IsZero()) { return(Decimals.Zero); } return((typicalPrice.Minus(typicalPriceAvg)).DividedBy(meanDeviation.MultipliedBy(FACTOR))); }