void generateIA(string pair = "BTCUSDT", string interval = "1d", int totalEntry = 5, int totalExit = 1, int totalEpochs = 99999, int round = 5) { try { string separator = "."; ReturnDataArray returnDataArray = getDataArray(pair, interval, "1000"); List <double[]> exitList = new List <double[]>(); List <double[]> entryList = new List <double[]>(); for (int z = 0; z < returnDataArray.arrayPriceClose.Length; z++) { try { List <double> lineEntry = new List <double>(); List <double> lineExit = new List <double>(); for (int i = 0; i < totalEntry; i++) { lineEntry.Add(double.Parse("0" + separator + Math.Round(returnDataArray.arrayPriceClose[z + i]))); } lineExit.Add(double.Parse("0" + separator + Math.Round(returnDataArray.arrayPriceClose[z + totalEntry]))); exitList.Add(lineExit.ToArray()); entryList.Add(lineEntry.ToArray()); z += totalEntry - 1; } catch { } } double[][] entry = entryList.ToArray(); double[][] exits = exitList.ToArray(); Perceptron perceptron = new Perceptron(totalEntry, totalExit); for (int i = 0; i < totalEpochs; i++) { for (int k = 0; k < entry.Length; k++) { perceptron.Train(entry[k], exits[k]); } } List <double> lastsPrices = new List <double>(); returnDataArray = getDataArray(pair, interval, totalEntry.ToString()); for (int i = 0; i < returnDataArray.arrayPriceClose.Length; i++) { lastsPrices.Add(double.Parse("0" + separator + Math.Round(returnDataArray.arrayPriceClose[i]))); } double[][] newEntry = { lastsPrices.ToArray() }; String result = perceptron.Compute(newEntry[0])[0].ToString(); result = result.Replace("0,", "").Replace("0.", "").Substring(0, round); string vies = "BAIXA"; if (double.Parse(result) > Math.Round(returnDataArray.arrayPriceClose[returnDataArray.arrayPriceClose.Length - 1])) { vies = "ALTA"; } lblResultado.Text = "O resultado para o próximo intervalo é de: $ " + result + "<br/>"; lblResultado.Text += "Como o BITCOIN hoje está custando $" + (returnDataArray.arrayPriceClose[returnDataArray.arrayPriceClose.Length - 1]) + " e a previsão para o BITCOIN amanhã é de " + vies; } catch (Exception ex) { lblResultado.Text = "ERROR " + ex.Message + ex.StackTrace; } }