Login Page - Create Account

Support Board


Date/Time: Thu, 28 Mar 2024 12:43:27 +0000



Post From: Buy Alert is trigerred accurately via spreadsheet but not via ASCIL

[2022-09-28 23:19:40]
kam2001 - Posts: 65
Hi,
i am trying to get refernce to Buy alert in my Ascil code.
My spreadsheet buy alert values changes during the bar time frame so I've set it to 'Alert only once per Bar' and 'Signal only on Bar close' which works perfectly via spreadsheet settings but when i am using this spreadsheet by reference in the code below it triggers my if condition but the alert is still changeable during bar period as bar is not closed yet. I am already using GetBarHasClosedStatus method.
Any suggestions. Thanks

const char *SheetCollectionName = "my-alerts";

const char *SheetName = "Sheet2";

void *SheetHandle = sc.GetSpreadsheetSheetHandleByName(SheetCollectionName, SheetName, false);

SCString CellString;
SCString MessageOut;
double CellValue = 0.0;

int status = sc.GetBarHasClosedStatus(sc.UpdateStartIndex);
if (status == BHCS_BAR_HAS_CLOSED) {
if (SheetHandle == nullptr) {
// sc.AddMessageToLog("No Spreadsheet...", 0);
// some code for no spreadsheet

} else {
if (sc.GetSheetCellAsDouble(SheetHandle, 11, 2, CellValue)) {
if (CellValue > 0.0) {
sc.AddMessageToLog("Bar Has Closed", true);
sc.AddMessageToLog("Show Alert Here", 0);
MessageOut.Format("Cell Value = %f", CellValue);
sc.AddMessageToLog(MessageOut, 0);
sc.Subgraph[0][sc.Index] = 100;
}
}
// some different code for spreadsheet found
}
}