I'm attempting to create a database that will record the max price of an item in relation to an API for Black Desert Online. In the first column is the Index number of an item and the second column is the market price posted by this code into the MaxPrice Tab from the API Prices Tab:
function readSalesNum() {
var sheetFrom = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Prices");
var sheetTo = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("MaxPrice");
// Copy from 2nd row, 5th column, all rows for one column
var index = sheetFrom.getRange(2, 2, sheetFrom.getLastRow(), 1).getValues();
var marketprice = sheetFrom.getRange(2, 5, sheetFrom.getLastRow(), 1).getValues();
//Item name overwrites itself
sheetTo.getRange(1,1,index.length,1).setValues(index);
sheetTo.getRange(1,2,index.length,1).setValues(marketprice);
}
I need to keep track of the max price all items sell for. The API is updated every 30 mins. In BDO there are market caps for all items enforced by the Devs. Which is why originally the script would post a new column with updated prices every 2 hours, and then =MAX to find the current highest price of the item. However if a new item is added to the API (in aphabetical order) it skews all the data
I need a script that will look at column A in MaxPrices, find the matching number in Prices then post the current market price to column B in MaxPrices. Then will only update column B in MaxPrices if the current market price in the Prices tab goes up for each item.