Skip to main content

Investing.com data uploaded but i am not able to use the data for email alerts.kindly help me

I have configured to fetch the data on every 1 min from investing wesite.

enter image description here

The table data is fetching from website. while trying to update date when 15 minutes status D column change to either strong sell or strong buy time on time and date column the functions are not working. please find below requirement.

  1. I need to update time and date in G column when D column update from the website either Strong sell or strong buy.
  2. once the time and data updated if the time and date less then 1 minute then need to get email alerts.

I have tried functions on the table but not working. kindly help me on this why the functions are not working .onchange .onedit.

I am using below query but i am not getting alert.

function getData() { 
  var sheetName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Main"); 
  
  var queryString = Math.random(); 
  var cellFunction = '=IMPORTHTML("https://www.investing.com/technical/commodities-technical-summary","table",4)';
  var datetime = Utilities.formatDate(new Date(), "IST", "yyyy/MM/dd HH: mm:ss");
    sheetName.getRange('A1').setValue(cellFunction); 
  sheetName.getRange('g2').setValue(datetime);
}

function sendNotification() {
    var sheetName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Main");   
  //if("D13" == sheetName.range.getA1Notation() || "D12" == e.range.getA1Notation()) {
    if("C13" == "Strong Buy" and "h13"=now() diff 1 minutes) {


      
  //Define Notification Details
      var recipients = "[email protected]";
      var subject = "Update"+e.range.getSheet().getName();
      var body = "cell C13 has been updated";
      
        var datetime = Utilities.formatDate(new Date(), "IST", "yyyy/MM/dd HH: mm:ss");
      sheetName.getRange('H13').setValue(datetime); 
      
  //Send the Email
      MailApp.sendEmail(recipients, subject, body);
    }
  }