I am trying to add the name of every individual "ticker" pulled from my spreadsheet to the "ownedticker" array, as well as update the quantity and total price of the stock in other arrays "ownedq" and "ownedtp", respectively.
However, this code doesn't work for some reason. Appreciate the help!
function pullTransactions() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var transactions = ss.getSheetByName("TransactionHistory"); //Transaction History
var rows = transactions.getDataRange();
var numRows = rows.getNumRows();
var tickers = transactions.getSheetValues(3, 3, (numRows-2), 1);
var ppss = transactions.getSheetValues(3, 5, (numRows-2), 1);
var qs = transactions.getSheetValues(3, 7, (numRows-2), 1);
var ownedticker = [];
var ownedq = [];
var ownedtp = [];
for (var i = 0; i <= tickers.length; i++) {
var ticker = tickers[i];
var pps = ppss[i];
var q = qs[i];
var check = ownedq[i];
for (var j = 0; j <= ownedticker.length; j++) {
if (ownedticker[j]) {
ownedq[j] += q;
ownedtp[j] += (q*pps);
}
}
if (check == ownedq[i]){
ownedticker.push(ticker);
ownedq.push(q);
ownedtp.push(pps*q);
}
}
}