/// <summary> /// Called on every new bar of data. /// </summary> /// <param name="currentBar">The current bar of the simulation</param> public override void OnBarUpdate(int currentBar) { base.OnBarUpdate(currentBar); Rsi rsi = (Rsi)_dependents[0]; Value[currentBar] = UtilityMethods.Sma(rsi.Avg, currentBar, 3); }
/// <summary> /// Called on every new bar of data. /// </summary> /// <param name="currentBar">The current bar of the simulation</param> protected override void OnBarUpdate(int currentBar) { base.OnBarUpdate(currentBar); Rsi rsiInd = (Rsi)Dependents[0]; double rsi = rsiInd.Value[currentBar]; double rsiL = UtilityMethods.Min(rsiInd.Value, currentBar, _period); double rsiH = UtilityMethods.Max(rsiInd.Value, currentBar, _period); if (rsi != rsiL && rsiH != rsiL) { Value[currentBar] = (rsi - rsiL) / (rsiH - rsiL); } else { Value[currentBar] = 0; } }
/// <summary> /// Called on every new bar of data. /// </summary> /// <param name="currentBar">The current bar of the simulation</param> public override void OnBarUpdate(int currentBar) { base.OnBarUpdate(currentBar); Rsi rsi = (Rsi)_dependents[0]; double rsiMinValue = UtilityMethods.Min(rsi.Value, currentBar, _periodStoch); double rsiMaxValue = UtilityMethods.Max(rsi.Value, currentBar, _periodStoch); double denom = rsiMaxValue - rsiMinValue; StoRsi[currentBar] = denom > 0.0 ? 100.0 * ((rsi.Value[currentBar] - rsiMinValue) / denom) : 0.0; // SMA or EMA depending on preference. SK[currentBar] = UtilityMethods.Sma(StoRsi, currentBar, _periodSK); SD[currentBar] = UtilityMethods.Sma(SK, currentBar, _periodSD); //SK[currentBar] = UtilityMethods.Ema(StoRsi, SK, currentBar, _periodSK); //SD[currentBar] = UtilityMethods.Ema(SK, SD, currentBar, _periodSK); }