/// <summary> /// Generate the input to the neural network to predict. It will look at the current /// date as well as the number of days leading up to it specified by EvalWindow. /// This method is used both internally and externally. /// </summary> /// <param name="marketData">The market data to use.</param> /// <param name="marketDataIndex">The point that we want to predict from.</param> /// <returns></returns> public INeuralData CreateData( List <LoadedMarketData> marketData, int marketDataIndex) { INeuralData neuralData = new BasicNeuralData(14); int totalPatterns = 0; var patternCount = new int[14]; for (var i = 0; i < EvalWindow; i++) { var data = marketData[(marketDataIndex - EvalWindow) + i]; var candle = new IdentifyCandleStick(); candle.SetStats(data); var pattern = candle.DeterminePattern(); if (pattern == IdentifyCandleStick.UNKNOWN) { continue; } totalPatterns++; patternCount[pattern]++; } if (totalPatterns == 0) { return(null); } for (var i = 0; i < 14; i++) { neuralData[i] = patternCount[i] / ((double)totalPatterns); } return(neuralData); }
/// <summary> /// Generate the input to the neural network to predict. It will look at the current /// date as well as the number of days leading up to it specified by EvalWindow. /// This method is used both internally and externally. /// </summary> /// <param name="marketData">The market data to use.</param> /// <param name="marketDataIndex">The point that we want to predict from.</param> /// <returns></returns> public INeuralData CreateData( List<LoadedMarketData> marketData, int marketDataIndex) { INeuralData neuralData = new BasicNeuralData(14); int totalPatterns = 0; int[] patternCount = new int[14]; for (int i = 0; i < EvalWindow; i++) { LoadedMarketData data = marketData[(marketDataIndex-EvalWindow) + i]; IdentifyCandleStick candle = new IdentifyCandleStick(); candle.SetStats(data); int pattern = candle.DeterminePattern(); if (pattern != IdentifyCandleStick.UNKNOWN) { totalPatterns++; patternCount[pattern]++; } } if (totalPatterns == 0) return null; for (int i = 0; i < 14; i++) { neuralData[i] = ((double)patternCount[i]) / ((double)totalPatterns); } return neuralData; }