/// <summary> /// Computes the next value of this indicator from the given state /// </summary> /// <param name="input">The input given to the indicator</param> /// <returns> A new value for this indicator </returns> protected override decimal ComputeNextValue(IBaseDataBar input) { if (!IsReady) { Open.Update(input.Time, (input.Open + input.Close) / 2); Close.Update(input.Time, (input.Open + input.High + input.Low + input.Close) / 4); High.Update(input.Time, input.High); Low.Update(input.Time, input.Low); } else { Open.Update(input.Time, (Open + Close) / 2); Close.Update(input.Time, (input.Open + input.High + input.Low + input.Close) / 4); High.Update(input.Time, Math.Max(input.High, Math.Max(Open, Close))); Low.Update(input.Time, Math.Min(input.Low, Math.Min(Open, Close))); } var volume = 0.0m; if (input is TradeBar) { volume = ((TradeBar)input).Volume; } else if (input is RenkoBar) { volume = ((RenkoBar)input).Volume; } Volume.Update(input.Time, volume); return(Close); }
/// <summary> /// Computes the next value of this indicator from the given state /// </summary> /// <param name="input">The input given to the indicator</param> /// <returns> A new value for this indicator </returns> protected override decimal ComputeNextValue(IBaseDataBar input) { if (!IsReady) { Open.Update(input.Time, (input.Open + input.Close) / 2); Close.Update(input.Time, (input.Open + input.High + input.Low + input.Close) / 4); High.Update(input.Time, input.High); Low.Update(input.Time, input.Low); } else { Open.Update(input.Time, (Open + Close) / 2); Close.Update(input.Time, (input.Open + input.High + input.Low + input.Close) / 4); High.Update(input.Time, Math.Max(input.High, Math.Max(Open, Close))); Low.Update(input.Time, Math.Min(input.Low, Math.Min(Open, Close))); } return(Close); }
/// <summary> /// Computes the next value of this indicator from the given state /// </summary> /// <param name="input">The input given to the indicator</param> /// <returns> A new value for this indicator </returns> protected override decimal ComputeNextValue(TradeBar input) { if (!IsReady) { Open.Update(new IndicatorDataPoint(input.Time, (input.Open + input.Close) / 2)); Close.Update(new IndicatorDataPoint(input.Time, (input.Open + input.High + input.Low + input.Close) / 4)); High.Update(new IndicatorDataPoint(input.Time, input.High)); Low.Update(new IndicatorDataPoint(input.Time, input.Low)); } else { Open.Update(new IndicatorDataPoint(input.Time, (Open + Close) / 2)); Close.Update(new IndicatorDataPoint(input.Time, (input.Open + input.High + input.Low + input.Close) / 4)); High.Update(new IndicatorDataPoint(input.Time, Math.Max(input.High, Math.Max(Open, Close)))); Low.Update(new IndicatorDataPoint(input.Time, Math.Min(input.Low, Math.Min(Open, Close)))); } return(Close); }