Support Board
Date/Time: Fri, 09 May 2025 14:22:27 +0000
[Programming Help] - Spreadsheet formula study to count occurences since session open bar
View Count: 508
[2023-05-26 20:36:30] |
User562383 - Posts: 10 |
How to calculate how many times events have occurred since the session open bar using the spreadsheet formula study? The simplest example would be bar count since the open. Eg If it's the opening session bar, set it to 0, otherwise add 1 to the previous cell IF(ABS(BARTIME - TIME(9, 30, 0)) < TIME(0, 0, 1),0,ID22.SG1@4+1) Results in every entry = 0. IF(ABS(BARTIME - TIME(9, 30, 0)) < TIME(0, 0, 1),0,1) and IF(ABS(BARTIME - TIME(9, 30, 0)) < TIME(0, 0, 1),0,CU4+1) Results in opening bar = 0 and every other entry = 1 except opening bar, but I need a running count. Eg 0,1,2,3,4,5... |
[2023-05-27 14:47:11] |
Sawtooth - Posts: 4213 |
You have mixed the syntaxes between Alert syntax and spreadsheet syntax. The Spreadsheet Formula study uses Alert syntax and, despite its name, is not a spreadsheet study. How to calculate how many times events have occurred since the session open bar using the spreadsheet formula study?
You'll need to create a persistent variable using two IF statements.Here is an example using spreadsheet syntax. You'll need to convert it to Alert syntax. Spreadsheet Example Formulas and Usage: Count Events Since First Occurrence For the Spreadsheet Formula study, like this: =IF(AND(BARTIME>TIME(9,29,59),BARTIME<TIME(9,30,01)),0,IF(EventTrue,ID1.SG1[-1]+1,ID1.SG1[-1])) where ID1 is the Spreadsheet Formula study For the Spreadsheet Study study, like this e.g. in cell P3: =IF(AND(FRACTIME(A3)>TIME(9,29,59),FRACTIME(A3)<TIME(9,30,01)),0,IF(EventTrue,P4+1,P4)) Date Time Of Last Edit: 2023-05-28 13:05:17
|
To post a message in this thread, you need to log in with your Sierra Chart account: