Support Board
Date/Time: Tue, 04 Nov 2025 05:09:22 +0000
Persistent and Incrementing Variables
View Count: 788
|   [2023-03-08 04:32:23]     |  
| User486817 - Posts: 83 | 
| 
                Hello, I am looking at this page regarding Persistent and Incrementing Variables: Spreadsheet Example Formulas and Usage: Formula to Count Bars Since An Event I am using the Color Bar Based on Alert Condition Study on a chart. I'm trying to count bars since a buy/sell alert was triggered. How can i translate the below two formulas using the ID1.SG1 notation i'm used to? i have this formula =IF(ID6.SG1=0,ID16.SG1[-1]+1,0) where ID6 is the Color Bar Based on Alert Condition study with formula =ID4.SG2<>0 and ID16.SG1 is the spreadsheet formula -- this works. but if ID6 is the same Color Bar Based on Alert Condition study, but the formula has multiple conditions like =OR(ID4.SG2<>0, ID5.SG2<>0, ID6.SG2<>0)for some reason it will not work. is there a way to achieve the same functionality of the below two formulas using only the spreadsheet formula study? can these two formulas be translated using ID1.SG1 notation? Buy Alert =IF(M3, 0,IF(OR(K3, P4 > 0), P4 + 1, P4)) Sell Alert =IF(K3, 0,IF(OR(M3, Q4 > 0), Q4 + 1, Q4)) thank you,  | 
        
|   [2023-03-08 13:01:19]     |  
| Sawtooth - Posts: 4285 | 
| 
                 can these two formulas be translated using ID1.SG1 notation? 
Yes.Buy bar count: =IF(SellAlert[0], 0,IF(OR(BuyAlert[0], ID1.SG1[-1] > 0), ID1.SG1[-1] + 1, ID1.SG1[-1])) where ID1 is this Spreadsheet Formula study. Sell bar count: =IF(BuyAlert[0], 0,IF(OR(SellAlert[0], ID2.SG1[-1] > 0), ID2.SG1[-1] + 1, ID2.SG1[-1])) where ID2 is this Spreadsheet Formula study. Date Time Of Last Edit: 2023-03-08 15:59:24  
             | 
        
To post a message in this thread, you need to log in with your Sierra Chart account:
