/// <summary>Get feature details from the RSI indicator</summary> private void RSIFeatures() { // Value is in the range [0,100] with 30/70 seen as the trigger levels. // Entry signals are when the RSI indicator has gone outside the 30/70 level, // turned around, then fallen back within the 30/70 range var rsi = Bot.Indicators.RelativeStrengthIndex(Bot.MarketSeries.Close, 14); // Approximate the RSI curve with a quadratic var x = (int)(CurrentIndex - 1 - Instrument.FirstIdx); var y = rsi.Result[x]; var dy = rsi.Result.FirstDerivative(x); var ddy = rsi.Result.SecondDerivative(x); var q = Quadratic.FromDerivatives(x, y, dy, ddy); // Estimate where the RSI will cross back into 30-70 range. If that's the next candle // then it's a entry signal //var d = rsi.Result.LastValue; // var dist = (d - 50.0) / 20.0; // values.Add(dist); // For now, just map high/low values var score = Maths.Sigmoid(y - 50.0, 20); // [-0.5 = 30, +0.5 = 70] Features.Add(new Feature("RSI", score)); }