Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 23:50:56 +0000



[Programming Help] - ALERT Not Working

View Count: 498

[2020-06-15 18:46:10]
User19100 - Posts: 9
Hello, I've created the following formula, which works with "Color Background based on ALERT Condition" but I want it to trigger 5 minutes before the top of the hour. When I add the "BARTIME" formula, it doesn't work. I don't get the color background nor does it trigger an ALERT.

=AND(ID16.SG1[-1]>ID17.SG3[-1],ID16.SG1<ID17.SG3,ID15.SG1[-1]>ID15.SG1,ID15.SG2[-1]>ID15.SG2,ID13.SG1[-1]>ID13.SG1,ID14.SG1[-1]>ID14.SG1,BARTIME>=TIME(5,55,0),BARTIME<=TIME(6,0,0))

Any help would be greatly appreciated.
[2020-06-16 02:58:19]
Sawtooth - Posts: 3993
BARTIME is only the bar's opening timestamp. There is currently no Main Price Graph Variable for the Last Bar End DateTime. This value is only available in a spreadsheet study in cell J41.

(Maybe SC Engineering would add this variable for Simple Alerts.)

To make this work in a spreadsheet study, add the Spreadsheet System/Alert study.
- Set the Chart Region to 1.
- Give it a name in the Spreadsheet Name field.
- Choose the Column K Alert sound. (On the Settings and Inputs tab, not on the Alerts tab.)
- On the Subgraphs tab, set the DrawStyle of SG1 to Background, and set all other subgraphs to Ignore.
- On the spreadsheet sheet, put this formula in cell K3:
=IF(ROW()=3,AND(ID16.SG1@4>ID17.SG3@4,ID16.SG1@3<ID17.SG3@3,ID15.SG1@4>ID15.SG1@3,ID15.SG2@4>ID15.SG2@3,ID13.SG1@4>ID13.SG1@3,ID14.SG1@4>ID14.SG1@3,FRACTIME($J$41)-(HOUR(FRACTIME($J$41))/24)>=55/1440,FRACTIME($J$41)-(HOUR(FRACTIME($J$41))/24)<60/1440),0)

This will color the background at the current bar beginning 5 min before the top of the hour until the top of the hour, when all of the other conditions are also TRUE.
If you want to color the background of more than the current bar, give the ROW function a range of bars, where ROW()=3 is the current bar, and earlier bars are in rows below, e.g. AND(ROW()>=3,ROW()<8)

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account