Support Board
Date/Time: Thu, 28 Nov 2024 20:51:21 +0000
[Programming Help] - Adding a filter to color background based on alert condition study
View Count: 607
[2023-03-27 05:34:18] |
User273277 - Posts: 59 |
I have a working "color background based on alert condition" study (id5), and want to add an additional condition to reduce the cases where it is triggered. For each bar where id5 is triggered (I keep 3 days data, and want to visually see every case where it triggers), first check: 1. If there has been any closed bar with a high below the first swing low (id4) after the most recent zigzag HH (id3) 2. Then don't show the background change I'm not sure where to start with this. I found this that might be related: Spreadsheet Example Formulas and Usage: Return Last Two Zig Zag Reversal Values Any examples of similar filters would help a lot. |
[2023-03-27 15:32:11] |
ForgivingComputers.com - Posts: 960 |
The Background Based on Alert study would not be able to keep track of the last two Zig Zags, so you would need to use a Spreadsheet System/Alert or a custom study.
|
[2023-03-27 15:51:32] |
User273277 - Posts: 59 |
Thanks, that helps point me in the right direction. Any suggestions as to how this might look? Maybe something like a couple of arrays and some bar timestamp comparisons in a spreadsheet alert? Not sure where to go here. |
[2023-03-27 16:15:04] |
ForgivingComputers.com - Posts: 960 |
Have you worked with Sierra Chart spreadsheets before? They are similar but not the same as Excel spreadsheets. The major difference is the rows, columns, and specific cells have unique features. Rows 1 and 2 are Header Rows, the most important being row 2. Rows 3 and higher have one chart bar per row, with the base data in columns A-G. (Date/Time, Open, High, Low, Close, Volume and Number of trades). User Formulas begin in Column K, with a default of 16. Up to 60 formulas can be used. Study data starts in Column AA (or the first column after the user formulas. Other trading-related variables are available in columns H and J. When you create a user formula, you enter it in Row 3, and it will be propagated down with any cell references automatically being adjusted. For example, if Cell K3 has the formula for the range of a bar (High-Low). The formula in K3 would be =(C3-D3) The spreadsheet will automatically refresh the rows below, so cell K4 would have: =(C4-D4)
It is a best practice to use the "IDxSGy@z" notation for study data cell references, instead of the column name ("AA3"). This will prevent issues that will arise if studies are moved or added to the chart before the last study. The direct cell reference will not be updated if the columns are rearranged by changing the study list, as the ID/SG is less likely to change. If the Sierra Chart documentation is too much to digest at once, you can get a lot of useful information from Tom Gilb's website https://www.sawtoothtrade.com/ Tom is active on the board and answer most spreadsheet questions. |
[2023-03-27 16:40:10] |
User273277 - Posts: 59 |
Thank you, this helps a lot. I had read the docs, but seeing the spreadsheet layout here is much easier to read. Now to figure out how to create arrays and compare them for every active candle. |
[2023-04-03 03:06:28] |
User273277 - Posts: 59 |
I managed to make a list of the time of the most recent HH for each price level: K=round(GetCorrespondingMatch(ID3.SG2@3:ID3.SG2@1003,2,0,0,0,A3:A1003,0),8) This creates a serial time list like this: 45016.66538991 45016.66538991 45016.66538991 45016.64598403 45016.64598403 45016.64598403 45016.64598403 45016.588594 45016.588594 45016.51995282 45016.51995282 Then I mark each HH with a 1, thinking I can use this to deliniate each new "sub-array" staring point. Another way to think of this is a trigger or enable switch to start looking for the next part: L=if(K3>K4,1,0) 45016.66538991 0 45016.66538991 0 45016.66538991 1 45016.64598403 0 45016.64598403 0 45016.64598403 0 45016.64598403 1 45016.588594 0 45016.588594 1 45016.51995282 0 45016.51995282 0 Now I need to grab the first pivot low after each HH (the 1's above) is triggered. How do I grab the EARLIESTNONZEROVALUE for the "sub-array" containing the pivot low between the most recent HH (column L marked with a 1, and now() / current bar ? Date Time Of Last Edit: 2023-04-03 03:52:23
|
To post a message in this thread, you need to log in with your Sierra Chart account: